html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    text-align: center;
    background-color: black;
    color: white;
}

/* Canvas fills the window; the page info sits on top of it */
#gameLayer {
    position: fixed;
    inset: 0;
}

canvas {
    display: block;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.github-corner {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1;
}

/* Interface layer: toolbar over the top-left of the canvas */
#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: calc(100% - 90px);
    padding: calc(6px + env(safe-area-inset-top)) 6px 6px calc(6px + env(safe-area-inset-left));
}

#toolbar button {
    min-width: 36px;
    height: 36px;
    padding: 0 0.6em;
    font: 14px sans-serif;
    color: #222;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid #999;
    border-radius: 18px;
    cursor: pointer;
    touch-action: manipulation;
}

#toolbar button[aria-pressed="true"] {
    background: #222;
    color: white;
}

#toolbar #soundToggle,
#toolbar #soundToggle[aria-pressed="true"] {
    background: rgba(255, 255, 255, 0.85);
    color: #222;
}

button:focus-visible {
    outline: 3px solid #4a7bd0;
    outline-offset: 2px;
}

h2, h3 {
    font-family: 'Roboto Slab', serif;
    font-weight: 500;
}

dialog {
    width: min(32rem, calc(100% - 2rem));
    max-height: 85dvh;
    overflow: auto;
    padding: 1rem 1.25rem;
    border: none;
    border-radius: 12px;
    background: white;
    color: #111;
    text-align: left;
    line-height: 1.4;
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
}

dialog h2 {
    margin-top: 0;
    font-size: 2rem;
}

dialog h3 {
    margin-bottom: 0.25em;
}

dialog ul {
    padding-left: 1.25em;
    margin-top: 0.25em;
}

dialog form {
    display: flex;
    justify-content: flex-end;
    gap: 0.5em;
    margin-top: 1em;
}

dialog form button {
    font: inherit;
    padding: 0.4em 1em;
    border: 1px solid #999;
    border-radius: 1em;
    background: #f2f2f2;
    color: #111;
    cursor: pointer;
}

kbd {
    padding: 0 0.3em;
    border: 1px solid #aaa;
    border-radius: 4px;
    background: #f6f6f6;
}

.inline-emoji {
    height: 1.2em;
    vertical-align: -0.25em;
}

#emojiGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
    gap: 6px;
}

#emojiGrid button {
    aspect-ratio: 1;
    font-size: 28px;
    background: #f2f2f2;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
}

#emojiGrid button[aria-pressed="true"] {
    border-color: #222;
}
