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

body {
    background: #111;
    overflow: hidden;
    font-family: monospace;
    font-size: 16px;
}

canvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    cursor: crosshair;
    z-index: 0;
}

dialog {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    margin: 0;
    padding: 16px;
    gap: 8px;
    display: flex;
    align-items: flex-start;
    pointer-events: none;
    background: transparent;
    border: none;
    z-index: 1;
    overflow: visible;
    max-width: none;
    max-height: none;
    flex-wrap: wrap;
    justify-content: flex-end;
}

dialog > * {
    pointer-events: auto;
}

button {
    background: rgba(0, 0, 0, 0.45);
    color: #eee;
    border: none;
    padding: 0 12px;
    height: 38px;
    border-radius: 5px;
    font-size: 100%;
    font-weight: 500;
    text-transform: none;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
    line-height: 38px;
}

button:hover {
    background: #000;
}

button:focus-visible,
#settings-panel select:focus-visible,
#settings-panel input:focus-visible {
    outline: 1px solid #fff;
    outline-offset: 2px;
}

#settings-controls {
    display: grid;
    gap: 14px 18px;
    margin-top: 14px;
    align-items: start;
}

#settings-controls label {
    display: grid;
    grid-template-columns: 88px max-content;
    align-items: center;
    gap: 10px;
    width: max-content;
    color: #eee;
}

#settings-controls label > span {
    white-space: nowrap;
}

#settings-panel select,
#settings-panel input {
    width: 100%;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 0;
    background-color: rgba(0, 0, 0, 0.42);
    background-image:
        linear-gradient(45deg, transparent 50%, rgba(238, 238, 238, 0.8) 50%),
        linear-gradient(135deg, rgba(238, 238, 238, 0.8) 50%, transparent 50%);
    background-position:
        calc(100% - 14px) calc(50% - 1px),
        calc(100% - 9px) calc(50% - 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
    color: #eee;
    font: inherit;
    line-height: 1.2;
    padding: 6px 26px 6px 8px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    color-scheme: dark;
}

#settings-panel input {
    width: 76px;
    background-image: none;
    padding: 6px 8px;
}

#settings-panel select option {
    background: #171717;
    color: #eee;
}

#settings-panel select:hover,
#settings-panel input:hover {
    background-color: rgba(0, 0, 0, 0.56);
}

#settings-panel select:focus-visible,
#settings-panel input:focus-visible {
    background-color: rgba(0, 0, 0, 0.62);
}

#midi-panel {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    gap: 10px 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    margin-top: 2px;
    padding-top: 12px;
}

#midi-panel[hidden] {
    display: none;
}

#midi-panel > label:first-child {
    grid-column: 1 / -1;
}

#slope,
#sounds {
    width: auto;
    field-sizing: content;
}

#pause,
#reset {
    display: none;
}

#settings-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

#settings-panel {
    position: fixed;
    top: 64px;
    right: 16px;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    border-radius: 5px;
    padding: 14px 18px;
    color: #eee;
    font-size: 100%;
    line-height: 1.8;
    display: none;
    max-width: clamp(200px, calc(100vw - 32px), 420px)
}

#settings-panel.show {
    display: block;
}

#settings-panel p {
    margin-bottom: 8px;
}

#settings-panel > p:last-child {
    margin-top: 20px;
    color: #bbb;
}

@media (max-width: 700px) {
    #settings-controls label {
        width: max-content;
    }

    #midi-panel {
        grid-template-columns: max-content;
    }

    #midi-panel > label:first-child {
        grid-column: auto;
    }

}

#settings-panel a {
    color: #bbb;
}

#settings-panel a:hover {
    color: #eee;
}
