*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', sans-serif
}

body {
    background: radial-gradient(ellipse at 50% 0%, #0d1b2a 0%, #0a0e14 60%);
    color: #e0e0e0
}

#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column
}

/* Header */
#lab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(0, 210, 255, 0.12)
}

#lab-header h1 {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, #00d4ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text
}

.header-right {
    display: flex;
    gap: 8px;
    align-items: center
}

#discovery-count {
    font-size: 12px;
    color: #00d4ff;
    font-family: 'JetBrains Mono', monospace
}

button {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(0, 210, 255, 0.08);
    border: 1px solid rgba(0, 210, 255, 0.2);
    border-radius: 8px;
    color: #00d4ff;
    cursor: pointer;
    font-family: inherit;
    transition: all .2s
}

button:hover {
    background: rgba(0, 210, 255, 0.18);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.12)
}

/* Workspace */
#lab-workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0
}

/* Shelf */
#chemical-shelf {
    width: 210px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.35);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    overflow-y: auto;
    overflow-x: hidden
}

#chemical-shelf::-webkit-scrollbar {
    width: 4px
}

#chemical-shelf::-webkit-scrollbar-thumb {
    background: rgba(0, 210, 255, 0.15);
    border-radius: 4px
}

#shelf-list {
    display: flex;
    flex-direction: column;
    gap: 4px
}

.cat-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 8px 4px 3px;
    color: #556
}

.chem-card {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
    user-select: none
}

.chem-card:hover {
    background: rgba(0, 210, 255, 0.07);
    border-color: rgba(0, 210, 255, 0.2);
    transform: translateX(3px)
}

.chem-card:active {
    transform: scale(0.97)
}

.chem-emoji {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0
}

.chem-info {
    flex: 1;
    min-width: 0
}

.chem-name {
    font-size: 11px;
    font-weight: 600;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.chem-formula {
    font-size: 10px;
    color: #666;
    font-family: 'JetBrains Mono', monospace
}

.chem-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0
}

/* Beaker */
#beaker-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0
}

#beaker-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%
}

#beaker-tags {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    max-width: 280px
}

.content-tag {
    font-size: 9px;
    padding: 2px 7px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    color: #999;
    font-family: 'JetBrains Mono', monospace
}

/* Info Panel */
#info-panel {
    width: 260px;
    padding: 14px;
    background: rgba(0, 0, 0, 0.35);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    overflow-y: auto
}

#info-panel h2 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 10px
}

#info-default p,
.tip {
    font-size: 12px;
    line-height: 1.6;
    color: #888;
    margin-bottom: 8px
}

.tip {
    padding: 8px;
    background: rgba(255, 200, 0, 0.05);
    border: 1px solid rgba(255, 200, 0, 0.12);
    border-radius: 8px;
    color: #c0a040;
    font-size: 11px
}

#rx-badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px
}

#rx-equation {
    padding: 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(0, 210, 255, 0.15);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #00d4ff;
    margin-bottom: 10px;
    word-break: break-word;
    line-height: 1.5
}

#rx-desc {
    font-size: 12px;
    line-height: 1.5;
    color: #999;
    margin-bottom: 10px
}

#rx-fact {
    padding: 8px;
    background: rgba(255, 200, 0, 0.04);
    border: 1px solid rgba(255, 200, 0, 0.12);
    border-radius: 8px;
    font-size: 11px;
    line-height: 1.5;
    color: #c0a040
}

#rx-fact::before {
    content: '💡 ';
    font-weight: 700
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn .2s
}

@keyframes fadeIn {
    from {
        opacity: 0
    }

    to {
        opacity: 1
    }
}

.modal-content {
    width: 90%;
    max-width: 560px;
    max-height: 80vh;
    background: #14181e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    overflow: hidden
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06)
}

.modal-header h2 {
    font-size: 16px
}

.modal-close {
    background: none;
    border: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px
}

#nb-list {
    padding: 12px;
    overflow-y: auto;
    max-height: calc(80vh - 50px);
    display: flex;
    flex-direction: column;
    gap: 6px
}

.nb-entry {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px
}

.nb-entry.found {
    border-color: rgba(0, 210, 255, 0.15)
}

.nb-entry h3 {
    font-size: 13px;
    margin-bottom: 2px
}

.nb-entry .nb-eq {
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    color: #00d4ff
}

.nb-entry.unknown h3 {
    color: #333
}

.nb-entry.unknown .nb-eq {
    color: #222
}

.hidden {
    display: none !important
}

/* Mobile */
@media(max-width:860px) {
    #lab-workspace {
        flex-direction: column
    }

    #chemical-shelf {
        width: 100%;
        max-height: 120px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05)
    }

    #shelf-list {
        flex-direction: row;
        flex-wrap: wrap
    }

    .cat-label {
        padding: 4px 6px 2px
    }

    .chem-card {
        padding: 4px 6px
    }

    #info-panel {
        width: 100%;
        max-height: 180px;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.05)
    }

    .header-right {
        flex-wrap: wrap
    }

    #lab-header h1 {
        font-size: 15px
    }
}