/* Infer global foundation. Component-level layout stays with its owning stylesheet. */
*,
*::before,
*::after {
    box-sizing: border-box;
    border-radius: 0 !important;
}

html {
    min-width: 320px;
    min-height: 100%;
    background: var(--global-bg);
    color-scheme: light;
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

body {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-width: 320px;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    color: var(--primary-text);
    background: var(--global-bg);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    font-weight: 450;
    line-height: 1.5;
    text-align: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-user-select: none;
    user-select: none;
}

button,
input,
select,
textarea {
    color: inherit;
    font: inherit;
}

button,
select,
input[type="button"],
input[type="submit"],
input[type="color"],
input[type="range"] {
    cursor: pointer;
}

button,
input,
select,
textarea,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--secondary-text);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

a:hover {
    color: var(--button-active-bg);
}

::selection {
    color: var(--color-on-primary);
    background: var(--color-primary);
}

:focus-visible {
    outline: 3px solid var(--button-focus-ring);
    outline-offset: 3px;
}

#content-wrapper {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-self: flex-start;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 100dvh;
    padding:
        max(20px, env(safe-area-inset-top))
        max(20px, env(safe-area-inset-right))
        max(28px, env(safe-area-inset-bottom))
        max(20px, env(safe-area-inset-left));
}

#controls-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 720px;
    gap: var(--space-sm);
}

#grid-wrapper {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-width: 0;
    max-width: 100%;
    padding: clamp(12px, 2.5vw, 28px);
}

#game-area {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
}

@media (max-width: 600px) {
    #content-wrapper {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-inline: max(10px, env(safe-area-inset-left));
    }

    #grid-wrapper {
        padding-inline: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
