/* static/games.layout.css */

/* Единый “game modal” по реальной высоте (через layout.js vars)
   БАЗА: на Desktop/Web — “card” по центру, на маленьких экранах/в tg fullscreen — full-bleed. */
#gamePlayModal.game-play-modal{
  position: fixed;
  inset: 0;
  width: 100vw;
  height: var(--app-h);
  max-height: var(--app-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--phone-pad, 14px);
  margin: 0;
  box-sizing: border-box;
}

/* Окно игры по умолчанию — card (чтобы на Desktop не было “растянутого” уродства) */
#gamePlayModal.game-play-modal .game-play-window{
  width: min(var(--phone-w, 420px), calc(100vw - (var(--phone-pad, 14px) * 2)));
  height: min(var(--modal-max-h, 860px), calc(var(--app-h) - (var(--phone-pad, 14px) * 2)));
  max-height: calc(var(--app-h) - (var(--phone-pad, 14px) * 2));
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  border-radius: 24px;
}

/* Внутренний root игры — flex, чтобы HUD/контент корректно делили высоту */
#gamePlayRoot,
#gamePlayModal .game-play-root{
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Контент игры всегда “внутри”, без горизонтального скролла */
#gamePlayModal canvas,
#gamePlayModal .game-canvas,
#gamePlayModal img{
  max-width: 100%;
  height: auto;
}

/* Safe-area снизу для HUD/кнопок внутри игры (если игра сама не добавила) */
#gamePlayModal .game-play-body{
  padding-bottom: calc(max(var(--safe-bottom), env(safe-area-inset-bottom, 0px)) + 16px);
  box-sizing: border-box;
}

/* Small screens: full-bleed */
@media (max-width: 520px){
  body #gamePlayModal.game-play-modal{
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  body #gamePlayModal.game-play-modal .game-play-window{
    width: 100vw;
    height: var(--app-h);
    max-height: var(--app-h);
    border-radius: 0;
  }
}

/* Telegram fullscreen: always full-bleed */
html.tg-fs #gamePlayModal.game-play-modal{
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}
html.tg-fs #gamePlayModal.game-play-modal .game-play-window{
  width: 100vw;
  height: var(--app-h);
  max-height: var(--app-h);
  border-radius: 0;
}

/* ===============================
   GAME SHELL — ЕДИНЫЙ КОНТРАКТ
   =============================== */

#gamePlayRoot {
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: 100%;
  min-height: 0;
}

/* общий контейнер всех игр */
.game-shell {
  width: 100%;
  max-width: 420px;        /* ПК и Web Telegram */
  height: 100%;
  min-height: 0;

  display: flex;
  flex-direction: column;

  margin: 0 auto;
}

/* mobile fullscreen */
html.tg-fs .game-shell {
  max-width: none;
}

/* зона самой игры */
.game-shell-inner {
  flex: 1;
  min-height: 0;

  display: flex;
  justify-content: center;
  align-items: center;
}
