body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #1a1a1a;
    color: #f0f0f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 1rem;
    min-height: 100vh;
    box-sizing: border-box;
    text-align: center;
}

h1 {
    color: #ffffff;
    margin-bottom: 0.5rem;
}

p {
    max-width: 600px;
    margin-bottom: 1rem;
    color: #cccccc;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 1.5rem;
}

.controls {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.controls > label {
    font-size: 1rem;
    color: #ccc;
    margin-bottom: -0.5rem;
}

#formulaSelect, #gradientSelect {
    padding: 0.5rem;
    font-size: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #2a2a2a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 5px;
    cursor: pointer;
    min-width: 320px;
    text-align: center;
}

#customFormulaContainer, #customGradientContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 320px;
}

#customFormulaInput, #customGradientInput {
    padding: 0.5rem;
    font-size: 1rem;
    font-family: 'Courier New', Courier, monospace;
    background-color: #2a2a2a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 5px;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
}

#formulaDisplay {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1rem;
    background-color: #2a2a2a;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    border: 1px solid #444;
    min-height: 1.5em;
    color: #f0f0f0;
    min-width: 300px;
    max-width: 90vw;
    text-align: center;
    word-break: break-all;
    margin-bottom: 1rem;
}

#newFractalBtn, #updateViewBtn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: bold;
    color: #ffffff;
    background-color: #007bff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#newFractalBtn {
    order: 2; /* Move button below formula */
}

#newFractalBtn:hover, #updateViewBtn:hover {
    background-color: #0056b3;
}

.navigation-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    margin-top: 1rem;
}

.navigation-controls div {
    display: flex;
    gap: 0.25rem;
}

.nav-btn {
    background-color: #333;
    border: 1px solid #555;
    color: #f0f0f0;
    font-size: 1.2rem;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-btn:hover {
    background-color: #007bff;
}

.view-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    max-width: 450px;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.input-group label {
    font-size: 0.9rem;
    color: #ccc;
}

.input-group input[type="number"] {
    width: 120px;
    padding: 0.5rem;
    font-size: 1rem;
    font-family: 'Courier New', Courier, monospace;
    background-color: #2a2a2a;
    color: #f0f0f0;
    border: 1px solid #444;
    border-radius: 5px;
    box-sizing: border-box;
    text-align: center;
}

/* Hide spin buttons on number inputs for a cleaner look */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

.input-group input[type="range"] {
    width: 150px;
    cursor: pointer;
}

#powerValue {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    color: #007bff;
    margin-left: 0.5rem;
}

canvas {
    border: 2px solid #444;
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.4);
    background-color: #000;
    cursor: grab;
}

canvas:active {
    cursor: grabbing;
}

.loader {
    position: absolute;
    color: white;
    font-size: 1.5rem;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 1rem 2rem;
    border-radius: 8px;
    display: none; /* Initially hidden */
}

.loader.show {
    display: block;
}