/* Eunobia Color Variables */
:root {
    --accent: #839ec9;
    --accent-dark: #6f87aa;
    --accent-light: #a8c4f0;
    --light: #ffffff;
    --muted: #65799b;
    --bg-page: #9BB5FE;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-page);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto; /* Allow scrolling normally */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

/* Prevent scrolling when level is active */
body.level-active {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
}

html.level-active {
    overflow: hidden !important;
    height: 100% !important;
}

/* Ensure dragged items are never clipped by body/html */
body .tool-item.dragging,
body .chemical-item.dragging,
html .tool-item.dragging,
html .chemical-item.dragging {
    clip-path: none !important;
    clip: auto !important;
    overflow: visible !important;
    contain: none !important;
}

/* Prevent scrolling on container and workbench, but allow sidebars to scroll */
.container.show {
    overflow: hidden !important;
    overscroll-behavior: none !important;
}

.container.show .workbench,
.container.show .workbench-surface,
.container.show .workbench-content {
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
}

/* Allow sidebars to scroll for tools/chemicals */
.tools-sidebar,
.chemical-rack {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    touch-action: pan-y !important; /* Allow vertical scrolling in sidebars */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--accent) #f1f1f1;
    /* Allow dragged items to escape sidebar boundaries */
    contain: layout style paint;
    /* Don't clip dragged items */
    clip-path: none;
    clip: auto;
}

/* Ensure dragged items can escape sidebar boundaries */
.tools-sidebar .tool-item.dragging,
.chemical-rack .chemical-item.dragging,
.tools-sidebar .chemical-item.dragging,
.chemical-rack .tool-item.dragging {
    /* Remove from sidebar flow completely when dragging */
    position: fixed !important;
    /* Ensure parent doesn't clip */
    transform: translateZ(0) !important;
    /* Highest z-index */
    z-index: 999999 !important;
    /* No clipping */
    clip-path: none !important;
    clip: auto !important;
    overflow: visible !important;
    contain: none !important;
}

.tools-sidebar::-webkit-scrollbar,
.chemical-rack::-webkit-scrollbar {
    width: 8px;
}

.tools-sidebar::-webkit-scrollbar-track,
.chemical-rack::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tools-sidebar::-webkit-scrollbar-thumb,
.chemical-rack::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 4px;
}

.tools-sidebar::-webkit-scrollbar-thumb:hover,
.chemical-rack::-webkit-scrollbar-thumb:hover {
    background: var(--accent-dark);
}

/* Improve scrolling on workbench - properties merged into main .workbench-content definition */

.container {
    display: none; /* Hidden by default - shown when level is selected via JavaScript */
    grid-template-columns: 250px 1fr 250px; /* Increased sidebar width from 200px to 250px */
    grid-template-rows: 1fr; /* Content row only - header is separate */
    height: calc(100vh - 80px); /* Account for fixed header */
    margin-top: 70px; /* Space for fixed header */
    overflow: hidden; /* Fixed - no scrolling in container */
}

.container.show {
    display: grid; /* Show as grid when level is selected */
    min-height: calc(100vh - 80px);
    gap: 15px; /* Increased gap */
    padding: 15px; /* Increased padding */
    padding-bottom: 60px; /* Space for toggle bar */
    overflow: hidden; /* Fixed - no scrolling in level */
}

/* Header Controls - Top Bar (Always Visible) - Eunobia Style */
.header-controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3000;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 12px 20px;
    background: white;
    border-bottom: 3px solid var(--accent);
    margin: 0;
    max-width: 100%;
}

/* Eunobia Brand Logo - Home Button */
.eunobia-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #000;
    font-weight: bold;
    font-size: 1.5rem;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.eunobia-brand:hover {
    opacity: 0.8;
    text-decoration: none;
    color: #000;
}

.eunobia-logo {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.eunobia-brand-text {
    font-weight: bold;
    color: #000;
}

/* Exam Mode Timer and Back Button */
.header-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    top: 50px; /* Lower the timer to avoid overlapping logo */
}

#exam-timer-container {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

/* Desktop: Keep timer in header center */
@media (min-width: 769px) {
    #exam-timer-container {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto;
        transform: none;
        flex-direction: row;
    }
}

/* Mobile: Move exam timer and back button to bottom */
@media (max-width: 768px) {
    #exam-timer-container {
        position: fixed !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 1000 !important;
        flex-direction: column !important;
        gap: 10px !important;
        background: rgba(0, 0, 0, 0.7) !important;
        padding: 15px 20px !important;
        border-radius: 12px !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
        top: auto !important;
        width: auto !important;
        min-width: 200px !important;
    }
    
    /* Don't hide header-center, just make it not interfere */
    .header-center {
        position: static !important;
        transform: none !important;
        top: auto !important;
        left: auto !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        height: 0 !important;
        overflow: visible !important;
    }
}

.exam-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-weight: 600;
    font-size: 1.1em;
}

.timer-label {
    opacity: 0.9;
}

.timer-value {
    background: rgba(255, 255, 255, 0.3);
    padding: 4px 12px;
    border-radius: 15px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.btn-exam-back {
    background: var(--accent);
    border: 2px solid var(--accent-dark);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px var(--accent-dark);
}

.btn-exam-back:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px var(--accent-dark);
}

.btn-exam-back:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--accent-dark);
}

.btn-submit-salt {
    background: #4CAF50;
    border: 2px solid #388E3C;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #388E3C;
}

.btn-submit-salt:hover {
    background: #388E3C;
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px #388E3C;
}

.btn-submit-salt:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #388E3C;
}

/* Submit Button in Header */
.btn-submit-salt-header {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border: 2px solid #388E3C;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #388E3C;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-submit-salt-header:hover {
    background: linear-gradient(135deg, #45a049 0%, #4CAF50 100%);
    transform: translateY(-2px);
    box-shadow: 4px 4px 0px #388E3C;
}

.btn-submit-salt-header:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #388E3C;
}

/* Mobile Submit Button (Inside Level) */
.btn-submit-salt-mobile {
    display: none; /* Hidden by default, shown on mobile only */
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    border: 2px solid #388E3C;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #388E3C;
    z-index: 1000;
    white-space: nowrap;
}

.btn-submit-salt-mobile:hover {
    background: linear-gradient(135deg, #45a049 0%, #4CAF50 100%);
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 4px 4px 0px #388E3C;
}

.btn-submit-salt-mobile:active {
    transform: translateX(-50%) translate(2px, 2px);
    box-shadow: 1px 1px 0px #388E3C;
}

/* Show mobile submit button only on mobile devices */
@media (max-width: 1024px) {
    .btn-submit-salt-mobile {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
}

/* Hide mobile submit button on desktop */
@media (min-width: 1025px) {
    .btn-submit-salt-mobile {
        display: none !important;
    }
}

/* Salt Submission Modal */
.salt-submission-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.salt-submission-modal .modal-content {
    background: white;
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow: hidden;
}

.salt-submission-modal .modal-header {
    padding: 20px 30px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.salt-submission-modal .modal-header h2 {
    color: #333;
    margin: 0;
    font-size: 1.5em;
}

.salt-submission-modal .modal-close {
    background: none;
    border: none;
    font-size: 2em;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.salt-submission-modal .modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.salt-submission-modal .modal-body {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
}

.salt-submission-modal .salt-selector-modal {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.salt-submission-modal .input-group-modal {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.salt-submission-modal .input-group-modal label {
    font-weight: 600;
    color: #333;
    font-size: 1em;
}

.salt-submission-modal .salt-select-modal {
    padding: 12px 16px;
    border: 2px solid var(--accent);
    border-radius: 8px;
    font-size: 1em;
    background: white;
    color: #333;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.salt-submission-modal .salt-select-modal:focus {
    outline: none;
    border-color: var(--accent-dark);
    box-shadow: 0 0 0 3px rgba(131, 158, 201, 0.2);
}

.salt-submission-modal .modal-footer {
    padding: 20px 30px;
    border-top: 2px solid #e9ecef;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

.salt-submission-modal .btn-submit-modal {
    background: #4CAF50;
    border: 2px solid #388E3C;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #388E3C;
}

.salt-submission-modal .btn-submit-modal:hover {
    background: #388E3C;
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px #388E3C;
}

.salt-submission-modal .btn-submit-modal:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #388E3C;
}

.salt-submission-modal .btn-cancel-modal {
    background: #6c757d;
    border: 2px solid #5a6268;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1em;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #5a6268;
}

.salt-submission-modal .btn-cancel-modal:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px #5a6268;
}

.salt-submission-modal .btn-cancel-modal:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #5a6268;
}

/* Salt Input Modal */
.salt-input-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.salt-input-modal .modal-content {
    background: white;
    border-radius: 12px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.salt-input-modal h2 {
    color: #333;
    margin-bottom: 20px;
}

.salt-input-modal p {
    color: #666;
    margin-bottom: 20px;
}

.salt-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1.1em;
    border: 2px solid var(--accent);
    border-radius: 8px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.salt-input:focus {
    outline: none;
    border-color: var(--accent-dark);
    box-shadow: 0 0 0 3px rgba(131, 158, 201, 0.2);
}

.salt-input-modal .modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.salt-input-modal .btn-submit {
    background: #4CAF50;
    border: 2px solid #388E3C;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #388E3C;
}

.salt-input-modal .btn-submit:hover {
    background: #388E3C;
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px #388E3C;
}

.salt-input-modal .btn-submit:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #388E3C;
}

.salt-input-modal .btn-cancel {
    background: #6c757d;
    border: 2px solid #5a6268;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #5a6268;
}

.salt-input-modal .btn-cancel:hover {
    background: #5a6268;
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px #5a6268;
}

.salt-input-modal .btn-cancel:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #5a6268;
}

/* Exam Feedback */
.exam-feedback {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 30px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 10001;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.exam-feedback.error {
    background: #f44336;
    color: white;
}

.exam-feedback.success {
    background: #4CAF50;
    color: white;
}

.exam-feedback.info {
    background: #2196F3;
    color: white;
}

.header-separator {
    width: 1px;
    height: 30px;
    background: #e0e0e0;
    margin: 0 10px;
}

/* Container visibility handled by JavaScript */

/* Left Sidebar - Tools */
.tools-sidebar {
    background: rgba(240, 240, 245, 0.98); /* Darker background to differentiate items */
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* Fixed - no scrolling in sidebar */
    /* Desktop: flexible height, Mobile: fixed height (set in media query) */
    /* Allow dragged items to pop out - use contain only when dragging */
    position: relative;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.2em;
    color: #333;
}

.sidebar-close {
    background: #dc3545;
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1.5em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    padding: 0;
}

.sidebar-close:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Hide close button on desktop */
@media (min-width: 1025px) {
    .sidebar-close {
        display: none;
    }
}

.header-controls .btn-home,
.header-controls .btn-profile,
.header-controls .btn-sidebar-toggle {
    background: var(--accent);
    border: 2px solid var(--accent-dark);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    width: auto;
    min-width: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0px var(--accent-dark);
}

.header-controls .btn-home:hover,
.header-controls .btn-profile:hover,
.header-controls .btn-sidebar-toggle:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 4px 4px 0px var(--accent-dark);
}

/* User Menu */
.user-menu {
    position: relative;
}

.btn-user-menu {
    background: var(--accent);
    border: 2px solid var(--accent-dark);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 2px 2px 0px var(--accent-dark);
}

.header-profile-picture {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid white;
    flex-shrink: 0;
    box-shadow: 1px 1px 0px rgba(0,0,0,0.2);
}

.btn-user-menu:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
    box-shadow: 4px 4px 0px var(--accent-dark);
}

.username-display {
    font-weight: 600;
}

.menu-icon {
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.user-menu.active .menu-icon {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
    overflow: hidden;
}

.user-menu.active .user-menu-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-item {
    display: block;
    padding: 12px 20px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 0.95em;
    cursor: pointer;
}

.menu-item:hover {
    background: #f8f9fa;
}

.menu-divider {
    height: 1px;
    background: #e9ecef;
    margin: 8px 0;
}

/* Exam Mode Timer */
.exam-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 87, 34, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.exam-timer .timer-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.exam-timer .timer-value {
    font-family: 'Courier New', monospace;
    font-size: 1.2em;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 15px;
    min-width: 60px;
    text-align: center;
}

/* Exam Complete Modal */
.exam-complete-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.exam-complete-modal .modal-content {
    background: white;
    border-radius: 12px;
    padding: 40px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.exam-complete-modal h2 {
    color: #333;
    margin-bottom: 20px;
}

.exam-complete-modal .exam-time {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    margin: 20px 0;
}

.exam-complete-modal .exam-salt {
    color: #666;
    margin-bottom: 30px;
}

.exam-complete-modal .modal-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.exam-complete-modal .btn-primary,
.exam-complete-modal .btn-secondary {
    padding: 10px 20px;
    border: 2px solid var(--accent-dark);
    border-radius: 4px;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    box-shadow: 2px 2px 0px var(--accent-dark);
}

.exam-complete-modal .btn-primary {
    background: var(--accent);
    color: white;
}

.exam-complete-modal .btn-secondary {
    background: white;
    color: var(--accent-dark);
}

.exam-complete-modal .btn-primary:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px var(--accent-dark);
    color: white;
}

.exam-complete-modal .btn-secondary:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px var(--accent-dark);
    color: var(--accent-dark);
}

.exam-complete-modal .btn-primary:active,
.exam-complete-modal .btn-secondary:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--accent-dark);
}

/* Fixed position sidebar toggle buttons on sides of screen */
.btn-sidebar-toggle-fixed {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 998;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 12px 8px;
    border-radius: 0 15px 15px 0;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.btn-tools-toggle-fixed {
    left: 0;
    border-radius: 0 15px 15px 0;
}

.btn-chemicals-toggle-fixed {
    right: 0;
    border-radius: 15px 0 0 15px;
}

.btn-sidebar-toggle-fixed:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 3px 0 12px rgba(0, 0, 0, 0.3);
}

.btn-sidebar-toggle-fixed:active {
    transform: translateY(-50%) scale(0.95);
}

/* Hide fixed toggle buttons on desktop (sidebars always visible) */
@media (min-width: 1025px) {
    .btn-sidebar-toggle-fixed {
        display: none;
    }
}

/* Show fixed toggle buttons on mobile/tablet */
@media (max-width: 1024px) {
    .btn-sidebar-toggle-fixed {
        display: flex;
    }
}

.tools-sidebar h2 {
    color: #333;
    margin-bottom: 15px; /* Reduced margin */
    font-size: 1.2em;
    text-align: center;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.tools-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 10px; /* Match chemicals */
    padding: 12px; /* Match chemicals on desktop */
    background: #f8f9fa;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: element; /* Enable dragging on WebKit browsers */
    /* Don't set touch-action: none here - it prevents scrolling */
    /* touch-action will be set dynamically when dragging starts */
}

/* Pop-out effect when dragging - applies to all platforms */
.tool-item.dragging,
.tools-sidebar .tool-item.dragging,
.chemical-rack .tool-item.dragging {
    transform: scale(1.25) translateZ(50px) !important;
    z-index: 999999 !important; /* Highest possible z-index - no restrictions */
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5) !important;
    background: #e9ecef !important;
    border: 2px solid #667eea !important;
    position: fixed !important; /* Fixed positioning when dragging - pops out of sidebar */
    pointer-events: none !important;
    opacity: 1 !important;
    transition: none !important;
    /* Ensure it's visible above everything */
    isolation: isolate;
    /* Ensure it's not clipped by parent containers */
    contain: none !important;
    /* Prevent clipping by any parent */
    clip-path: none !important;
    clip: auto !important;
    overflow: visible !important;
    will-change: transform, left, top;
    /* Remove all restrictions */
    max-width: none !important;
    max-height: none !important;
    width: auto !important;
    height: auto !important;
}

.tool-item:hover:not(.dragging) {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateX(5px);
}

.tool-item:active {
    cursor: grabbing;
    color: #333 !important; /* Prevent text color change on mobile */
}

.tool-item:active span {
    color: #333 !important; /* Keep text color on active */
}

.tool-icon {
    width: 36px; /* Increased from 32px - bigger */
    height: 36px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    flex-shrink: 0;
    pointer-events: none; /* Allow drag events to pass through to parent */
}

.tool-item span {
    font-weight: 500;
    color: #333;
    pointer-events: none; /* Allow drag events to pass through to parent */
}

/* Main Workbench */
.workbench {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 25px; /* Increased from 20px */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* Fixed - no scrolling inside level */
    perspective: 1200px;
    /* Desktop: normal flow, Mobile: flexible (set in media query) */
}

.workbench-surface {
    width: 100%;
    height: 100%;
    background-image: url('assets/wmremove-transformed.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    border: 3px solid #4A4A4A;
    position: relative;
    min-height: 400px;
    transform: rotateX(5deg) rotateY(0deg);
    transform-style: preserve-3d;
    overflow: hidden; /* Prevent scrolling */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), inset 0 2px 10px rgba(255, 255, 255, 0.1);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: auto; /* CRITICAL: Allow drag and drop events on PC */
}

.workbench-title {
    display: none; /* Hidden - content moved to tools sidebar */
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #667eea;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 50;
}

/* Level display styles - now in header-controls */
.level-display {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(102, 126, 234, 0.1);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85em;
}

/* Home button styles - now in header-controls */
.btn-home {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-home:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.level-label {
    opacity: 0.9;
}

.level-number {
    background: white;
    color: #667eea;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.level-name {
    font-weight: 600;
}

.workbench-content {
    padding: 60px 20px 60px 20px; /* Added bottom padding for toggle bar */
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    overflow: hidden; /* No scrolling inside the workbench */
    -ms-user-select: none;
    pointer-events: auto; /* Ensure drop events work */
}

.instruction-text {
    text-align: center;
    color: #666;
    margin-top: 50px;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.instruction-text p {
    margin: 10px 0;
    font-size: 1.1em;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Right Sidebar - Chemical Rack */
.chemical-rack {
    background: rgba(240, 240, 245, 0.98); /* Darker background to differentiate items */
    border-radius: 10px;
    padding: 25px; /* Increased from 20px */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* Fixed - no scrolling in sidebar */
    /* Desktop: flexible height, Mobile: fixed height (set in media query) */
    /* Allow dragged items to pop out - use contain only when dragging */
    position: relative;
}

.rack-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    cursor: pointer;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: background 0.3s ease;
}

.rack-header:hover {
    background: #e9ecef;
}

.rack-header h2 {
    color: #333;
    font-size: 1.2em;
    border-bottom: none;
    margin: 0;
}

.toggle-icon {
    font-size: 0.8em;
    color: #667eea;
    transition: transform 0.3s ease;
}

.chemical-rack.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* Hide toggle icon on mobile - use close button instead */
@media (max-width: 1024px) {
    .toggle-icon {
        display: none;
    }
    
    .rack-header {
        cursor: default;
        background: transparent;
        padding: 0;
        margin-bottom: 15px;
        padding-bottom: 10px;
        border-bottom: 2px solid #e9ecef;
    }
    
    .rack-header:hover {
        background: transparent;
    }
}

.chemicals-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: all 0.3s ease;
}

.chemical-rack.collapsed .chemicals-list {
    display: none;
}

/* Ensure chemicals list is visible when sidebar is active */
.chemical-rack.active .chemicals-list {
    display: flex !important;
}

.chemical-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px; /* Increased from 12px - bigger */
    background: #f8f9fa;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: element; /* Enable dragging on WebKit browsers */
    /* Don't set touch-action: none here - it prevents scrolling */
    /* touch-action will be set dynamically when dragging starts */
}

/* Pop-out effect when dragging - applies to all platforms */
.chemical-item.dragging,
.tools-sidebar .chemical-item.dragging,
.chemical-rack .chemical-item.dragging {
    transform: scale(1.25) translateZ(50px) !important;
    z-index: 999999 !important; /* Highest possible z-index - no restrictions */
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.5) !important;
    background: #e9ecef !important;
    border: 2px solid #667eea !important;
    position: fixed !important; /* Fixed positioning when dragging - pops out of sidebar */
    pointer-events: none !important;
    opacity: 1 !important;
    transition: none !important;
    /* Ensure it's visible above everything */
    isolation: isolate;
    /* Ensure it's not clipped by parent containers */
    contain: none !important;
    /* Prevent clipping by any parent */
    clip-path: none !important;
    clip: auto !important;
    overflow: visible !important;
    will-change: transform, left, top;
    /* Remove all restrictions */
    max-width: none !important;
    max-height: none !important;
    width: auto !important;
    height: auto !important;
}

.chemical-item:hover:not(.dragging) {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateX(-5px);
}

.chemical-icon {
    width: 36px; /* Increased from 32px - bigger */
    height: 36px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    flex-shrink: 0;
    pointer-events: none; /* Allow drag events to pass through to parent */
}

.chemical-item span {
    font-weight: 500;
    color: #333;
    pointer-events: none; /* Allow drag events to pass through to parent */
}

.chemical-item:active {
    cursor: grabbing;
    color: #333 !important; /* Prevent text color change on mobile */
}

.chemical-item:active span {
    color: #333 !important; /* Keep text color on active */
}

/* Bottom Checklist Toggle Bar */
.checklist-toggle {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 25px; /* Increased padding */
    cursor: pointer;
    z-index: 101;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    user-select: none;
}

.checklist-toggle:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.3);
}

.toggle-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-weight: 600;
}

.toggle-icon {
    font-size: 1.8em; /* Increased from 1.2em to make more visible */
    transition: transform 0.3s ease;
    opacity: 1; /* Ensure it's always visible */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3)); /* Add shadow for visibility */
}

.checklist-toggle.active .toggle-icon {
    transform: rotate(180deg);
}

.toggle-text {
    font-size: 1.1em;
}

.toggle-progress {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9em;
    margin-left: auto;
}

/* Bottom Test Checklist - Slider Popup */
.test-checklist {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 15px 15px 0 0;
    padding: 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    position: fixed;
    bottom: -100%;
    left: 0;
    right: 0;
    height: 80vh; /* Set fixed height instead of max-height */
    max-height: 80vh;
    overflow-y: auto; /* Changed back to auto - will show scrollbar when needed */
    overflow-x: hidden;
    z-index: 100;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #667eea #f1f1f1; /* Firefox */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior: contain; /* Prevent scroll chaining */
}

.test-checklist.open {
    bottom: 0;
}

.test-checklist::-webkit-scrollbar {
    width: 12px; /* Increased from 8px for better visibility */
}

.test-checklist::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
    margin: 10px 0;
}

.test-checklist::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
    border: 2px solid #f1f1f1; /* Add border for better visibility */
}

.test-checklist::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Firefox scrollbar styling */
@-moz-document url-prefix() {
    .test-checklist {
        scrollbar-width: thin;
        scrollbar-color: #667eea #f1f1f1;
    }
}

.checklist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    position: relative;
}

.checklist-close {
    background: #f0f0f0;
    border: none;
    color: #667eea;
    font-size: 2em;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    margin-left: 15px;
}

.checklist-close:hover {
    background: #667eea;
    color: white;
    transform: rotate(90deg);
}

.checklist-header h2 {
    color: #333;
    font-size: 1.3em;
}

.test-progress {
    color: #667eea;
    font-weight: 600;
}

.test-categories {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.test-category {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.category-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #667eea;
    margin: 0;
    padding-bottom: 5px;
    border-bottom: 2px solid #e9ecef;
}

.test-tabs {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 10px;
}

/* Group Identification Tabs - Horizontal Table Format */
.group-identification-tabs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    max-width: 100%;
}

.group-identification-tabs .test-tab {
    min-width: 120px;
    padding: 12px 15px;
    flex-direction: row;
    justify-content: flex-start;
    text-align: left;
    background: white;
    border: 2px solid #dee2e6;
}

.group-identification-tabs .test-tab:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

.group-identification-tabs .test-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #764ba2;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.group-identification-tabs .test-number {
    font-size: 1.2em;
    margin-right: 8px;
    min-width: 24px;
}

.group-identification-tabs .test-name {
    font-size: 0.85em;
    flex: 1;
    text-align: left;
}

.group-identification-tabs .test-status {
    margin-left: auto;
    font-size: 1em;
}

.test-tab-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px dashed #dee2e6;
    color: #6c757d;
    font-style: italic;
}

.placeholder-text {
    font-size: 0.9em;
}

.identify-salt-section {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    padding: 15px 20px;
    border-top: 3px solid var(--accent);
    text-align: center;
    display: block !important; /* Always visible */
    z-index: 1000;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
}

.salt-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* Mobile styles for salt identification */
@media (max-width: 1024px) {
    .identify-salt-section {
        padding: 12px 15px;
        bottom: 0;
    }
    
    .salt-selector {
        gap: 10px;
        flex-direction: column;
    }
    
    .salt-selector label {
        font-size: 0.9em;
    }
    
    .salt-select {
        width: 100%;
        max-width: 250px;
        min-width: auto;
    }
    
    .btn-identify {
        width: 100%;
        max-width: 250px;
        margin-top: 5px;
    }
}

.salt-selector label {
    font-weight: 600;
    color: #333;
}

.salt-select {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 0.95em;
    background: white;
    color: #333;
    cursor: pointer;
    min-width: 150px;
}

.salt-select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.btn-identify {
    background: #28a745;
    color: white;
    border: 2px solid #1e7e34;
    padding: 12px 32px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px #1e7e34;
}

.btn-identify:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px #1e7e34;
}

.btn-identify:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #1e7e34;
}

.identify-hint {
    margin-top: 8px;
    color: #666;
    font-size: 0.85em;
}

.test-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    min-width: 120px;
}

.test-tab:hover {
    background: #e9ecef;
    border-color: #667eea;
}

.test-tab.active {
    background: #667eea;
    color: white;
    border-color: #764ba2;
}

.test-number {
    font-size: 1.5em;
    font-weight: bold;
}

.test-name {
    font-size: 0.9em;
    text-align: center;
}

.test-status {
    font-size: 1.2em;
}

.test-inference {
    font-size: 0.7em;
    color: #555;
    margin-top: 4px;
    text-align: center;
    max-width: 120px;
    word-wrap: break-word;
    line-height: 1.2;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity 0.3s ease, max-height 0.3s ease, margin-top 0.3s ease;
}

.test-inference.show {
    opacity: 1;
    max-height: 60px;
    margin-top: 6px;
    color: #2e7d32;
    font-weight: 500;
}

.test-tab.active .test-inference.show {
    color: #a5d6a7;
}

.test-tab.completed .test-status::before {
    content: "✓";
    color: #28a745;
}

.test-tab.active.completed .test-status::before {
    color: white;
}

.inference-instruction {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    padding: 12px;
    margin: 15px 0;
}

.inference-instruction h4 {
    color: #2e7d32;
    margin-bottom: 8px;
}

.inference-instruction .inference-text {
    color: #1b5e20;
    font-weight: 500;
    margin: 0;
}

/* Test Panel */
.test-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.test-panel.active {
    display: flex;
}

.test-panel-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

.test-panel-container {
    position: relative;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1001;
}

.test-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: relative;
    z-index: 1002;
}

.test-panel-header h3 {
    font-size: 1.5em;
}

.close-panel {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2em;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
}

.close-panel:hover {
    background: rgba(255, 255, 255, 0.3);
}

.test-panel-content {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
    position: relative;
    z-index: 1002;
}

/* Home Screen */
.home-screen {
    position: fixed;
    top: 70px; /* Space for fixed header */
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-page);
    display: flex;
    align-items: flex-start; /* Changed from center to allow scrolling */
    justify-content: center;
    z-index: 2000;
    padding-top: 20px; /* Additional padding */
    overflow-y: auto; /* Allow scrolling on mobile */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    padding: 20px 0; /* Add padding for scrolling */
}

.home-content {
    background: linear-gradient(145deg, #ffffff, #dce6ff);
    border: 3px solid var(--accent);
    padding: 50px;
    border-radius: 12px;
    box-shadow: 4px 4px 0px var(--accent-dark);
    max-width: 800px;
    width: 90%;
    text-align: center;
    margin: 20px auto; /* Add margin for scrolling */
    min-height: fit-content; /* Don't force full height */
    overflow-y: visible; /* Allow content to scroll */
}

.brand-header {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 3px solid var(--accent);
}

.brand-logo {
    font-size: 4em;
    margin-bottom: 15px;
    animation: float 3s ease-in-out infinite;
    image-rendering: pixelated;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.home-content h1 {
    color: var(--accent-dark);
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand-tagline {
    color: var(--muted);
    font-size: 1em;
    margin-top: 5px;
    font-weight: 400;
}

.brand-name {
    color: var(--accent);
    font-weight: 600;
    font-size: 1.1em;
}

/* Mode Switch Button - Pixel Art Style */
.btn-mode-switch {
    padding: 10px 20px;
    background: var(--accent);
    border: 2px solid var(--accent-dark);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px var(--accent-dark);
}

.btn-mode-switch:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px var(--accent-dark);
}

.btn-mode-switch:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--accent-dark);
}

.btn-mode-switch:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px var(--accent-dark);
}

.btn-mode-switch:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--accent-dark);
}

.subtitle {
    color: var(--muted);
    font-size: 1.1em;
    margin-bottom: 40px;
    line-height: 1.6;
    font-weight: 400;
}

.level-selection h2 {
    color: var(--accent-dark);
    margin-bottom: 15px;
    font-size: 1.8em;
    font-weight: 600;
}

.level-description {
    color: var(--muted);
    margin-bottom: 30px;
    line-height: 1.7;
    font-size: 1.05em;
}

.level-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    grid-auto-flow: row;
    gap: 20px;
    margin-top: 30px;
    min-height: 100px; /* Ensure grid has height */
}

.level-button {
    background: linear-gradient(145deg, #ffffff, #dce6ff);
    border: 3px solid var(--accent);
    color: var(--accent-dark);
    padding: 30px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 3px 3px 0px var(--accent-dark);
    position: relative;
    overflow: hidden;
}

.level-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.level-button:hover::before {
    left: 100%;
}

.level-button:hover {
    transform: translateY(-2px);
    box-shadow: 4px 4px 0px var(--accent-dark);
    background: var(--accent-light);
}

.level-button:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--accent-dark);
}

.level-button-number {
    font-size: 3em;
    font-weight: bold;
    margin-bottom: 10px;
}

.level-button-name {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 5px;
}

.level-button-desc {
    font-size: 0.9em;
    opacity: 0.9;
}

.level-button.level-completed {
    background: linear-gradient(145deg, #e8f5e9, #c8e6c9);
    border-color: #4CAF50;
    position: relative;
}

.level-completed-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #4CAF50;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    box-shadow: 2px 2px 0px #388E3C;
    display: flex;
    align-items: center;
    gap: 4px;
}

.level-completed-badge::before {
    content: '✓';
    font-size: 1em;
}

.test-instruction {
    margin-bottom: 20px;
}

.test-instruction h4 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.test-instruction p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.observation-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
}

.observation-section h4 {
    color: #333;
    margin-bottom: 15px;
}

.observation-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.observation-option {
    padding: 12px 20px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.observation-value {
    font-weight: 600;
    color: #333;
}

.observation-inference {
    font-size: 0.9em;
    color: #666;
    font-style: italic;
    text-align: right;
    flex: 1;
}

.observation-option:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.observation-option.selected {
    border-color: #667eea;
    background: #e0e8ff;
}

.observation-option.selected .observation-value {
    color: #667eea;
    font-weight: 700;
}

.observation-option.selected .observation-inference {
    color: #667eea;
    font-weight: 500;
}

.level-hint {
    margin-top: 10px;
    padding: 10px;
    background: #f0f4ff;
    border-radius: 5px;
    color: #667eea;
    font-size: 0.9em;
}

.inference-result {
    margin-top: 20px;
    padding: 15px;
    background: #d4edda;
    border-left: 4px solid #28a745;
    border-radius: 4px;
    display: none;
}

.inference-result.show {
    display: block;
}

.inference-result h5 {
    color: #155724;
    margin-bottom: 8px;
}

.inference-result p {
    color: #155724;
    margin: 0;
}

/* Draggable items on workbench */
.workbench-item {
    position: absolute;
    padding: 0;
    background-color: transparent;
    background-image: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    cursor: grab;
    z-index: 10;
    transition: transform 0.2s ease, filter 0.2s ease;
    user-select: none;
    touch-action: pan-y; /* Allow vertical scrolling, prevent horizontal drag */
    will-change: auto;
    backface-visibility: hidden;
    transform: translateZ(0);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    pointer-events: auto;
}

/* Sprite-based items - display the sprite directly */
.workbench-item.sprite-item {
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    /* Ensure sprite stays within bounds */
    overflow: visible; /* Allow label to extend beyond */
    /* Ensure only one background image */
    background-attachment: scroll;
    /* Fixed height based on sprite only - label is absolutely positioned */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative; /* For absolute positioning of label */
}

/* Sprite visual container */
.workbench-item.sprite-item .sprite-visual {
    flex-shrink: 0;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    pointer-events: none; /* Allow clicks to pass through to parent */
}

/* Label under sprite items - positioned absolutely so it doesn't affect item sizing */
.sprite-label {
    position: absolute;
    top: 100%; /* Position below the sprite */
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    font-size: 0.7em;
    pointer-events: none; /* Allow clicks to pass through to parent */
    text-align: center;
    color: #333;
    max-width: 200px; /* Increased to allow longer names without affecting item size */
    word-wrap: break-word;
    line-height: 1.2;
    font-weight: 500;
    white-space: normal;
    z-index: 1;
}

/* Glass rod specific - ensure it fits properly */
.workbench-item.glass-rod-item {
    overflow: visible !important; /* Allow label to extend beyond - labels are absolutely positioned */
}

/* Ensure sprite items don't have any pseudo-elements that could duplicate */
.workbench-item.sprite-item::before,
.workbench-item.sprite-item::after {
    display: none !important;
    content: none !important;
}

/* Hover effect for all sprite items (including test tube) - same as watch glass */
.workbench-item.sprite-item:hover,
.workbench-item.test-tube-item:hover {
    filter: brightness(1.15) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transform: translateZ(0) scale(1.08);
    /* Don't override background-image - let it stay from inline style */
    background-color: transparent;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    box-shadow: none;
}

/* Test tube specific styling */
.workbench-item.test-tube-item {
    padding: 0; /* Remove padding so height is exactly the visual size */
    background: transparent;
    border: none;
    width: 64px;
    height: 128px; /* Fixed height - just the tube visual, label is absolutely positioned */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative; /* For absolute positioning of label */
    overflow: visible; /* Allow label to extend beyond */
}

.test-tube-visual {
    position: relative;
    width: 64px;
    height: 128px;
    background-image: url('assets/test-tube.png');
    background-size: contain;
    pointer-events: none; /* Allow clicks to pass through to parent */
    background-repeat: no-repeat;
    background-position: center;
    z-index: 2; /* Test tube image on top */
}

/* Liquid fill area - fills the transparent bottom of test tube */
/* Original image: 16px × 32px */
/* Original transparent area: 7px wide, 31px height */
/* Displayed size: 80px × 160px (scale factor = 5x) */
/* Scaled dimensions: width = 35px (7 × 5), height = 155px (31 × 5) */
.test-tube-visual::before {
    content: '';
    position: absolute;
    bottom: 2px; /* Raise slightly to not cover bottom border */
    left: 49%;
    transform: translateX(-50%);
    width: 15px;  /* 7px × 5 = 35px */
    height: 0;
    background-color: transparent;
    border-radius: 0;
    transition: height 0.3s ease, background-color 0.3s ease;
    z-index: -1; /* Behind the test tube image */
}

/* Liquid colors for different states */
/* Scaled height: 31px × 5 = 155px (full fill) */
.test-tube-item[data-liquid="water"] .test-tube-visual::before {
    height: 72px;
    background-color: #87CEEB; /* Sky blue for water */
}

.test-tube-item[data-liquid="salt-solution"] .test-tube-visual::before {
    height: 72px;
    background-color: #E0F7FA; /* Light blue for salt solution */
}

.test-tube-item[data-liquid="hno3-solution"] .test-tube-visual::before {
    height: 72px;
    background-color: #FFB74D; /* Orange for HNO3 */
}

.test-tube-item[data-liquid="cobalt-solution"] .test-tube-visual::before {
    height: 72px;
    background-color: #E91E63; /* Pink for cobalt */
}

.test-tube-item[data-liquid="ash-mixture"] .test-tube-visual::before {
    height: 72px;
    background-color: #9C27B0; /* Purple for ash mixture */
}

.test-tube-item[data-liquid="yellow-solution"] .test-tube-visual::before {
    height: 50px; /* Reduced height - yellow solution should be less visible */
    background-color: #FFF9C4; /* Light yellow for phosphate test solution */
}

.test-tube-item[data-liquid="salt"] .test-tube-visual::before {
    height: 72px;
    background-color: #F5F5DC; /* Beige for salt crystals */
}

/* Insoluble salt - blue water with white particles at bottom */
.test-tube-item[data-liquid="insoluble-salt"] .test-tube-visual::before {
    height: 72px;
    background-color: #87CEEB; /* Blue water fills the tube */
}

/* Add white particle dots at the bottom for insoluble salt - second layer on z-index */
.test-tube-item[data-liquid="insoluble-salt"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #FFFFFF;
    border-radius: 50%;
    box-shadow: 
        -6px 0 0 #FFFFFF,
        6px 0 0 #FFFFFF,
        -3px -4px 0 #FFFFFF,
        3px -4px 0 #FFFFFF,
        -9px -2px 0 rgba(255, 255, 255, 0.8),
        9px -2px 0 rgba(255, 255, 255, 0.8),
        -6px -6px 0 rgba(255, 255, 255, 0.7),
        6px -6px 0 rgba(255, 255, 255, 0.7),
        0 -8px 0 rgba(255, 255, 255, 0.6),
        -12px -4px 0 rgba(255, 255, 255, 0.5),
        12px -4px 0 rgba(255, 255, 255, 0.5);
    z-index: 3; /* Above the liquid layer */
}

/* Effervescence effect - bubbling animation */
.test-tube-item[data-effect="effervescence"] .test-tube-visual {
    position: relative;
    overflow: visible;
}

/* Create animated bubbles using pseudo-element with box-shadow for multiple bubbles */
.test-tube-item[data-effect="effervescence"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 
        -10px 25px 0 rgba(255, 255, 255, 0.8),
        10px 30px 0 rgba(255, 255, 255, 0.7),
        -15px 45px 0 rgba(255, 255, 255, 0.6),
        15px 50px 0 rgba(255, 255, 255, 0.5),
        -8px 65px 0 rgba(255, 255, 255, 0.4),
        8px 70px 0 rgba(255, 255, 255, 0.3);
    animation: bubble-rise 2s ease-in-out infinite;
    z-index: 3;
}

/* Shake effect for the liquid */
.test-tube-item[data-effect="effervescence"] .test-tube-visual::before {
    animation: bubble-shake 0.3s ease-in-out infinite;
}

@keyframes bubble-rise {
    0% {
        bottom: 10px;
        opacity: 0.9;
        transform: translateX(-50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
    100% {
        bottom: 150px;
        opacity: 0;
        transform: translateX(-50%) scale(0.4);
    }
}

@keyframes bubble-shake {
    0%, 100% {
        transform: translateX(-50%);
    }
    25% {
        transform: translateX(-51%);
    }
    75% {
        transform: translateX(-49%);
    }
}

/* Precipitate effect - white solid at bottom */
.test-tube-item[data-effect="precipitate"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 20px;
    background: linear-gradient(to top, #FFFFFF 0%, #F5F5F5 100%);
    border-radius: 0 0 6px 6px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: precipitate-form 0.8s ease-out;
}

.test-tube-item[data-effect="precipitate-brown"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 20px;
    background: linear-gradient(to top, #8B4513 0%, #654321 100%);
    border-radius: 0 0 6px 6px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: precipitate-form 0.8s ease-out;
}

.test-tube-item[data-effect="precipitate-black"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 20px;
    background: linear-gradient(to top, #000000 0%, #1a1a1a 100%);
    border-radius: 0 0 6px 6px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: precipitate-form 0.8s ease-out;
}

.test-tube-item[data-effect="solution-blue"] .test-tube-visual::before {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 60px;
    background: linear-gradient(to top, #0000FF 0%, #4169E1 50%, #87CEEB 100%);
    border-radius: 0 0 6px 6px;
    z-index: 1;
    opacity: 0.8;
}

.test-tube-item[data-effect="solution-red"] .test-tube-visual::before {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 60px;
    background: linear-gradient(to top, #DC143C 0%, #FF6347 50%, #FFB6C1 100%);
    border-radius: 0 0 6px 6px;
    z-index: 1;
    opacity: 0.8;
}

@keyframes precipitate-form {
    0% {
        height: 0;
        opacity: 0;
    }
    100% {
        height: 20px;
        opacity: 1;
    }
}

/* Pour effect - liquid transfer animation */
.test-tube-item[data-effect="pour-effect"] {
    position: relative;
    overflow: visible;
}

.test-tube-item[data-effect="pour-effect"] .test-tube-visual {
    position: relative;
    overflow: visible;
}

.test-tube-item[data-effect="pour-effect"] .test-tube-visual::after {
    content: '';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 30px;
    background: linear-gradient(to bottom, 
        rgba(135, 206, 235, 0.9) 0%, 
        rgba(135, 206, 235, 0.6) 50%, 
        rgba(135, 206, 235, 0.3) 100%);
    border-radius: 4px;
    z-index: 10;
    animation: pour-liquid 1s ease-out;
    box-shadow: 0 2px 4px rgba(135, 206, 235, 0.4);
    pointer-events: none;
}

@keyframes pour-liquid {
    0% {
        top: -50px;
        opacity: 0;
        transform: translateX(-50%) scaleY(0);
    }
    30% {
        opacity: 1;
        transform: translateX(-50%) scaleY(1);
    }
    70% {
        opacity: 0.8;
        transform: translateX(-50%) scaleY(1);
    }
    100% {
        top: -10px;
        opacity: 0;
        transform: translateX(-50%) scaleY(0.3);
    }
}

/* Blood red coloration effect for acetate test */
.test-tube-item[data-effect="blood-red"] .test-tube-visual::before {
    background: linear-gradient(to top, #DC143C 0%, #8B0000 50%, #DC143C 100%);
    animation: blood-red-form 0.8s ease-out;
}

@keyframes blood-red-form {
    0% {
        opacity: 0;
        filter: brightness(0.5);
    }
    50% {
        filter: brightness(1.2);
    }
    100% {
        opacity: 1;
        filter: brightness(1);
    }
}

/* Halide test visual effects - White Fumes */
.test-tube-item[data-effect="white-fumes"] .test-tube-visual {
    position: relative;
    overflow: visible;
}

.test-tube-item[data-effect="white-fumes"] .test-tube-visual::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 40px;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.7) 50%, rgba(255, 255, 255, 0.3) 100%);
    border-radius: 50% 50% 0 0;
    z-index: 3;
    animation: white-fumes-rise 2s ease-in-out infinite;
    box-shadow: 
        0 -10px 20px rgba(255, 255, 255, 0.8),
        0 -20px 30px rgba(255, 255, 255, 0.6),
        0 -30px 40px rgba(255, 255, 255, 0.4);
}

@keyframes white-fumes-rise {
    0% {
        top: -20px;
        opacity: 0.9;
        transform: translateX(-50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
    100% {
        top: -60px;
        opacity: 0;
        transform: translateX(-50%) scale(0.6);
    }
}

/* Halide test visual effects - Brown Vapours */
.test-tube-item[data-effect="brown-vapours"] .test-tube-visual {
    position: relative;
    overflow: visible;
}

.test-tube-item[data-effect="brown-vapours"] .test-tube-visual::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 35px;
    height: 45px;
    background: linear-gradient(to top, rgba(139, 69, 19, 0.9) 0%, rgba(139, 69, 19, 0.6) 50%, rgba(139, 69, 19, 0.3) 100%);
    border-radius: 50% 50% 0 0;
    z-index: 3;
    animation: brown-vapours-rise 2.5s ease-in-out infinite;
    box-shadow: 
        0 -10px 20px rgba(139, 69, 19, 0.7),
        0 -20px 30px rgba(139, 69, 19, 0.5),
        0 -30px 40px rgba(139, 69, 19, 0.3);
}

@keyframes brown-vapours-rise {
    0% {
        top: -20px;
        opacity: 0.9;
        transform: translateX(-50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
    100% {
        top: -65px;
        opacity: 0;
        transform: translateX(-50%) scale(0.6);
    }
}

/* Halide test visual effects - Violet Vapours */
.test-tube-item[data-effect="violet-vapours"] .test-tube-visual {
    position: relative;
    overflow: visible;
}

.test-tube-item[data-effect="violet-vapours"] .test-tube-visual::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 35px;
    height: 45px;
    background: linear-gradient(to top, rgba(138, 43, 226, 0.9) 0%, rgba(138, 43, 226, 0.6) 50%, rgba(138, 43, 226, 0.3) 100%);
    border-radius: 50% 50% 0 0;
    z-index: 3;
    animation: violet-vapours-rise 2.5s ease-in-out infinite;
    box-shadow: 
        0 -10px 20px rgba(138, 43, 226, 0.7),
        0 -20px 30px rgba(138, 43, 226, 0.5),
        0 -30px 40px rgba(138, 43, 226, 0.3);
}

@keyframes violet-vapours-rise {
    0% {
        top: -20px;
        opacity: 0.9;
        transform: translateX(-50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
    100% {
        top: -65px;
        opacity: 0;
        transform: translateX(-50%) scale(0.6);
    }
}

/* Brown ring effect for nitrate confirmatory test */
.test-tube-item[data-effect="brown-ring"] .test-tube-visual {
    position: relative;
    overflow: visible;
}

/* Bottom layer - salt solution with ferrous sulphate (light blue/green) */
.test-tube-item[data-effect="brown-ring"] .test-tube-visual::before {
    height: 50px; /* Bottom half - salt solution */
    background: linear-gradient(to top, 
        #E0F7FA 0%, 
        #B2DFDB 50%, 
        #E0F7FA 100%); /* Light blue-green for salt solution + FeSO4 */
    bottom: 2px;
}

/* Brown ring at the junction - using ::after */
.test-tube-item[data-effect="brown-ring"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 50px; /* At the junction between solutions */
    left: 50%;
    transform: translateX(-50%);
    width: 20px; /* Slightly wider than tube to show ring clearly */
    height: 5px; /* Ring thickness */
    background: linear-gradient(to right, 
        rgba(139, 69, 19, 0.4) 0%, 
        rgba(139, 69, 19, 0.95) 15%, 
        rgba(139, 69, 19, 1) 30%,
        rgba(139, 69, 19, 1) 70%,
        rgba(139, 69, 19, 0.95) 85%, 
        rgba(139, 69, 19, 0.4) 100%);
    border-radius: 3px;
    z-index: 4;
    box-shadow: 
        0 0 6px rgba(139, 69, 19, 0.9),
        0 0 12px rgba(139, 69, 19, 0.6),
        inset 0 1px 2px rgba(101, 67, 33, 0.8);
    animation: brown-ring-form 1.2s ease-out;
    border: 1px solid rgba(101, 67, 33, 0.9);
}

@keyframes brown-ring-form {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
        filter: brightness(0.5);
    }
    50% {
        filter: brightness(1.3);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
        filter: brightness(1);
    }
}

/* Paper ball + Reddish brown vapours effect for nitrate test */
.test-tube-item[data-effect="paper-ball-vapours"] .test-tube-visual {
    position: relative;
    overflow: visible;
}

/* Paper ball at the bottom */
.test-tube-item[data-effect="paper-ball-vapours"] .test-tube-visual::before {
    /* Keep the liquid fill */
    height: 72px;
    background-color: #E0F7FA; /* Light blue for salt solution */
}

/* Paper ball image at the bottom */
.test-tube-item[data-effect="paper-ball-vapours"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background-image: url('assets/paper-ball.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 4;
    animation: paper-ball-appear 0.5s ease-out;
}

@keyframes paper-ball-appear {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(10px) scale(0.5);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* Reddish brown vapours rising from the top */
.test-tube-item[data-effect="paper-ball-vapours"] {
    position: relative;
}

.test-tube-item[data-effect="paper-ball-vapours"]::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 35px;
    height: 45px;
    background: linear-gradient(to top, rgba(139, 0, 0, 0.9) 0%, rgba(139, 0, 0, 0.6) 50%, rgba(139, 0, 0, 0.3) 100%);
    border-radius: 50% 50% 0 0;
    z-index: 5;
    animation: reddish-brown-vapours-rise 2.5s ease-in-out infinite;
    box-shadow: 
        0 -10px 20px rgba(139, 0, 0, 0.7),
        0 -20px 30px rgba(139, 0, 0, 0.5),
        0 -30px 40px rgba(139, 0, 0, 0.3);
    pointer-events: none;
}

@keyframes reddish-brown-vapours-rise {
    0% {
        top: -20px;
        opacity: 0.9;
        transform: translateX(-50%) scale(0.8);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.1);
    }
    100% {
        top: -65px;
        opacity: 0;
        transform: translateX(-50%) scale(0.4);
    }
}

/* Paper ball only (no vapours) - for when nitrate is absent */
.test-tube-item[data-effect="paper-ball-only"] .test-tube-visual {
    position: relative;
    overflow: visible;
}

.test-tube-item[data-effect="paper-ball-only"] .test-tube-visual::before {
    height: 72px;
    background-color: #E0F7FA; /* Light blue for salt solution */
}

.test-tube-item[data-effect="paper-ball-only"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    background-image: url('assets/paper-ball.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    z-index: 4;
    animation: paper-ball-appear 0.5s ease-out;
}

/* Halide test visual effects - White Precipitate */
.test-tube-item[data-effect="precipitate-white"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 20px;
    background: linear-gradient(to top, #FFFFFF 0%, #F5F5F5 100%);
    border-radius: 0 0 6px 6px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: precipitate-form 0.8s ease-out;
}

/* Halide test visual effects - Yellow Precipitate */
.test-tube-item[data-effect="precipitate-yellow"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 20px;
    background: linear-gradient(to top, #FFD700 0%, #FFA500 100%);
    border-radius: 0 0 6px 6px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: precipitate-form 0.8s ease-out;
}

/* Halide test visual effects - Deep Yellow Precipitate */
.test-tube-item[data-effect="precipitate-deep-yellow"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 20px;
    background: linear-gradient(to top, #FFA500 0%, #FF8C00 100%);
    border-radius: 0 0 6px 6px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: precipitate-form 0.8s ease-out;
}

/* Blue floating precipitate effect for aluminum confirmatory test */
.test-tube-item[data-effect="precipitate-blue-floating"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 30px; /* Floating above the bottom */
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 16px;
    background: linear-gradient(to top, #0000FF 0%, #4169E1 50%, #87CEEB 100%);
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 100, 0.4);
    animation: blue-precipitate-float 2s ease-in-out infinite;
}

@keyframes blue-precipitate-float {
    0%, 100% {
        transform: translateX(-50%) translateY(0px);
        opacity: 0.9;
    }
    50% {
        transform: translateX(-50%) translateY(-5px);
        opacity: 1;
    }
}

/* Iron confirmatory test - Blue precipitate on top */
.test-tube-item[data-effect="precipitate-blue-top"] .test-tube-visual::after {
    content: '';
    position: absolute;
    top: 50px; /* Lowered from top - in upper portion of tube */
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 20px;
    background: linear-gradient(to bottom, #0000FF 0%, #4169E1 50%, #87CEEB 100%);
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 255, 0.4);
    animation: precipitate-form 0.8s ease-out;
}

/* Iron confirmatory test - Red precipitate on bottom */
.test-tube-item[data-effect="precipitate-red-bottom"] .test-tube-visual::before {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 20px;
    background: linear-gradient(to top, #DC143C 0%, #FF6347 50%, #FFB6C1 100%);
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(220, 20, 60, 0.4);
    animation: precipitate-form 0.8s ease-out;
}

/* Nickel confirmatory test - Bright red precipitate at bottom */
.test-tube-item[data-effect="precipitate-red"] .test-tube-visual::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 20px;
    background: linear-gradient(to top, #FF0000 0%, #FF3333 50%, #FF6666 100%);
    border-radius: 0 0 6px 6px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(255, 0, 0, 0.4);
    animation: precipitate-form 0.8s ease-out;
}

/* Iron confirmatory test - Blue on top and red on bottom */
.test-tube-item[data-effect="precipitate-blue-top-red-bottom"] .test-tube-visual::after {
    content: '';
    position: absolute;
    top: 50px; /* Blue precipitate lowered - in upper portion of tube */
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 20px;
    background: linear-gradient(to bottom, #0000FF 0%, #4169E1 50%, #87CEEB 100%);
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 255, 0.4);
    animation: precipitate-form 0.8s ease-out;
}

.test-tube-item[data-effect="precipitate-blue-top-red-bottom"] .test-tube-visual::before {
    content: '';
    position: absolute;
    bottom: 2px; /* Red precipitate on bottom */
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 20px;
    background: linear-gradient(to top, #DC143C 0%, #FF6347 50%, #FFB6C1 100%);
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(220, 20, 60, 0.4);
    animation: precipitate-form 0.8s ease-out;
}

/* Test tube label - absolutely positioned so it doesn't affect item sizing */
.test-tube-label {
    position: absolute;
    top: 100%; /* Position below the tube */
    left: 50%;
    transform: translateX(-50%);
    margin-top: 4px;
    font-size: 0.7em;
    text-align: center;
    color: #333;
    max-width: 200px; /* Increased to allow longer names without affecting item size */
    pointer-events: none; /* Allow clicks to pass through to parent */
    word-wrap: break-word;
    line-height: 1.2;
    font-weight: 500;
    white-space: normal;
    z-index: 1;
}

/* General hover only for non-sprite items */
.workbench-item:not(.sprite-item):not(.test-tube-item):hover {
    background: #f8f9fa;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.workbench-item:active,
.workbench-item.dragging {
    cursor: grabbing;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    z-index: 10001 !important; /* Higher than overlay (10000) */
    opacity: 1 !important; /* Fully visible when dragging */
}

.workbench-item.nearby:not(.sprite-item) {
    border: 3px solid #28a745;
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
}

.workbench-item.sprite-item.nearby {
    filter: drop-shadow(0 0 12px rgba(40, 167, 69, 0.9)) brightness(1.15);
    transform: translateZ(0) scale(1.1);
    background: transparent !important;
}

.remove-item {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    z-index: 20;
}

.remove-item:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* Test notification */
.test-notification {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 200;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification-content {
    padding: 20px;
}

.notification-content h4 {
    color: #667eea;
    margin-bottom: 10px;
}

.notification-content p {
    color: #666;
    margin-bottom: 15px;
}

.notification-content button {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
}

.notification-content button:hover {
    background: #764ba2;
}

/* Workbench feedback */
.workbench-feedback {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(102, 126, 234, 0.9);
    color: white;
    padding: 15px 30px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 10000;
    display: none;
    animation: fadeInOut 2s ease;
    pointer-events: none;
}

/* Inference notification */
.inference-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    pointer-events: auto;
    min-width: 350px;
    max-width: 500px;
    display: none;
    animation: slideInRight 0.3s ease;
    border-left: 5px solid #667eea;
}

.inference-notification.correct-inference {
    border-left-color: #28a745;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.inference-notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.inference-notification.correct-inference .inference-notification-header {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.inference-notification-header h4 {
    margin: 0;
    font-size: 1.1em;
}

.correct-badge {
    background: rgba(255, 255, 255, 0.3);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 600;
}

.inference-notification-content {
    padding: 20px;
    color: #333;
    line-height: 1.6;
}

.inference-notification-content p {
    margin: 0;
    font-size: 1em;
}

.close-inference {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5em;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-inference:hover {
    background: rgba(255, 255, 255, 0.3);
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* Reaction animations */
@keyframes reactionPop {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

@keyframes reactionMessage {
    0% {
        transform: translateY(-20px);
        opacity: 0;
    }
    5%, 95% {
        transform: translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateY(-20px);
        opacity: 0;
    }
}

/* Salt visual sample for color test */
.salt-visual-sample {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.salt-display {
    width: 200px;
    height: 200px;
    margin: 20px auto;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.salt-crystals {
    width: 80%;
    height: 80%;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.3) 0px,
        rgba(255, 255, 255, 0.3) 10px,
        transparent 10px,
        transparent 20px
    );
    border-radius: 5px;
}

.salt-hint {
    position: absolute;
    bottom: -30px;
    color: #666;
    font-size: 0.9em;
    text-align: center;
    width: 100%;
}

.reaction-item {
    animation: reactionPop 0.5s ease;
}

.reaction-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #667eea;
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 600;
    z-index: 10000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none;
    white-space: nowrap;
    pointer-events: none;
}

.reaction-effect {
    position: fixed;
    width: 100px;
    height: 100px;
    border: 4px solid;
    border-radius: 50%;
    pointer-events: none;
    z-index: 300;
    transform: translate(-50%, -50%);
    animation: reactionPulse 1s ease-out;
}

@keyframes reactionPulse {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(3);
        opacity: 0;
    }
}

/* Test progress bar */
.test-progress-bar {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.progress-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
    border-radius: 10px;
}

.inference-notice {
    background: #d4edda;
    border-left: 4px solid #28a745;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.inference-notice h4 {
    color: #155724;
    margin-bottom: 8px;
}

.inference-notice p {
    color: #155724;
    margin: 0;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
}

/* Level complete modal */
.level-complete-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-content.correct-answer {
    border-top: 5px solid #28a745;
}

.modal-content.wrong-answer {
    border-top: 5px solid #dc3545;
}

.error-message {
    color: #dc3545;
    font-weight: 600;
    margin: 15px 0;
}

.consequence-message {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    border-radius: 5px;
    color: #856404;
    margin: 20px 0;
    text-align: left;
}

.btn-retry {
    background: #ffc107;
    color: #333;
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.btn-retry:hover {
    background: #ffb300;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 193, 7, 0.4);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

.salt-name {
    font-size: 1.5em;
    font-weight: bold;
    color: #28a745;
    margin: 20px 0;
    padding: 15px;
    background: #d4edda;
    border-radius: 10px;
    border-left: 4px solid #28a745;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.btn-next, .btn-close {
    padding: 10px 24px;
    border: 2px solid var(--accent-dark);
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.2s ease;
    box-shadow: 2px 2px 0px var(--accent-dark);
}

.btn-next {
    background: var(--accent);
    color: white;
}

.btn-next:hover {
    background: var(--accent-dark);
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px var(--accent-dark);
    color: white;
}

.btn-next:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--accent-dark);
}

.btn-close {
    background: white;
    color: var(--accent-dark);
}

.btn-close:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 4px 4px 0px var(--accent-dark);
    color: var(--accent-dark);
}

.btn-close:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px var(--accent-dark);
}

/* Bunsen Burner Styles */
.bunsen-burner {
    position: absolute;
    bottom: 40px; /* Bottom left position for PC */
    left: 40px;
    transform: none;
    width: 80px;
    height: 120px;
    z-index: 100;
    transform-style: preserve-3d;
}

.burner-visual {
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 120px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    opacity: 1;
    transition: opacity 0.5s ease;
}

/* Off state - static image */
.bunsen-burner:not(.on):not(.turning-off) .burner-visual {
    background-image: url('assets/bunsen-burner-off.png');
    opacity: 1 !important;
}

/* On state - animated GIF that plays forward then stops at last frame */
.bunsen-burner.on .burner-visual {
    opacity: 1 !important;
}

/* Turning off state - fade out the GIF */
.bunsen-burner.turning-off .burner-visual {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.burner-toggle {
    position: absolute;
    bottom: -30px; /* Slightly higher button position */
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 14px; /* Slightly larger for easier clicking */
    background: #667eea;
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8em; /* Slightly larger text */
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 101;
    min-width: 80px; /* Ensure button has minimum width for easier clicking */
}

.burner-toggle:hover {
    background: #5568d3;
    transform: translateX(-50%) scale(1.05);
}

.bunsen-burner.on .burner-toggle {
    background: #FF5722;
}

.bunsen-burner.on .burner-toggle:hover {
    background: #E64A19;
}

/* Items on burner get special styling */
.workbench-item.on-burner {
    border-color: #FF6B00 !important;
    box-shadow: 0 0 15px rgba(255, 107, 0, 0.5) !important;
    animation: warmingGlow 1s ease infinite alternate;
}

@keyframes warmingGlow {
    0% {
        box-shadow: 0 0 15px rgba(255, 107, 0, 0.5);
    }
    100% {
        box-shadow: 0 0 25px rgba(255, 107, 0, 0.8);
    }
}

/* Disposal Section Styles */
.disposal-section {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 192px;
    height: 192px;
    z-index: 100;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.disposal-section:hover {
    transform: scale(1.1);
}

.disposal-container {
    width: 100%;
    height: 100%;
    background-image: url('assets/sink.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    position: relative;
    overflow: visible;
}

.disposal-section:hover .disposal-container {
    filter: brightness(1.1);
}

/* Shake animation for test tube (removed but keeping keyframe for compatibility) */
@keyframes shake {
    0%, 100% {
        transform: translateX(0) rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px) rotate(-5deg);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px) rotate(5deg);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 150px 1fr 150px;
    }
}

/* Desktop only (> 1024px) - restore original behavior */
@media (min-width: 1025px) {
    .tools-sidebar,
    .chemical-rack {
        /* Desktop: flexible height, scrollable - original behavior */
        height: auto;
        min-height: auto;
        max-height: none;
    }
    
    .workbench {
        /* Desktop: normal flow - original behavior */
        flex: none;
    }
    
    .container {
        align-items: stretch; /* Original desktop behavior */
    }
    
    /* Restore original tool/chemical item sizes on desktop */
    .tool-item {
        padding: 12px; /* Match chemicals */
        gap: 10px; /* Match chemicals */
    }
    
    .chemical-item {
        padding: 12px; /* Original size */
    }
    
    .tool-icon {
        width: 32px; /* Original size */
        height: 32px;
    }
    
    .chemical-icon {
        width: 32px; /* Original size */
        height: 32px;
    }
}

/* Mobile/Phone and Tablet/iPad Responsive Styles - Stacked layout */
@media (max-width: 1024px) {
    body {
        font-size: 14px;
    }

    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: calc(100vh - 60px);
        padding: 10px;
        gap: 10px;
    }
    
    /* Hide sidebars from grid layout on mobile - they're now fixed overlays */
    .tools-sidebar,
    .chemical-rack {
        display: block !important;
    }

    /* Sidebars - Slide-in panels on mobile/tablet */
    .tools-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 1000;
        background: rgba(240, 240, 245, 0.98) !important; /* Darker background to differentiate items */
        overflow-y: scroll; /* Always show scrollbar for dragging */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding: 10px 8px; /* Reduced horizontal padding for more scroll room */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
        transition: transform 0.3s ease;
        transform: translateX(-100%);
        order: 2;
        /* Don't clip dragged items */
        clip-path: none;
        clip: auto;
        contain: layout style paint;
    }
    
    .chemical-rack {
        position: fixed;
        top: 0;
        bottom: 0;
        right: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        max-height: 100vh;
        z-index: 1000;
        background: rgba(240, 240, 245, 0.98) !important; /* Darker background to differentiate items */
        overflow-y: scroll; /* Always show scrollbar for dragging */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding: 10px 8px; /* Reduced horizontal padding for more scroll room */
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
        transition: transform 0.3s ease;
        transform: translateX(100%);
        order: 2;
        /* Don't clip dragged items */
        clip-path: none;
        clip: auto;
        contain: layout style paint;
    }
    
    /* Show sidebar when active */
    .tools-sidebar.active {
        transform: translateX(0);
    }
    
    .chemical-rack.active {
        transform: translateX(0);
    }
    
    /* Force scrollbar to always be visible and draggable */
    .tools-sidebar,
    .chemical-rack {
        overflow-y: scroll !important; /* Force scrollbar to always show */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        /* Force scrollbar visibility on WebKit browsers */
        scrollbar-gutter: stable; /* Reserve space for scrollbar */
    }
    
    /* Thick, always-visible, draggable scrollbar for sidebars on phone */
    .tools-sidebar::-webkit-scrollbar,
    .chemical-rack::-webkit-scrollbar {
        width: 20px !important; /* Thick enough to grab easily */
        -webkit-appearance: none; /* Remove default styling */
        display: block !important; /* Always show scrollbar */
        background: #f1f1f1; /* Track background */
    }
    
    .tools-sidebar::-webkit-scrollbar-track,
    .chemical-rack::-webkit-scrollbar-track {
        background: #f1f1f1 !important;
        border-radius: 10px;
        margin: 5px 0; /* Add some margin for better visibility */
        -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.1);
        display: block !important; /* Always show track */
    }
    
    .tools-sidebar::-webkit-scrollbar-thumb,
    .chemical-rack::-webkit-scrollbar-thumb {
        background: #667eea !important;
        border-radius: 10px;
        border: 3px solid #f1f1f1; /* Thicker border for better grip */
        min-height: 40px !important; /* Minimum thumb height for easier grabbing */
        -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.2);
        cursor: pointer !important; /* Show pointer cursor */
        -webkit-user-select: none; /* Prevent text selection */
        user-select: none;
        display: block !important; /* Always show thumb */
    }
    
    .tools-sidebar::-webkit-scrollbar-thumb:active,
    .chemical-rack::-webkit-scrollbar-thumb:active {
        background: #5568d3 !important;
        cursor: grabbing !important; /* Show grabbing cursor when dragging */
    }
    
    .tools-sidebar::-webkit-scrollbar-thumb:hover,
    .chemical-rack::-webkit-scrollbar-thumb:hover {
        background: #764ba2 !important;
    }
    
    /* Firefox scrollbar - always visible and draggable */
    .tools-sidebar,
    .chemical-rack {
        scrollbar-width: auto !important; /* Thick scrollbar */
        scrollbar-color: #667eea #f1f1f1 !important;
    }
    
    /* Ensure scrollbar is draggable on all browsers */
    .tools-sidebar,
    .chemical-rack {
        /* Enable native scrollbar dragging */
        touch-action: pan-y;
        /* Make scrollbar interactive */
        pointer-events: auto;
        /* Force scrollbar to always reserve space */
        scrollbar-gutter: stable;
    }
    
    /* iOS Safari specific - force scrollbar visibility */
    @supports (-webkit-touch-callout: none) {
        .tools-sidebar,
        .chemical-rack {
            /* Force scrollbar to always show on iOS */
            -webkit-overflow-scrolling: touch;
            /* Add padding to ensure scrollbar area is always visible */
            padding-right: 25px; /* Extra space for scrollbar */
        }
        
        .tools-sidebar.active,
        .chemical-rack.active {
            /* When active, ensure scrollbar is visible */
            overflow-y: scroll !important;
        }
    }
    
    /* Increase chemicals list length on phone - add more padding at bottom */
    .chemicals-list {
        padding-bottom: 100px; /* Extra space for scrolling */
        padding-right: 30px; /* Space between items and scrollbar to avoid accidental clicks */
    }
    
    /* Add padding to tools list to avoid clicking items when scrolling */
    .tools-list {
        padding-right: 30px; /* Space between items and scrollbar to avoid accidental clicks */
    }
    
    /* Overlay when sidebar is open */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 10000; /* High but below dragging items */
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: all;
    }

    .workbench {
        order: 1;
        flex: 1; /* Grow to fill remaining space */
        min-height: 400px;
        padding: 15px;
    }

    .workbench-surface {
        min-height: 400px;
    }

    /* Header controls - horizontal on mobile */
    .header-controls {
        grid-column: 1;
        padding: 10px 15px;
        gap: 10px;
    }


    /* Tools - slimmer on mobile */
    .tool-item {
        padding: 6px 4px; /* Reduced horizontal padding */
        gap: 4px; /* Smaller gap */
        min-height: 40px; /* Slightly smaller but still touchable */
        margin: 0 2px; /* Narrower margins */
        transition: all 0.3s ease;
    }
    
    /* Pop-out effect when dragging */
    .tool-item:active,
    .tool-item.dragging {
        transform: scale(1.15) translateZ(20px);
        z-index: 999999 !important; /* Highest possible z-index - no restrictions */
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
        background: #e9ecef;
        position: fixed !important; /* Fixed on mobile to escape sidebar clipping */
        pointer-events: none !important; /* Prevent interference with other elements */
        clip-path: none !important;
        clip: auto !important;
        overflow: visible !important;
        contain: none !important;
        max-width: none !important;
        max-height: none !important;
    }
    
    /* Chemicals - slimmer on mobile */
    .chemical-item {
        padding: 8px 5px; /* Reduced horizontal padding */
        gap: 5px;
        min-height: 44px;
        margin: 0 3px; /* Narrower margins */
        transition: all 0.3s ease;
    }
    
    /* Pop-out effect when dragging */
    .chemical-item:active,
    .chemical-item.dragging {
        transform: scale(1.15) translateZ(20px);
        z-index: 999999 !important; /* Highest possible z-index - no restrictions */
        position: fixed !important; /* Fixed on mobile to escape sidebar clipping */
        clip-path: none !important;
        clip: auto !important;
        overflow: visible !important;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
        background: #e9ecef;
        pointer-events: none !important; /* Prevent interference with other elements */
        contain: none !important;
        max-width: none !important;
        max-height: none !important;
    }

    .tool-icon {
        width: 18px; /* Smaller icons for tools */
        height: 18px;
        flex-shrink: 0;
    }
    
    .chemical-icon {
        width: 20px; /* Keep chemical icons as they were */
        height: 20px;
        flex-shrink: 0;
    }

    .tool-item span {
        font-size: 0.75em; /* Smaller text for tools */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .chemical-item span {
        font-size: 0.8em; /* Keep chemical text as it was */
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Reduce gap between items for more compact list */
    .tools-list {
        gap: 6px; /* Smaller gap for tools */
    }
    
    .chemicals-list {
        gap: 8px; /* Keep chemicals gap */
    }

    .tools-sidebar h2,
    .rack-header h2 {
        font-size: 1em;
        margin-bottom: 10px;
    }

    /* Test checklist - full screen on mobile */
    .test-checklist {
        height: 85vh;
        padding: 15px;
    }

    .checklist-header {
        margin-bottom: 10px;
    }

    .checklist-header h2 {
        font-size: 1.1em;
    }

    .checklist-close {
        width: 35px;
        height: 35px;
        font-size: 1.5em;
    }

    .test-tabs {
        gap: 8px;
        padding-bottom: 8px;
    }

    .test-tab {
        padding: 10px 12px;
        min-width: 90px;
    }

    .test-number {
        font-size: 1.2em;
    }

    .test-name {
        font-size: 0.75em;
    }

    /* Salt selector - stack vertically */
    .salt-selector {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .salt-selector label {
        font-size: 0.9em;
    }

    .salt-select {
        width: 100%;
        min-width: auto;
        padding: 10px;
        font-size: 0.9em;
    }

    .btn-identify {
        width: 100%;
        padding: 12px 20px;
        font-size: 1em;
    }

    /* Test panel - full screen on mobile */
    .test-panel-container {
        width: 95%;
        max-width: none;
        max-height: 90vh;
        border-radius: 15px 15px 0 0;
    }

    .test-panel-header {
        padding: 15px;
    }

    .test-panel-header h3 {
        font-size: 1.2em;
    }

    .test-panel-content {
        padding: 20px;
    }

    .test-instruction h4 {
        font-size: 1em;
    }

    .test-instruction p {
        font-size: 0.9em;
    }

    /* Observation options - full width */
    .observation-option {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .observation-value {
        font-size: 0.95em;
    }

    .observation-inference {
        font-size: 0.85em;
        text-align: left;
        width: 100%;
    }

    /* Home screen */
    .home-content {
        padding: 30px 20px;
        width: 95%;
        margin: 10px auto; /* Ensure margin for scrolling */
    }
    
    .home-screen {
        padding: 10px 0; /* Less padding on mobile */
        align-items: flex-start; /* Start from top for better scrolling */
    }

    .home-content h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1em;
    }

    .level-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .level-button {
        padding: 20px 15px;
    }

    .level-button-number {
        font-size: 2em;
    }

    .level-button-name {
        font-size: 1em;
    }

    .level-button-desc {
        font-size: 0.8em;
    }

    /* Notifications - adjust for mobile */
    .inference-notification {
        min-width: 90%;
        max-width: 90%;
        right: 5%;
        top: 60px;
    }

    .inference-notification-header {
        padding: 12px 15px;
    }

    .inference-notification-header h4 {
        font-size: 1em;
    }

    .inference-notification-content {
        padding: 15px;
        font-size: 0.9em;
    }

    .workbench-feedback {
        top: 60px;
        padding: 12px 20px;
        font-size: 0.9em;
        max-width: 90%;
        left: 5%;
        transform: translateX(0);
    }

    .reaction-message {
        padding: 10px 20px;
        font-size: 0.9em;
        max-width: 90%;
        white-space: normal;
        text-align: center;
    }

    /* Test tube - smaller on mobile */
    .workbench-item.test-tube-item {
        min-width: 60px;
        max-width: 72px;
        width: 60px;
        height: 120px;
    }

    .test-tube-visual {
        width: 60px;
        height: 120px;
    }

    .test-tube-label {
        font-size: 0.6em;
        max-width: 72px;
    }

    /* Bunsen burner - adjust position */
    .bunsen-burner {
        top: 25%; /* Higher position on tablet */
        bottom: auto;
        left: 20px;
        transform: none;
        width: 60px;
        height: 90px;
    }

    .burner-visual {
        width: 60px;
        height: 90px;
    }

    .burner-toggle {
        font-size: 0.7em;
        padding: 6px 10px;
        min-width: 70px;
    }

    /* Disposal section - adjust position */
    .disposal-section {
        top: 15px;
        right: 15px;
        width: 144px;
        height: 144px;
    }

    /* Modal */
    .modal-content {
        padding: 25px 20px;
        width: 90%;
    }

    .modal-content h2 {
        font-size: 1.5em;
    }

    .salt-name {
        font-size: 1.2em;
        padding: 12px;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .btn-next,
    .btn-close,
    .btn-retry {
        width: 100%;
        padding: 12px 20px;
    }

    /* Category titles */
    .category-title {
        font-size: 1em;
    }

    /* Progress text */
    .test-progress {
        font-size: 0.85em;
    }

    .toggle-text {
        font-size: 0.95em;
    }

    .toggle-progress {
        font-size: 0.8em;
        padding: 3px 10px;
    }

    /* Checklist toggle bar */
    .checklist-toggle {
        padding: 12px 15px;
        min-height: 50px; /* Better touch target */
    }

    /* Improve button touch targets */
    .btn-home,
    .btn-identify,
    .checklist-close,
    .close-panel {
        min-height: 44px;
        min-width: 44px;
    }

    /* Improve test tab touch targets */
    .test-tab {
        min-height: 60px;
    }

    /* Improve observation option touch targets */
    .observation-option {
        min-height: 50px;
    }
}

/* Extra small phones */
@media (max-width: 480px) {
    body {
        font-size: 13px;
    }

    .container {
        padding: 8px;
        gap: 8px;
    }

    .tools-sidebar,
    .chemical-rack {
        height: 250px; /* Fixed height - still bigger */
        min-height: 250px;
        max-height: 250px;
        padding: 10px 8px;
        flex-shrink: 0;
    }
    
    .workbench {
        flex: 1; /* Grow to fill remaining space */
        min-height: 350px;
    }
    
    /* Even more compact on very small phones */
    .tool-item {
        padding: 5px 6px; /* Even slimmer for tools */
        gap: 4px;
        margin: 0 2px;
        min-height: 38px;
    }
    
    .chemical-item {
        padding: 6px 8px; /* Keep chemicals slightly bigger */
        gap: 5px;
        margin: 0 3px;
    }

    .tool-icon {
        width: 16px; /* Smaller icons for tools */
        height: 16px;
    }
    
    .chemical-icon {
        width: 18px; /* Keep chemical icons */
        height: 18px;
    }

    .tool-item span,
    .chemical-item span {
        font-size: 0.75em;
    }
    
    .tools-list,
    .chemicals-list {
        gap: 6px;
    }

    .workbench {
        padding: 10px;
    }

    .test-checklist {
        height: 90vh;
        padding: 12px;
    }

    .level-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        max-height: calc(100vh - 250px); /* Make it taller on mobile - covers most of screen */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 10px;
        margin-top: 20px;
    }
    
    .home-content {
        padding: 30px 20px;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    
    .home-screen {
        padding: 10px 0;
    }
    
    /* Make workbench table taller on small phones */
    .container.show {
        height: calc(100vh - 50px);
        min-height: calc(100vh - 50px);
        margin-top: 50px;
        padding: 8px;
        padding-bottom: 40px;
    }
    
    .workbench {
        min-height: calc(100vh - 150px);
        height: calc(100vh - 150px);
        padding: 10px;
    }
    
    .workbench-content {
        padding: 30px 10px;
        min-height: 100%;
    }

    .test-tab {
        padding: 8px 10px;
        min-width: 80px;
    }

    .test-number {
        font-size: 1em;
    }

    .test-name {
        font-size: 0.7em;
    }

    .home-content h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .test-panel-container {
        width: 100%;
        border-radius: 0;
        max-height: 100vh;
    }

    .inference-notification {
        min-width: 95%;
        max-width: 95%;
        right: 2.5%;
    }

    .workbench-item.test-tube-item {
        min-width: 50px;
        max-width: 60px;
        width: 50px;
        height: 100px;
    }

    .test-tube-visual {
        width: 50px;
        height: 100px;
    }

    .bunsen-burner {
        top: auto;
        bottom: 25px; /* Raised just a tiny bit from original 15px */
        left: 15px;
        transform: none;
        width: 50px;
        height: 75px;
    }
    
    .burner-toggle {
        padding: 6px 10px;
        font-size: 0.7em;
        min-width: 70px;
    }

    .burner-visual {
        width: 50px;
        height: 75px;
    }

    .disposal-section {
        top: 10px;
        right: 10px;
        width: 120px;
        height: 120px;
    }
}

/* Landscape orientation - keep stacked layout for phones and tablets */
@media (max-width: 1024px) and (orientation: landscape) {
    /* Keep the same stacked layout, just adjust heights */
    .container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr auto;
    }

    .tools-sidebar,
    .chemical-rack {
        height: 250px; /* Fixed height in landscape */
        min-height: 250px;
        max-height: 250px;
        flex-shrink: 0;
    }

    .workbench {
        flex: 1; /* Grow to fill remaining space */
        min-height: 300px;
    }

    .test-checklist {
        height: 75vh;
    }

    .test-panel-container {
        max-height: 85vh;
    }
}

/* Prevent zoom on input focus (iOS Safari) */
@media (max-width: 1024px) {
    input,
    select,
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    /* Make workbench table taller on mobile */
    .container.show {
        height: calc(100vh - 60px);
        min-height: calc(100vh - 60px);
        margin-top: 60px;
        padding: 10px;
        padding-bottom: 50px;
    }
    
    .workbench {
        min-height: calc(100vh - 200px);
        height: calc(100vh - 200px);
        padding: 15px;
    }
    
    .workbench-surface {
        min-height: 100%;
        height: 100%;
    }
    
    .workbench-content {
        min-height: 100%;
        height: 100%;
        padding: 40px 15px;
    }
}

/* Notification System */
.notification-container {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.notification {
    background: white;
    border: 2px solid var(--accent-dark);
    border-radius: 4px;
    padding: 14px 18px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 4px 4px 0px var(--accent-dark);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
    font-weight: 600;
    font-size: 0.95em;
}

.notification.success {
    border-color: #388E3C;
    box-shadow: 4px 4px 0px #388E3C;
    background: #E8F5E9;
    color: #2E7D32;
}

.notification.error {
    border-color: #d32f2f;
    box-shadow: 4px 4px 0px #d32f2f;
    background: #FFEBEE;
    color: #C62828;
}

.notification.info {
    border-color: #1976D2;
    box-shadow: 4px 4px 0px #1976D2;
    background: #E3F2FD;
    color: #1565C0;
}

.notification-icon {
    font-size: 1.3em;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
    line-height: 1.4;
}

.notification-close {
    background: transparent;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s ease;
    font-weight: bold;
}

.notification-close:hover {
    opacity: 1;
}

.notification-close:active {
    transform: scale(0.9);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.notification.hiding {
    animation: slideOutRight 0.3s ease-out forwards;
}

@media (max-width: 768px) {
    .notification-container {
        top: 80px;
        right: 10px;
        left: 10px;
    }
    
    .notification {
        min-width: auto;
        max-width: 100%;
    }
}

