body {
    background-color: #1a1a1a;
    color: #ffffff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100%;
    width: 100%;
}

.sidebar {
    width: 300px;
    background-color: #252525;
    padding: 20px;
    overflow-y: auto;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    flex-shrink: 0;
}

.sidebar:first-child { border-right: 1px solid #444; }

.sidebar.right-sidebar {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.sidebar-scroll-area {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
}

.sidebar-fixed-area {
    flex-shrink: 0;
    background-color: #1f1f1f;
    border-top: 2px solid #444;
    padding: 20px;
    z-index: 10;
    box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
}

.sidebar h2 {
    margin-top: 0;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
    color: #eee;
    font-size: 1.2em;
}

.preset-btn {
    width: 100%;
    background-color: #333;
    border: 1px solid #444;
    color: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background-color: #4CAF50;
    border-color: #4CAF50;
    transform: translateX(5px);
}

.preset-btn strong {
    display: block;
    font-size: 16px;
    margin-bottom: 5px;
}

.preset-btn span {
    font-size: 12px;
    color: #aaa;
    font-style: italic;
}

.preset-btn:hover span { color: #eee; }

.rule-box {
    margin-bottom: 20px;
    background: #333;
    padding: 10px;
    border-radius: 8px;
}

.rule-box p { margin: 5px 0; font-size: 13px; }
.rule-box .desc { color: #bbb; font-style: italic; font-size: 12px; margin-bottom: 10px; }

.example {
    display: flex; align-items: center; justify-content: center; gap: 10px;
}

.mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 12px);
    grid-template-rows: repeat(3, 12px);
    gap: 1px;
    background-color: #555;
    padding: 1px;
}

.mini-grid div { width: 12px; height: 12px; background-color: #1a1a1a; }
.mini-grid div.alive { background-color: #ffee00; }
.mini-grid div.born { background-color: #ffee00; box-shadow: 0 0 5px #ffee00; }
.mini-grid div.dead { background-color: #444; }
.arrow { font-size: 16px; color: #888; }

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #1a1a1a;
    padding: 10px;
}

.controls {
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: #252525;
    padding: 10px 20px;
    border-radius: 30px;
    border: 1px solid #444;
    width: fit-content; 
}

.controls button {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    background-color: transparent;
    color: #ccc;
    border: 1px solid #555;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.controls button:hover {
    background-color: #444;
    border-color: #777;
    color: white;
    transform: translateY(-1px);
}

.controls button:nth-child(2):hover {
    border-color: #4CAF50;
    color: #4CAF50;
}

.controls button:first-child:hover {
    border-color: #FFC107;
    color: #FFC107;
}

.controls button.stop:hover {
    background-color: rgba(244, 67, 54, 0.1);
    border-color: #f44336;
    color: #f44336;
}

.controls button.clear:hover {
    border-color: #2196F3;
    color: #2196F3;
}

p.info { font-size: 0.9em; color: #aaa; margin-top: 10px; }

.speed-controls {
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: #252525;
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid #444;
}

.speed-controls span {
    margin-right: 5px;
    font-size: 14px;
    color: #aaa;
    font-weight: bold;
}

.speed-btn {
    padding: 5px 10px;
    font-size: 12px;
    background-color: transparent;
    border: 1px solid #555;
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.speed-btn:hover {
    background-color: #444;
    border-color: #777;
}

.speed-btn.active {
    background-color: #4CAF50;
    color: white;
    border-color: #4CAF50;
    font-weight: bold;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

.save-btn {
    width: 100%;
    background-color: transparent;
    border: 1px solid #555;
    color: #ccc;
    margin-bottom: 0;
    text-align: center;
    padding: 10px;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.save-btn:hover {
    background-color: #444;
    border-color: #777;
    color: white;
    transform: translateY(-1px);
}

.save-btn strong { display: inline-block; margin-right: 5px; } 

#userPresetList {
    margin-top: 10px;
    border-top: 1px dashed #444;
    padding-top: 10px;
}

.user-preset-wrapper {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.user-preset-wrapper .preset-btn {
    margin-bottom: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex-grow: 1;
}

.user-preset-wrapper .del-btn {
    width: 40px;
    background-color: #2c2c2c;
    border: 1px solid #444;
    border-left: none;
    color: #f44336;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
    font-weight: bold;
}
.user-preset-wrapper .del-btn:hover {
    background-color: #f44336;
    color: white;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-box {
    background: #252525;
    padding: 20px;
    border-radius: 10px;
    width: 300px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border: 1px solid #444;
    text-align: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-box h3 { margin-top: 0; color: #fff; }

.modal-input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    background: #333;
    border: 1px solid #555;
    color: white;
    border-radius: 5px;
    box-sizing: border-box;
}

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

.btn-confirm { background-color: #4CAF50; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; }
.btn-cancel { background-color: #f44336; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; }

.toast-notification {
    visibility: hidden;
    min-width: 250px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 5px;
    padding: 16px;
    position: fixed;
    z-index: 1001;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border: 1px solid #444;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s;
}

.toast-notification.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

@keyframes fadeIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }

.sidebar-scroll-area::-webkit-scrollbar { width: 8px; }
.sidebar-scroll-area::-webkit-scrollbar-track { background: #252525; }
.sidebar-scroll-area::-webkit-scrollbar-thumb {
    background-color: #444;
    border-radius: 10px;
    border: 2px solid #252525;
}
.sidebar-scroll-area::-webkit-scrollbar-thumb:hover { background-color: #666; }