/* General Styles */
body {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    background-color: #1e1e1e;
    color: #f0f0f0;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: 1200px;
}

header h1 {
    text-align: center;
    color: #65b16a;
    font-size: 2.5em;
    margin-bottom: 20px;
    font-weight: 700;
}

main {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

#simulation-wrapper {
    flex-grow: 1;
    border: 2px solid #444;
    border-radius: 10px;
    padding: 10px;
    background-color: #2c2c2c;
}

#simulation-box {
    width: 100%;
    height: 500px;
    position: relative;
    overflow: hidden;
    background-image: radial-gradient(#3a3a3a 1px, transparent 1px);
    background-size: 20px 20px;
}

#controls {
    width: 300px;
    flex-shrink: 0;
    background-color: #2c2c2c;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #444;
}

h2 {
    color: #608BC1;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    margin-top: 0;
    font-weight: 400;
}

/* Atom & Control Buttons */
.atom-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.add-atom, .action-buttons button {
    padding: 10px;
    font-size: 1em;
    font-weight: 700;
    border-radius: 5px;
    border: 1px solid #555;
    background-color: #3e3e3e;
    color: #f0f0f0;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

.add-atom:hover, .action-buttons button:hover {
    background-color: #555;
}

.add-atom:active, .action-buttons button:active {
    transform: scale(0.95);
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

#combine {
    background-color: #60a564;
    color: #F8FAFC;
}

#combine:hover {
    background-color: #6eab72;
}

#reset {
    background-color: #555;
    color: #f0f0f0;
}

#reset:hover {
    background-color: #666;
}

/* Result Display */
#result {
    background-color: #1e1e1e;
    border: 1px dashed #444;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
    min-height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Atom Styles in Simulation */
.atom {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2em;
    font-weight: bold;
    color: white;
    position: absolute;
    cursor: grab;
    user-select: none;
    border: 2px solid rgba(255, 255, 255, 0.7);
}
.atom:active { cursor: grabbing; }
.H { background-color: #E0E0E0; color: #333; }
.C { background-color: #4B4B4B; }
.N { background-color: #3050F8; }
.O { background-color: #f44747; }
.F { background-color: #90E050; }
.Na { background-color: #AB5CF2; }
.Mg { background-color: #b8ff67; }
.Al { background-color: #BFA6A6; }
.Si { background-color: #F0C8A0; }
.P { background-color: #FF8000; }
.S { background-color: #FFFF30; color: #333; }
.Cl { background-color: #81dd81; }
.K { background-color: #8F40D4; }
.Ca { background-color: #5effc7; }
.Li { background-color: #CC80FF; }
.Be { background-color: #a3cb1e; }
.B { background-color: #FFB5B5; }
.Cu { background-color: #B87333; }


/* Collection Section */
#collection-section {
    background-color: #2c2c2c;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #444;
}

#collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
}

.collection-card {
    background-color: #3e3e3e;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.collection-card.discovered {
    cursor: pointer;
}

.collection-card.discovered:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.collection-card .formula {
    font-size: 1.5em;
    font-weight: 700;
    margin-bottom: 5px;
}

.collection-card .name {
    font-size: 0.9em;
    color: #ccc;
}

.collection-card.locked {
    background-color: #333;
    color: #777;
}

/* Modal styles */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #2c2c2c;
    margin: auto;
    padding: 30px;
    border: 1px solid #555;
    width: 80%;
    max-width: 500px;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    color: #f0f0f0;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 32px;
    font-weight: bold;
    transition: color 0.3s;
}

.close-button:hover,
.close-button:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

#modal-title {
    margin-top: 0;
    color: #608BC1;
    font-size: 24px;
    border-bottom: 2px solid #608BC1;
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-weight: 400;
}

#modal-usage {
    font-size: 16px;
    line-height: 1.6;
}

/* Responsive Styles */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    main {
        flex-direction: column;
    }

    #controls {
        width: 100%;
        box-sizing: border-box;
    }

    #simulation-box {
        height: 300px;
    }

    header h1 {
        font-size: 2em;
    }

    .atom {
        width: 40px;
        height: 40px;
        font-size: 1em;
    }
}
