* {
    box-sizing: border-box;
}

body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    padding: 24px;
    background-color: #b8bec6;
    background-image: radial-gradient(
        circle,
        rgba(34, 34, 34, 0.15) 1px,
        transparent 1.5px
    );
    background-size: 24px 24px;
    color: #222;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    line-height: 1.5;
}

h1 {
    margin: 0 0 24px;
    font-size: 24px;
    font-weight: normal;
}

.buttons {
    display: grid;
    gap: 14px;
}

button {
    width: 100%;
    font: inherit;
    font-size: 16px;
    color: inherit;
    padding: 12px 18px;
    border: 1px solid rgba(34, 34, 34, 0.3);
    border-radius: 6px;
    background: #c7f0ff;
    cursor: pointer;
}

button:hover {
    background: #ffd0d0;
}

button:focus-visible {
    outline: 2px solid #246a8c;
    outline-offset: 3px;
}

.home-page {
    display: block;
    place-items: normal;
    padding: 32px 24px;
}

.catalog-page {
    width: 100%;
    max-width: 1402px;
    margin: 0 auto;
}

.catalog-navigation {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 24px;
    margin-bottom: 24px;
}

.catalog-navigation a,
.site-footer a {
    color: inherit;
    text-underline-offset: 4px;
}

.games-section {
    width: 100%;
    padding: 32px 24px;
    background: #fff7aa;
    scroll-margin-top: 24px;
}

.games-section + .games-section {
    border-top: 1px solid rgba(34, 34, 34, 0.2);
}

.name-title {
    text-align: center;
    font-size: 75px;
    font-weight: 700;
    font-style: bold;
    color: #00edfa;
    text-shadow:
        0 0 6px rgba(0, 237, 250, 0.8),
        0 0 18px rgba(0, 237, 250, 0.55),
        0 0 36px rgba(0, 237, 250, 0.35);
}

.games-content {
    max-width: calc(4 * 320px + 3 * 24px);
    margin: 0 auto;
}

.games-content > h2 {
    margin: 0 0 24px;
    font-size: 24px;
    font-weight: normal;
    text-align: center;
    overflow-wrap: anywhere;
}

.games-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
}

.game-panel {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    justify-content: space-between;
    gap: 32px;
    width: 320px;
    max-width: 100%;
    min-width: 0;
    min-height: 320px;
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    background-color: #222;
    background-size: cover;
    background-position: center;
    text-align: center;
}

.game-panel-contain {
    background-color: #000;
    background-size: contain;
    background-repeat: no-repeat;
}

.game-title {
    margin: 0;
    color: #fff;
    font-size: 26px;
    line-height: 1.25;
    font-weight: 700;
    overflow-wrap: anywhere;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
}

.game-action,
.dialog-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 12px 18px;
    border: 1px solid rgba(34, 34, 34, 0.3);
    border-radius: 6px;
    background: #c7f0ff;
    color: #222;
    font: inherit;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.game-action img {
    flex-shrink: 0;
}

.game-action:hover,
.dialog-option:hover {
    background: #ffd0d0;
}

.game-action:focus-visible,
.dialog-option:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

.game-action:disabled,
.game-action[aria-disabled="true"] {
    background: #dce1e5;
    color: #5d6267;
    cursor: not-allowed;
}

.tool-panel {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    gap: 16px;
    width: 320px;
    max-width: 100%;
    min-width: 0;
    padding: 16px;
    border: 1px solid #fff;
    border-radius: 8px;
    background: #f5f7f8;
}

.tool-title {
    margin: 0;
    font-size: 20px;
    line-height: 1.3;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.tool-image {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: #222;
}

.tool-description {
    margin: 0;
    color: #444b53;
    font-size: 15px;
    overflow-wrap: anywhere;
}

.tool-github {
    margin-top: auto;
}

.tool-github:focus-visible {
    outline-color: #246a8c;
}

.catalog-retry {
    width: auto;
    margin-bottom: 24px;
}

.game-dialog {
    width: 360px;
    max-width: calc(100% - 32px);
    max-height: calc(100svh - 32px);
    padding: 24px;
    border: 1px solid #fff;
    border-radius: 8px;
    background: #f5f7f8;
    color: #222;
}

.game-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.dialog-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
}

.dialog-header h2 {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.dialog-close {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 24px;
    line-height: 1;
}

.dialog-option:focus-visible {
    outline-color: #246a8c;
}

#play-dialog [hidden] {
    display: none;
}

.game-dialog.is-reading {
    width: 640px;
    padding: 0;
    overflow: hidden;
}

.game-dialog.is-reading[open] {
    display: flex;
    flex-direction: column;
}

.is-reading .dialog-header {
    flex-shrink: 0;
    margin: 0;
    padding: 24px;
    border-bottom: 1px solid #dce4e8;
    background: #e9f7fb;
}

.instructions-text {
    min-height: 0;
    padding: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: 16px;
    line-height: 1.8;
}

.instructions-text:focus-visible {
    outline: 2px solid #246a8c;
    outline-offset: -4px;
}

@media (max-width: 420px) {
    .home-page {
        padding: 24px 16px;
    }

    .games-section {
        padding: 24px 16px;
    }

    .game-panel {
        padding: 24px;
    }
}

.site-footer {
    padding: 24px 0;
    color: #444b53;
    font-size: 14px;
    text-align: center;
}

.site-footer p {
    margin: 0;
}
