:root {
    --bg-color: #1e1e24;
    --panel-bg: #2b2b36;
    --text-color: #f5f5f5;
    --accent-blue: #4fa3d1;
    --cation-color: #ff6b6b;
    --anion-color: #4ecdc4;
    --pop-color: #ffd166; 
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: var(--panel-bg);
    border-bottom: 2px solid #333;
}

.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 300px;
    background-color: var(--panel-bg);
    padding: 20px;
    overflow-y: auto;
    border-right: 2px solid #333;
}

.panel {
    background: #363642;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* --- UPGRADED: The glowing yellow style applied to the sidebar box! --- */
.score-display-sidebar {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
    background: #23232a;
    padding: 12px 15px;
    border-radius: 8px;
    border: 2px solid var(--pop-color);
    box-shadow: 0 0 10px rgba(255, 209, 102, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

#score {
    color: var(--pop-color);
    font-size: 1.8rem;
    text-shadow: 0 0 8px rgba(255, 209, 102, 0.4);
}
/* ---------------------------------------------------------------------- */

#collected-list {
    margin: 0;
    padding-left: 20px;
    line-height: 1.6;
}

.ion-bank {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    gap: 15px 12px; 
    justify-content: center; 
    align-content: start; 
    min-height: 115px; 
}

.ion {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.1s ease;
}

.ion:active {
    transform: scale(0.95);
}

.cation { background-color: var(--cation-color); color: white; order: 1; }
.anion { background-color: var(--anion-color); color: #111; order: 2; }

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
    overflow-y: auto; 
}

.status-bar {
    background: #363642;
    padding: 15px 20px; 
    border-radius: 8px;
    margin-bottom: 10px;
    text-align: left; 
    font-size: 1.1rem;
}

.chamber-wrapper {
    position: relative;
    margin-top: 25px; 
}

.charge-badge {
    position: absolute;
    top: -24px;
    left: 20px; 
    background-color: #2a2a35;
    border: 2px solid var(--accent-blue);
    border-radius: 12px;
    padding: 5px 25px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    z-index: 10; 
}

.charge-badge h2 { 
    margin: 0; 
    font-size: 1.1rem; 
    color: #aaa; 
    text-transform: uppercase;
    letter-spacing: 1px;
}

#net-charge {
    color: var(--pop-color);
    font-size: 2.2rem; 
    font-weight: 900;
    text-shadow: 0 0 10px rgba(255, 209, 102, 0.4);
    line-height: 1;
}

.chamber {
    min-height: 150px; 
    border: 2px dashed #666;
    border-radius: 10px;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 15px;
    padding: 35px 20px 20px 20px; 
    background: #23232a;
}

.success-popup {
    display: none; 
    flex-direction: column;
    align-items: flex-start; 
    background-color: #363642;
    padding: 20px 30px; 
    border-radius: 10px;
    margin-top: 20px;
    border: 2px solid var(--anion-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    text-align: left; 
    animation: popIn 0.3s ease-out forwards;
    
    width: 100%; 
    max-width: 600px; 
    box-sizing: border-box; 
}

@keyframes popIn {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.success-popup h2 { margin-top: 0; margin-bottom: 5px; color: var(--anion-color); font-size: 1.5rem; }
.big-formula { font-size: 3rem; color: white; display: block; margin-bottom: 15px; font-weight: bold; }

#naming-section {
    width: 100%;
    margin-top: 5px;
    padding-top: 15px;
    border-top: 1px dashed #555;
}

#built-name-display {
    font-size: 1.8rem;
    color: var(--pop-color);
    margin-bottom: 15px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 209, 102, 0.3);
}

.name-banks {
    display: flex;
    gap: 20px;
    width: 100%;
}

.name-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.name-btn {
    background-color: #4a4a5a;
    color: #fff;
    border: 2px solid transparent;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: all 0.1s;
    text-align: center;
}

.name-btn:hover { background-color: #5a5a6a; }

.name-btn.selected {
    background-color: var(--accent-blue);
    border-color: #fff;
}

#collect-btn {
    background-color: var(--anion-color);
    color: #111;
    border: none;
    padding: 12px 25px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

#collect-btn:active { transform: scale(0.95); }

.toast {
    position: fixed;
    bottom: -60px; 
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--anion-color);
    color: #111;
    padding: 15px 25px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1rem;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.toast.show { bottom: 30px; }

.mastery-modal {
    display: none; 
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.4s;
}

.mastery-content {
    background: #2b2b36;
    padding: 40px;
    border-radius: 15px;
    border: 4px solid var(--pop-color);
    text-align: center;
    max-width: 500px;
    box-shadow: 0 0 30px rgba(255, 209, 102, 0.5);
    animation: popIn 0.5s ease-out;
}

.mastery-content h1 {
    color: var(--pop-color);
    margin-top: 0;
    font-size: 2.2rem;
    text-shadow: 0 0 10px rgba(255, 209, 102, 0.4);
}

.mastery-content p {
    font-size: 1.2rem;
    line-height: 1.5;
    color: var(--text-color);
}

#close-mastery-btn {
    background-color: var(--accent-blue);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

#close-mastery-btn:active { transform: scale(0.95); }

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