/* ============================================================
   18-ingame-layout.css — In-game layout (final overrides)
   ============================================================ */

/* Game screen: left board fills height; right column scrolls so 2 cards are not clipped */
/* Bottom nav bar is hidden (display:none !important in 11-bottom-nav.css), so
   reserve 0 space for it instead of leaving an empty gap at the bottom of
   the select/game screens. */
:root { --nav-h: 0px; }

body.in-game {
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  /* Lock document scroll so only the player cards area can move */
  overflow: hidden !important;
  height: 100%;
  max-height: 100%;
}
html:has(body.in-game) {
  overflow: hidden !important;
  height: 100%;
}

body.in-game #phase-game {
  display: flex !important;
  flex-direction: column;
  /* Lock the game screen to the viewport so the 1-75 board never scrolls.
     Only the player cards (.player-card-wrap) are allowed to scroll. */
  height: calc(100vh - var(--nav-h) - env(safe-area-inset-bottom, 0px));
  height: calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom, 0px));
  height: calc(var(--tg-vh, 100vh) - var(--nav-h) - env(safe-area-inset-bottom, 0px));
  min-height: 0;
  max-height: calc(100vh - var(--nav-h) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - var(--nav-h) - env(safe-area-inset-bottom, 0px));
  max-height: calc(var(--tg-vh, 100vh) - var(--nav-h) - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

body.in-game .stats-row { flex: none; padding: 6px 8px 4px; }

body.in-game .stat-box { padding: 4px 2px; }

body.in-game .stat-label { line-height: 1.15; margin-bottom: 0; }

body.in-game .stat-value { line-height: 1.25; }

body.in-game .sound-round { width: 36px; height: 36px; font-size: 16px; }

body.in-game .hist-bar { flex: none; margin: 2px 8px 0; padding: 4px 8px; min-height: 0; }

body.in-game .game-main {
  flex: 1 1 auto;
  min-height: 0; /* allow flex children to shrink so only cards scroll */
  padding: 6px 8px 6px;
  align-items: stretch;
  overflow: hidden;
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

body.in-game .left-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Left column (1-75 board) stays fixed; never participates in scrolling */
  overflow: hidden;
}

body.in-game .left-sticky {
  position: static;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

body.in-game .numbers-list {
  flex: 1 1 0;
  min-height: 0; /* was 280px — let it shrink on short screens instead of forcing page scroll */
  display: flex !important;
  flex-direction: column;
  max-height: none;
  overflow: hidden;
  padding: 5px 5px 6px;
  visibility: visible !important;
}

body.in-game .list-header { flex: none; padding-bottom: 3px; }

body.in-game .list-header span { padding: 1px 0; font-size: 13px; }

body.in-game .list-body {
  flex: 1 1 auto;
  min-height: 0; /* was 300px — prevent forcing the whole page to scroll */
  gap: 3px;
  grid-template-rows: repeat(15, minmax(0, 1fr));
}

body.in-game .list-num {
  height: auto;
  min-height: 0;
  font-size: clamp(9px, 1.5vh, 12px);
  border-radius: 6px;
}

body.in-game .bottom-area { flex: none; padding: 6px 0 0; }

body.in-game .cards-count { font-size: 17px; line-height: 1.1; margin-bottom: 0; }

body.in-game .cards-count-row { margin-bottom: 3px; }

body.in-game .cards-icon { width: 30px; height: 30px; padding: 3px; gap: 1.5px; }

body.in-game .promo-marquee { padding: 4px 0; font-size: 10.5px; margin-bottom: 5px; }

body.in-game .refresh-big { padding: 7px; font-size: 12px; margin-bottom: 4px; border-radius: 10px; }

body.in-game .game-id { font-size: 10px; line-height: 1.2; }

/* The ball/draw/AUTO/BINGO controls never scroll - only the card list below
   them does (.player-card-wrap). The 1-75 board on the left is also fixed.
   #phase-game is locked to the viewport (overflow:hidden) so nothing else moves. */
body.in-game .call-side {
  min-height: 0;
  max-height: none;
  gap: 6px;
  overflow: hidden; /* clip to itself; only .player-card-wrap scrolls inside */
  align-items: stretch;
  display: flex !important;
  flex-direction: column;
  visibility: visible !important;
  flex: 1 1 auto;
}

body.in-game .call-side > *:not(.player-card-wrap) {
  touch-action: none;
  flex: none; /* keep controls from shrinking */
}

body.in-game .ball-sticky {
  position: static;
  padding: 0 0 6px;
  background: var(--bg);
  flex: none;
}

body.in-game .current-ball { width: 78px; height: 78px; font-size: 25px; }

body.in-game .wait-msg { font-size: 15px; line-height: 1.45; margin-top: 8px; }

body.in-game .player-card-wrap {
  flex: 1 1 auto;
  min-height: 0;
  margin-bottom: 0;
  padding-bottom: 4px;   /* was 20px — wasted empty space that hid the 2nd card */
  overflow-x: hidden;
  overflow-y: auto;      /* ONLY this element scrolls when multiple cards are present */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* On a viewport taller than the card needs (desktop Mini App window, or embedded inside
     another app's WebView), center the card group instead of leaving it top-pinned with dead
     space below. "safe" drops back to plain top-alignment the instant a 2nd card no longer
     fits, so the existing scroll-to-reveal-card-2 behavior below is unaffected either way. */
  display: flex;
  flex-direction: column;
  justify-content: safe center;
}

/* 2 cards: tighter stack so the second card is at least partially visible without scrolling */
body.in-game #player-cards.multi[data-count="2"] {
  gap: 6px;
  padding-bottom: 0;
}


@media (max-height: 640px) {
  body.in-game .promo-marquee { display: none; }
  body.in-game .current-ball { width: 68px; height: 68px; font-size: 22px; }
}
