.games-modal,
.games-modal *,
.games-modal *::before,
.games-modal *::after {
    box-sizing: border-box;
}

.games-modal[hidden],
.games-modal__play[hidden] {
    display: none !important;
}

.games-modal {
    --games-modal-top-offset: 0px;
    --games-modal-surface: #13171f;
    --games-modal-radius: 8px;
    --games-modal-dialog-width: min(1040px, calc(100vw - 32px));
    position: fixed;
    inset: var(--games-modal-top-offset) 0 0;
    z-index: 100000;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    padding: clamp(6px, 1.25vmin, 16px);
    overscroll-behavior: contain;
}

.games-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(3px);
}

.games-modal__dialog {
    position: relative;
    display: grid;
    grid-template-rows: auto auto auto;
    width: var(--games-modal-dialog-width);
    max-width: 100%;
    height: auto;
    max-height: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--games-modal-radius);
    background: var(--games-modal-surface);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.games-modal__header,
.games-modal__footer {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: clamp(44px, 6dvh, 56px);
    margin: 0;
    padding: clamp(4px, 1dvh, 8px) clamp(8px, 1.25vw, 12px);
    background: var(--games-modal-surface);
}

.games-modal__header {
    justify-content: flex-end;
}

.games-modal__title {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.games-modal__close {
    appearance: none;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 4px;
    border: 0;
    border-radius: 6px;
    color: #fff;
    background: transparent;
    cursor: pointer;
}

.games-modal__close:hover {
    background: rgba(255, 255, 255, 0.08);
}

.games-modal__close:focus-visible,
.games-modal__play:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.92);
    outline-offset: 2px;
}

.games-modal__close path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
}

.games-modal__body {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
    isolation: isolate;
}

.games-modal__body::after {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-items: center;
    background: #000;
    content: "";
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
}

.games-modal.is-loading .games-modal__body::after {
    opacity: 1;
}

.games-modal__frame {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: #000;
    color-scheme: dark;
}

.games-modal__footer {
    justify-content: center;
}

.games-modal__play {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    margin: 0;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #000;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    background: linear-gradient(90deg, #ffc700 0%, #ffea21 100%);
    cursor: pointer;
    transition: 160ms ease;
}

.games-modal__play:hover,
.games-modal__play:focus-visible {
    color: #000;
    text-decoration: none;
    background: linear-gradient(90deg, #ffe669 0%, #ffe669 100%);
}

.games-modal__play-icon {
    flex: 0 0 auto;
    color: #fff;
}

.games-modal__play-icon path {
    fill: #000;
}

html.has-games-modal,
body.has-games-modal {
    overflow: hidden;
    overscroll-behavior: none;
}

@media (max-width: 640px) {
    .games-modal {
        padding: 0;
    }

    .games-modal__dialog {
        grid-template-rows: auto minmax(0, 1fr) auto;
        width: 100%;
        height: 100%;
        max-height: none;
        border: 0;
        border-radius: 0;
    }

    .games-modal__body {
        height: auto;
        aspect-ratio: auto;
    }
}

@media (max-height: 620px) {
    .games-modal {
        padding-block: 4px;
    }

    .games-modal__header,
    .games-modal__footer {
        min-height: 44px;
        padding-block: 2px;
    }

    .games-modal__close {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 640px) and (max-height: 620px) {
    .games-modal {
        padding: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .games-modal__body::after,
    .games-modal__play {
        transition: none;
    }
}
