:root {
    --bg-color: #0f172a;
    --panel-bg: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-hover: #0ea5e9;
    --btn-bg: #334155;
    --btn-hover: #475569;
    --grid-line: #334155;
    --cell-alive: #38bdf8;
    --cell-dead: #0f172a;
    
    --font-family: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
}

header {
    text-align: center;
    padding-bottom: 1rem;
}

header h1 {
    font-weight: 300;
    letter-spacing: 0.1em;
    font-size: 1.5rem;
    color: var(--accent-color);
}

main {
    display: flex;
    flex: 1;
    gap: 1rem;
    overflow: hidden;
}

.canvas-wrapper {
    flex: 1;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--grid-line);
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.controls {
    width: 250px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background-color: var(--panel-bg);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--grid-line);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    background-color: var(--btn-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.btn:hover:not(:disabled) {
    background-color: var(--btn-hover);
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn.primary {
    background-color: var(--accent-color);
    color: #0f172a;
    font-weight: 600;
}

.btn.primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.slider-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: block;
}

input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    height: 4px;
    background: var(--grid-line);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    transition: background .15s ease-in-out;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
}

.stats {
    margin-top: auto;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--grid-line);
    padding-top: 1rem;
}

.stats p {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.stats span {
    color: var(--text-primary);
    font-family: monospace;
}

@media (max-width: 768px) {
    main {
        flex-direction: column;
    }
    
    .controls {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 1rem;
    }

    .control-group {
        flex: 1;
        min-width: 120px;
    }
}
