/* Box sizing rules */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Remove default margin */
body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
    margin: 0;
}

/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
ul[role="list"],
ol[role="list"] {
    list-style: none;
}

/* Set core root defaults */
html:focus-within {
    scroll-behavior: smooth;
}

html {
    overflow-y: scroll;
}

@supports (scrollbar-gutter: stable) {
    html {
        overflow-y: auto;
        scrollbar-gutter: stable;
    }
}

/* Set core body defaults */
body {
    min-height: 100vh;
    min-height: 100svh;
    text-rendering: optimizeSpeed;
    line-height: 1.5;
}

/* A elements that don't have a class get default styles */
a:not([class]) {
    text-decoration-skip-ink: auto;
}

/* Make images easier to work with */
img,
picture {
    max-width: 100%;
    display: block;
}

/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
    font: inherit;
}

/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
@media (prefers-reduced-motion: reduce) {
    html:focus-within {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
}
#main {
        font-size: 1.5rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 2rem;
        min-height: 100vh;
        min-height: 100svh;

        text-wrap: balance;
    }

    .content {
        font-family: serif;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        flex-grow: 1;
        max-width: 50ch;
    }

    dialog {
        font-family: system-ui, sans-serif;
        font-size: 1rem;
        width: min(24rem, calc(100vw - 4rem));
        height: min(18rem, calc(100vw - 4rem));
        padding: 1rem;
        border: 4px solid currentColor;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    dialog[open] {
        transform: translate(attr(data-offset px), attr(data-offset px));
    }

    dialog:not([open]) {
        display: none;
    }

    dialog::backdrop {
        background: rgb(140 0 0 / 0.5);
    }

    dialog h2:focus {
        outline: none;
    }

    .modal-content {
        overflow: auto;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .modal-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
    }

    button {
        padding: 0.6rem 1rem;
        border: 4px solid currentColor;
        background: transparent;
        color: inherit;
        cursor: pointer;
    }

    button:disabled {
        cursor: not-allowed;
        opacity: 0.7;
    }

    html:has(dialog:modal) {
        overflow: hidden;
    }

    dialog[open].upside-down {
        animation: rotation 6s linear infinite;
        transform-origin: calc(50% + attr(data-offset px))
            calc(50% + attr(data-offset px));
    }

    @media (prefers-reduced-motion: reduce) {
        dialog[open].upside-down {
            animation: none;
        }
    }

    @keyframes rotation {
        to {
            rotate: 360deg;
        }
    }