* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #f5d67b;
}

.canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
    background: #0d0d1a;
    padding: 10px;
    border-radius: 8px;
    border: 2px solid #333;
    outline: none;
}

#simulation-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #2a2a3a;
}

.fullscreen-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 20px;
    line-height: 32px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    z-index: 10;
}

.fullscreen-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

/* Fullscreen styles */
.canvas-wrapper:fullscreen {
    padding: 0;
    border: none;
    border-radius: 0;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
}

.canvas-wrapper:fullscreen #simulation-canvas {
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
}

.canvas-wrapper:fullscreen .fullscreen-btn {
    top: 20px;
    right: 20px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

button {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-radius: 6px;
    transition: all 0.2s;
}

#play-btn {
    background: #4CAF50;
    color: white;
    min-width: 80px;
}

#play-btn:hover {
    background: #45a049;
}

#reset-btn {
    background: #f44336;
    color: white;
}

#reset-btn:hover {
    background: #d32f2f;
}

button:active {
    transform: scale(0.98);
}

.parameters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 700px) {
    .parameters {
        grid-template-columns: 1fr;
    }
}

fieldset {
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    background: #16213e;
}

legend {
    color: #f5d67b;
    font-weight: 600;
    padding: 0 10px;
}

.param-row {
    display: grid;
    grid-template-columns: 1fr 120px 50px;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.param-row:has(.small-btn) {
    grid-template-columns: 1fr 120px 50px auto;
}

.small-btn {
    padding: 4px 8px;
    font-size: 11px;
    background: #4a5568;
    color: #eee;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.small-btn:hover {
    background: #5a6578;
}

.param-row:last-child {
    margin-bottom: 0;
}

.checkbox-row {
    grid-template-columns: 1fr;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.mode-row {
    grid-template-columns: auto 1fr;
    gap: 10px;
}

.mode-row > label {
    font-size: 14px;
    align-self: center;
}

.toggle-group {
    display: flex;
    background: #0d0d1a;
    border-radius: 6px;
    padding: 3px;
    gap: 3px;
}

.toggle-group input[type="radio"] {
    display: none;
}

.toggle-group label {
    flex: 1;
    text-align: center;
    padding: 6px 12px;
    font-size: 13px;
    color: #888;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.toggle-group label:hover {
    color: #bbb;
    background: rgba(255, 255, 255, 0.05);
}

.toggle-group input[type="radio"]:checked + label {
    background: #2a4a7a;
    color: #f5d67b;
    font-weight: 500;
}

.param-row label {
    font-size: 14px;
}

.param-row input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 3px;
    outline: none;
}

.param-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f5d67b;
    cursor: pointer;
}

.param-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #f5d67b;
    cursor: pointer;
    border: none;
}

.param-row span {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 13px;
    color: #aaa;
    text-align: right;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 15px;
    background: #16213e;
    border-radius: 8px;
    border: 1px solid #444;
}

.stats span {
    font-size: 14px;
}

.stats strong {
    color: #f5d67b;
    font-family: 'Monaco', 'Consolas', monospace;
}

footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: #888;
    font-size: 14px;
    border-top: 1px solid #333;
}

footer a {
    color: #f5d67b;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}
