/* =========================================================
   Theme variables
   Values may be overridden from site.json / inline <style>.
   ========================================================= */

:root {
    color-scheme: dark;

    --bg: #1d1d1d;
    --panel: #303030;
    --text: #e8e8e8;
    --accent: #e95420;

    --muted: rgba(232, 232, 232, 0.68);
    --line: rgba(232, 232, 232, 0.16);
    --line-strong: rgba(232, 232, 232, 0.28);
    --backdrop: rgba(29, 29, 29, 0.96);
    --overlay: rgba(29, 29, 29, 0.58);

    --radius: 8px;
    --radius-small: 6px;

    --container: 1080px;
    --page-gutter: 28px;
    --card-gap: 13px;
    --card-padding: 15px;
    --hero-spacing: 30px;
    --section-spacing: 46px;
    --modal-width: 1200px;

    --font-family: Ubuntu, Cantarell, "Noto Sans", "Segoe UI", Arial, sans-serif;
    --font-body: 14px;
    --font-small: 11px;
    --font-hero: 38px;
    --font-section: 27px;
    --font-card-title: 19px;
    --font-modal-title: 31px;
    --line-height: 1.5;

    font-family: var(--font-family);
    font-size: var(--font-body);
}

/* =========================================================
   Reset and document
   ========================================================= */

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

html {
    width: 100%;
    max-width: 100%;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-family);
    font-size: var(--font-body);
    line-height: var(--line-height);
}

body.modal-open {
    overflow: hidden;
    overscroll-behavior: none;
}

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

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

button {
    color: inherit;
}

img,
svg,
video,
iframe {
    display: block;
    max-width: 100%;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.container {
    width: min(calc(100% - var(--page-gutter)), var(--container));
    margin-inline: auto;
}

/* =========================================================
   Header / hero
   ========================================================= */

.hero {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-bottom: var(--hero-spacing);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
}

.brand__mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: var(--radius-small);
    background: var(--accent);
    color: var(--text);
    font-size: var(--font-small);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.brand__text {
    font-size: var(--font-body);
    font-weight: 700;
}

.hero__content {
    max-width: 720px;
    margin-top: var(--hero-spacing);
    padding-left: 15px;
    border-left: 3px solid var(--accent);
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--accent);
    font-size: var(--font-small);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero h1 {
    max-width: 720px;
    margin: 0;
    font-size: clamp(calc(var(--font-hero) * 0.72), 5vw, var(--font-hero));
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.12;
    text-wrap: balance;
}

.hero__tagline {
    max-width: 640px;
    margin: 13px 0 0;
    color: var(--muted);
    font-size: calc(var(--font-body) + 1px);
    line-height: var(--line-height);
}

/* =========================================================
   Games catalog
   ========================================================= */

.games-section {
    padding-top: 28px;
    padding-bottom: var(--section-spacing);
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 15px;
}

.section-heading h2 {
    margin: 0;
    font-size: clamp(calc(var(--font-section) * 0.82), 4vw, var(--font-section));
    font-weight: 700;
    letter-spacing: -0.015em;
}

.games-count {
    display: grid;
    min-width: 34px;
    height: 29px;
    padding-inline: 9px;
    place-items: center;
    border-radius: var(--radius-small);
    background: var(--accent);
    color: var(--text);
    font-size: calc(var(--font-small) + 1px);
    font-weight: 700;
}

.games-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--card-gap);
}

.game-card {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    padding: 0;
    border: 1px solid var(--line);
    border-top: 3px solid var(--card-accent, var(--accent));
    border-radius: var(--radius);
    background: var(--panel);
    cursor: pointer;
    text-align: left;
}

.game-card:hover {
    border-color: var(--card-accent, var(--accent));
}

.game-card:active {
    transform: translateY(1px);
}

.game-card__media {
    position: relative;
    display: block;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
}

.game-card__media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center;
}

.game-card__badge {
    position: absolute;
    z-index: 1;
    top: 9px;
    right: 9px;
    padding: 5px 8px;
    border: 1px solid var(--card-accent, var(--accent));
    border-radius: var(--radius-small);
    background: var(--panel);
    color: var(--text);
    font-size: max(9px, calc(var(--font-small) - 1px));
    font-weight: 700;
    letter-spacing: 0.025em;
}

.game-card__body {
    display: block;
    padding: var(--card-padding);
}

.game-card__title {
    display: block;
    margin-bottom: 6px;
    font-size: var(--font-card-title);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.game-card__description {
    display: -webkit-box;
    overflow: hidden;
    color: var(--muted);
    font-size: calc(var(--font-body) - 1px);
    line-height: var(--line-height);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.game-card__action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    color: var(--card-accent, var(--accent));
    font-size: calc(var(--font-small) + 1px);
    font-weight: 700;
}

.game-card__action svg {
    width: 15px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

/* =========================================================
   Footer
   ========================================================= */

.site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 24px;
    padding-top: 18px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: calc(var(--font-small) + 1px);
}

.site-footer__meta,
.site-footer__contacts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
}

.site-footer__meta span + span::before {
    margin-right: 14px;
    color: var(--line-strong);
    content: "•";
}

.site-footer__contacts {
    justify-content: flex-end;
}

.footer-email {
    color: var(--text);
    text-decoration: none;
}

.footer-email:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.footer-socials {
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-social {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
}

.footer-social:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.footer-social__icon {
    width: 18px;
    height: 18px;
    background: currentColor;
    -webkit-mask: var(--social-icon) center / contain no-repeat;
    mask: var(--social-icon) center / contain no-repeat;
}

@media (max-width: 699px) {
    .site-footer,
    .site-footer__contacts {
        align-items: flex-start;
        flex-direction: column;
    }

    .site-footer__contacts {
        width: 100%;
    }
}

/* =========================================================
   Modal shell

   The dialog itself never scrolls. Only .modal__layout scrolls.
   This keeps the close button stable and prevents viewport gaps.
   ========================================================= */

.modal[hidden] {
    display: none;
}

.modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 12px;
    overflow: hidden;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: var(--backdrop);
}

.modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(100%, var(--modal-width));
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--line-strong);
    border-top: 3px solid var(--modal-accent, var(--accent));
    border-radius: var(--radius);
    background: var(--panel);
}

.modal__layout {
    display: grid;
    min-width: 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: var(--modal-accent, var(--accent)) var(--bg);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.modal__close {
    position: absolute;
    z-index: 15;
    top: 9px;
    right: 9px;
    display: grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-small);
    background: var(--panel);
    cursor: pointer;
}

.modal__close:hover {
    border-color: var(--modal-accent, var(--accent));
    background: var(--accent);
}

.modal__close svg {
    width: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-width: 2;
}

/* =========================================================
   Gallery
   ========================================================= */

.gallery {
    position: relative;
    min-width: 0;
    padding: 9px;
    background: var(--bg);
}

.gallery__stage {
    position: relative;
    display: grid;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    place-items: center;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--bg);
}

.gallery__stage img,
.gallery__stage video,
.gallery__stage iframe {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: none;
    max-height: none;

    border: 0;
    object-fit: contain;
}

.gallery__empty {
    color: var(--muted);
    font-size: calc(var(--font-body) - 1px);
}

.gallery__arrow {
    position: absolute;
    z-index: 2;
    top: min(40vw, 290px);
    display: grid;
    width: 37px;
    height: 37px;
    padding: 0;
    place-items: center;
    transform: translateY(-50%);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-small);
    background: var(--panel);
    cursor: pointer;
}

.gallery__arrow:hover {
    border-color: var(--modal-accent, var(--accent));
    background: var(--accent);
}

.gallery__arrow:disabled {
    display: none;
}

.gallery__arrow--prev {
    left: 18px;
}

.gallery__arrow--next {
    right: 18px;
}

.gallery__arrow svg {
    width: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.gallery__counter {
    min-height: 17px;
    margin-top: 7px;
    color: var(--muted);
    font-size: var(--font-small);
    text-align: center;
}

.gallery__thumbs {
    display: grid;
    grid-auto-columns: 84px;
    grid-auto-flow: column;
    gap: 7px;
    overflow-x: auto;
    padding: 7px 1px 1px;
    scroll-snap-type: x proximity;
    scrollbar-color: var(--modal-accent, var(--accent)) var(--bg);
    scrollbar-width: thin;
}

.gallery__thumb {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--panel);
    cursor: pointer;
    opacity: 0.58;
    scroll-snap-align: start;
}

.gallery__thumb:hover {
    opacity: 0.82;
}

.gallery__thumb.is-active {
    border-color: var(--modal-accent, var(--accent));
    opacity: 1;
}

.gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery__thumb-icon {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--overlay);
}

.gallery__thumb-icon svg {
    width: 23px;
    fill: var(--text);
}

/* =========================================================
   Game information and links
   ========================================================= */

.game-info {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 21px;
    padding: 25px 18px 22px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.game-info__header {
    padding-right: 42px;
    padding-left: 13px;
    border-left: 3px solid var(--modal-accent, var(--accent));
}

.game-info h2 {
    margin: 0;
    font-size: clamp(calc(var(--font-modal-title) * 0.77), 6vw, var(--font-modal-title));
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.game-info__description {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: calc(var(--font-body) - 1px);
    line-height: 1.58;
}

.link-section {
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.link-section h3 {
    margin: 0 0 10px;
    color: var(--text);
    font-size: var(--font-small);
    font-weight: 700;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.store-links,
.extra-links {
    display: grid;
    gap: 7px;
}

.store-link,
.extra-link {
    display: flex;
    min-height: 46px;
    align-items: center;
    gap: 10px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-small);
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
}

.store-link:hover,
.extra-link:hover {
    border-color: var(--modal-accent, var(--accent));
}

.store-link__icon {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: var(--radius-small);
    background: var(--panel);
}

.store-link__icon img {
    width: 20px;
    height: 20px;
}

.store-link__label,
.extra-link__label {
    min-width: 0;
    flex: 1;
    font-size: calc(var(--font-body) - 1px);
    font-weight: 600;
}

.store-link__arrow,
.extra-link__arrow {
    width: 15px;
    flex: 0 0 auto;
    fill: none;
    stroke: var(--modal-accent, var(--accent));
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.extra-link {
    min-height: 41px;
}

.extra-link__label {
    font-weight: 500;
}

/* =========================================================
   JavaScript fallback
   ========================================================= */

.noscript {
    position: fixed;
    z-index: 200;
    right: 12px;
    bottom: 12px;
    left: 12px;
    padding: 11px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-small);
    background: var(--panel);
    color: var(--text);
    font-size: calc(var(--font-body) - 1px);
    text-align: center;
}

/* =========================================================
   Tablet and desktop
   ========================================================= */

@media (min-width: 700px) {
    .hero {
        padding-top: 20px;
        padding-bottom: calc(var(--hero-spacing) * 1.25);
    }

    .hero__content {
        margin-top: calc(var(--hero-spacing) * 1.3);
    }

    .games-section {
        padding-top: 34px;
        padding-bottom: calc(var(--section-spacing) * 1.2);
    }

    .games-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: calc(var(--card-gap) + 3px);
    }

    .modal {
        padding: 18px;
    }

    .modal__dialog {
        max-height: calc(100vh - 36px);
        max-height: calc(100dvh - 36px);
    }

    .gallery {
        padding: 13px;
    }

    .game-info {
        padding: 28px 25px 25px;
    }

    .store-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1020px) {
    .games-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .modal__layout {
        grid-template-columns: minmax(0, 1.65fr) minmax(310px, 0.7fr);
    }

    .gallery {
        display: flex;
        min-height: 600px;
        flex-direction: column;
        justify-content: center;
        padding: 18px;
    }

    .gallery__arrow {
        top: 50%;
    }

    .gallery__thumbs {
        grid-auto-columns: 100px;
        padding-top: 11px;
    }

    .game-info {
        position: sticky;
        top: 0;
        align-self: start;
        min-height: 600px;
        padding: 37px 28px 28px;
        border-top: 0;
        border-left: 1px solid var(--line);
    }

    .store-links {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   Phone / coarse-pointer fullscreen modal

   No viewport height is calculated here. The fixed modal fills
   the current viewport via inset: 0, and the dialog flexes into it.
   ========================================================= */

@media (max-width: 699px), (max-width: 960px) and (hover: none) and (pointer: coarse) {
    .hero__content {
        margin-top: 27px;
    }

    .modal {
        display: flex;
        align-items: stretch;
        justify-content: stretch;
        padding: 0;
        background: var(--panel);
    }

    .modal__backdrop {
        display: none;
    }

    .modal__dialog {
        flex: 1 1 auto;
        width: 100%;
        max-width: none;
        min-width: 0;
        min-height: 0;
        max-height: none;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .modal__layout {
        flex: 1 1 auto;
        min-height: 0;
    }

    .modal__close {
        position: fixed;
        top: max(8px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
    }

    .gallery {
        padding: max(6px, env(safe-area-inset-top)) 6px 9px;
    }

    .gallery__arrow {
        top: 29vw;
        width: 35px;
        height: 35px;
    }

    .gallery__arrow--prev {
        left: 11px;
    }

    .gallery__arrow--next {
        right: 11px;
    }

    .game-info {
        padding:
                24px
                max(15px, env(safe-area-inset-right))
                max(22px, env(safe-area-inset-bottom))
                max(15px, env(safe-area-inset-left));
    }
}

/* =========================================================
   Accessibility
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .game-card:active {
        transform: none;
    }
}
