/* === СТРАНИЦА ИГРЫ ===
   Та же палитра и та же манера, что у витрины (см. комментарий в
   css/index/style.css): токены variables.css, скругления 8–14px,
   границы --color-dark-grey. */

.game-page {
    width: 100%;
    max-width: 900px;
    padding: 24px 24px 56px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-sizing: border-box;
}

.game-back {
    font-size: 13px;
    color: var(--text-light-grey);
    align-self: flex-start;
}

.game-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.game-icon {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border: 1px solid var(--color-dark-grey);
    border-radius: 16px;
    background-color: var(--color-dark-grey);
    flex-shrink: 0;
}

.game-identity {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1 1 220px;
}

.game-title {
    margin: 0;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--text-white);
}

.game-author {
    margin: 0;
    font-size: 13px;
    color: var(--text-light-grey);
}

.game-plays {
    margin: 0;
    font-size: 12px;
    color: var(--text-grey);
}

.game-play,
.comment-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--site-control-h);
    padding: 0 28px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-white);
    background: var(--gradient-brand);
    border: 1px solid var(--color-purple);
    border-radius: 8px;
    white-space: nowrap;
    transition: opacity 0.15s ease, transform 0.1s ease;
}

.game-play:hover,
.comment-submit:hover {
    opacity: 0.9;
}

.game-play:active,
.comment-submit:active {
    transform: translateY(1px);
}

/* ----- Плеер -----
   Постер и iframe — одна и та же коробка: скрипт подменяет один
   элемент другим, и без общих правил страница дёргалась бы в момент
   запуска. */
.game-stage {
    position: relative;
}

.game-player,
.game-frame {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--color-dark-grey);
    border-radius: 12px;
    background-color: var(--color-dark-grey);
    overflow: hidden;
}

/* ----- Разворот на весь вьюпорт -----
   Не системный fullscreen: сцена растягивается на весь экран поверх
   страницы, а браузер остаётся собой. */
.game-stage.is-maximized {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: var(--color-black);
}

.game-stage.is-maximized .game-frame {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border: none;
    border-radius: 0;
}

/* Скрытая кнопка обязана быть скрытой: display из класса перебивает
   [hidden] браузера. У кнопки разворота (.stage-expand) правило своё,
   в main.css. */
.game-play[hidden] {
    display: none;
}

/* Кнопка разворота (вид — .stage-expand в main.css) — в правом верхнем
   углу игры. */
.game-stage .stage-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
}

.game-player {
    position: relative;
    transition: border-color 0.15s ease;
}

.game-player:hover {
    border-color: var(--color-purple);
    opacity: 1;
}

.game-player-poster {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Кнопка запуска поверх постера. Треугольник рисуем бордерами:
   иконки под него в проекте нет, а картинка ради одного значка —
   лишний запрос. */
.game-player-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--gradient-brand);
    box-shadow: 0 8px 28px rgba(20, 24, 32, 0.55);
    transition: transform 0.15s ease;
}

.game-player-play::before {
    content: "";
    border-style: solid;
    border-width: 13px 0 13px 21px;
    border-color: transparent transparent transparent var(--text-white);

    /* Оптический центр треугольника правее геометрического. */
    margin-left: 6px;
}

.game-player:hover .game-player-play {
    transform: translate(-50%, -50%) scale(1.08);
}

.game-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-section-title {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-white);
}

.game-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-light-grey);
    white-space: pre-line;
}

/* ----- Лайк и избранное ----- */
.game-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: var(--site-control-h);
    padding: 0 14px;
    font-size: 13px;
    color: var(--text-light-grey);
    background: transparent;
    border: 1px solid var(--color-dark-grey);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.game-action:hover:not(:disabled) {
    color: var(--text-white);
    border-color: var(--color-purple);
    opacity: 1;
}

.game-action:disabled {
    cursor: wait;
    opacity: 0.6;
}

.game-action-icon {
    font-size: 15px;
    line-height: 1;
}

.game-action.is-on {
    color: var(--text-white);
    border-color: var(--color-magenta);
}

.game-action.is-on .game-action-icon {
    color: var(--text-magenta);
}

/* ----- Поделиться -----
   Квадратная кнопка последней в ряду лайка и избранного. Формочка со
   ссылкой (share_link.ejs, стили поля — main.css) выпадает под ней
   влево: справа от последней кнопки места нет.

   Блок стоит после .game-action: селекторы того же веса, и padding с
   display кнопки должны перебить общие, а не наоборот. */
.game-share {
    position: relative;
}

/* display:flex, а не inline-flex от .game-action: строчный summary
   оставил бы под собой зазор, и кнопка встала бы ниже соседей. */
.game-share-btn {
    display: flex;
    width: var(--site-control-h);
    padding: 0;
    justify-content: center;
    list-style: none;
    user-select: none;
}

.game-share-btn::-webkit-details-marker {
    display: none;
}

.game-share[open] .game-share-btn {
    color: var(--text-white);
    border-color: var(--color-purple);
}

.game-share-icon {
    width: 18px;
    height: 18px;
}

.game-share-popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 10;
    width: 280px;
    padding: 6px;
    background-color: var(--layer-2);
    border: 1px solid var(--color-dark-grey);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
    box-sizing: border-box;
}

/* ----- Скриншоты -----
   Лента миниатюр фиксированной высоты под плеером: три скриншота
   640×360 во всю ширину раздували страницу втрое. */
.game-shots {
    display: flex;
    flex-direction: row;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.game-shots::-webkit-scrollbar {
    display: none;
}

.game-shot {
    flex: 0 0 auto;
    display: block;
    height: 120px;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--color-dark-grey);
    border-radius: 10px;
    background-color: var(--color-dark-grey);
    overflow: hidden;
    transition: border-color 0.15s ease;
}

.game-shot:hover {
    border-color: var(--color-purple);
    opacity: 1;
}

.game-shot-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ----- Лайтбокс скриншотов -----
   Полноэкранный оверлей: крупный кадр, стрелки по бокам и рулетка
   миниатюр внизу. Скрыт атрибутом hidden до первого клика. */
/* display:grid перебивает браузерное [hidden]{display:none} — без
   этой строки оверлей виден сразу после загрузки. */
.shot-lightbox[hidden] {
    display: none;
}

.shot-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(20, 24, 32, 0.92);
}

/* Пока лайтбокс открыт — страница под ним не прокручивается. */
body.shot-open {
    overflow: hidden;
}

.shot-lightbox-image {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.shot-lightbox-nav {
    grid-row: 1;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: var(--text-white);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--color-dark-grey);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.shot-lightbox-nav:hover {
    background: rgba(144, 19, 254, 0.35);
    border-color: var(--color-purple);
}

.shot-lightbox-prev { grid-column: 1; }
.shot-lightbox-next { grid-column: 3; }

.shot-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    font-size: 26px;
    line-height: 1;
    color: var(--text-white);
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.15s ease;
}

.shot-lightbox-close:hover {
    opacity: 1;
}

/* Рулетка миниатюр под кадром. */
.shot-lightbox-strip {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: none;
}

.shot-lightbox-strip::-webkit-scrollbar {
    display: none;
}

.shot-lightbox-thumb {
    flex: 0 0 auto;
    width: 112px;
    height: 63px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--color-dark-grey);
    cursor: pointer;
    overflow: hidden;
    opacity: 0.55;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.shot-lightbox-thumb:hover {
    opacity: 0.85;
}

.shot-lightbox-thumb.is-active {
    opacity: 1;
    border-color: var(--color-magenta);
}

.shot-lightbox-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 640px) {
    .game-page {
        padding: 20px 16px 40px;
        gap: 20px;
    }

    .game-title {
        font-size: 20px;
    }

    .game-icon {
        width: 64px;
        height: 64px;
        border-radius: 14px;
    }

    /* Кнопка уходит под шапку и растягивается: на телефоне она
       главное действие страницы. */
    .game-play {
        width: 100%;
        text-align: center;
    }

    .game-actions {
        width: 100%;
    }

    .game-action {
        flex: 1 1 0;
        justify-content: center;
    }

    .game-shot {
        height: 84px;
    }

    .game-player-play {
        width: 56px;
        height: 56px;
    }

    .game-player-play::before {
        border-width: 10px 0 10px 16px;
        margin-left: 5px;
    }

    /* На телефоне стрелки лишние: рулетка листается пальцем. */
    .shot-lightbox {
        padding: 16px 8px;
    }

    .shot-lightbox-nav {
        display: none;
    }

    .shot-lightbox-image {
        grid-column: 1 / -1;
    }

    .shot-lightbox-thumb {
        width: 84px;
        height: 47px;
    }
}

/* === ОТЗЫВЫ ===
   Список приходит скриптом (js/game/comments.js); карточки клонируются
   из <template> в game.ejs. Раскладка как у YouTube: аватар, автор и
   давность, текст, ряд «лайк / дизлайк / Ответить», под ним
   раскрывашка ответов. Ответы — тот же блок, поменьше. */

/* Карточки и кнопки задают display классом, а скрипт прячет их
   атрибутом hidden — без этого правила класс победил бы. */
.game-comments [hidden] {
    display: none !important;
}

.comments-count {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-grey);
}

.comment-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.comment-input {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-white);
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-dark-grey);
    border-radius: 8px;
    outline: none;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s ease;
}

.comment-input::placeholder {
    color: var(--text-grey);
}

.comment-input:focus {
    border-color: var(--color-purple);
}

.comment-submit {
    font-family: inherit;
    cursor: pointer;
}

.comment-form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.comment-hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-grey);
}

.comment-error {
    color: var(--color-red-pink);
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.comment {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--color-dark-grey);
    flex-shrink: 0;
}

.comment-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.comment-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.comment-author {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-white);
}

.comment-date {
    font-size: 12px;
    color: var(--text-grey);
}

.comment-delete {
    margin-left: auto;
}

.comment-text {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-light-grey);
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Текстовая кнопка: «Ответить», «Удалить», раскрывашка ответов. */
.comment-link {
    padding: 0;
    font: inherit;
    font-size: 12px;
    color: var(--text-grey);
    background: none;
    border: 0;
    cursor: pointer;
    transition: color 0.15s ease;
}

.comment-link:hover {
    color: var(--text-white);
}

/* Ряд действий под текстом: лайк с числом, дизлайк, «Ответить». */
.comment-foot {
    display: flex;
    align-items: center;
    gap: 16px;
}

.comment-vote {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    font: inherit;
    font-size: 12px;
    color: var(--text-grey);
    background: none;
    border: 0;
    cursor: pointer;
    transition: color 0.15s ease;
}

.comment-vote:hover:not(:disabled) {
    color: var(--text-white);
}

.comment-vote:disabled {
    cursor: wait;
}

.comment-vote.is-on {
    color: var(--color-magenta);
}

.comment-vote-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Дизлайк — тот же большой палец, перевёрнутый. */
.comment-dislike .comment-vote-icon {
    transform: rotate(180deg);
}

/* Раскрывашка «N ответов»: стрелка поворачивается, когда открыто. */
.comment-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    color: var(--text-purple);
}

.comment-toggle-icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: transform 0.15s ease;
}

.comment-toggle[aria-expanded="true"] .comment-toggle-icon {
    transform: rotate(180deg);
}

.comment-replies {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4px;
}

.comment-reply .comment-avatar {
    width: 26px;
    height: 26px;
}

.comment-reply-form {
    margin-top: 4px;
}

.comments-more {
    align-self: center;
}
