/* Every /games page: one screen, page itself never scrolls.
   Chat / move logs / open-room lists may scroll inside their own boxes. */
html.fit-viewport,
html.fit-viewport body {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
html.fit-viewport body {
  display: flex;
  flex-direction: column;
}
html.fit-viewport .bar {
  flex: 0 0 auto;
  padding: 0.35rem 0.75rem;
}
html.fit-viewport .brand {
  font-size: 1.15rem;
}
html.fit-viewport .nav a {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}
html.fit-viewport .game {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0.35rem 0.75rem 0.45rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
html.fit-viewport body.is-playing .game {
  width: 100%;
  max-width: none;
  padding: 0.25rem 0.45rem 0.3rem;
}
html.fit-viewport .game > h1 {
  flex-shrink: 0;
  font-size: clamp(1.45rem, 3.5vw, 2rem);
  margin: 0 0 0.1rem;
}
html.fit-viewport .game > .lede {
  flex-shrink: 0;
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Lobby fills leftover height; only inner lists scroll */
html.fit-viewport #lobby.panel,
html.fit-viewport #lobby {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
html.fit-viewport #lobby .actions {
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
}
html.fit-viewport #lobby .open-rooms {
  flex: 0 1 30%;
  min-height: 0;
  max-height: none;
  overflow: auto;
  margin: 0;
}
html.fit-viewport #lobby .lobby-chat,
html.fit-viewport #lobby .chat-box {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  margin-top: 0;
}

/* In-room table fills the main column */
html.fit-viewport body.is-playing .game > h1,
html.fit-viewport body.is-playing .game > .lede,
html.fit-viewport body.is-playing #lobby {
  display: none !important;
}
html.fit-viewport body.is-playing #table.table {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  gap: 0;
  grid-template-columns: 1fr;
  align-items: stretch;
}
html.fit-viewport .play-col {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
html.fit-viewport body.is-playing .play-col {
  gap: 0.28rem;
}
html.fit-viewport body.is-playing .hud {
  gap: 0.3rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}
html.fit-viewport body.is-playing .hud-block {
  padding: 0.28rem 0.5rem;
  min-width: 0;
}
html.fit-viewport body.is-playing .hud-block .label {
  font-size: 0.62rem;
}
html.fit-viewport body.is-playing .hud-block strong {
  font-size: 0.82rem;
}
html.fit-viewport body.is-playing .players {
  font-size: 0.8rem;
  gap: 0.35rem;
  flex-shrink: 0;
}
html.fit-viewport body.is-playing .share {
  margin: 0;
  gap: 0.35rem;
  flex-shrink: 0;
}
html.fit-viewport body.is-playing .share input {
  padding: 0.4rem 0.55rem;
  font-size: 0.72rem;
}
html.fit-viewport body.is-playing .share .btn {
  padding: 0.4rem 0.7rem;
  font-size: 0.78rem;
}
html.fit-viewport body.is-playing .chess-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100% !important;
  max-width: none !important;
  margin: 0;
  padding: 0;
}
html.fit-viewport body.is-playing .chess-canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: auto !important;
  max-height: none !important;
  aspect-ratio: auto !important;
}
html.fit-viewport body.is-playing .chess-canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}
html.fit-viewport body.is-playing .turn {
  margin: 0;
  font-size: 0.78rem;
  text-align: center;
  flex-shrink: 0;
}
html.fit-viewport body.is-playing .play-col > .row {
  margin-top: 0 !important;
  flex-shrink: 0;
  justify-content: center;
}
html.fit-viewport body.is-playing .play-col > .row .btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.78rem;
}
/* Games hub cards */
html.fit-viewport .game > .actions {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  align-content: start;
}


