/* Bridge tablet/narrow-browser widths so the layout does not fall between mobile and desktop rules. */
@media (min-width: 640px) and (max-width: 980px) and (min-height: 700px) {
  html,
  body { min-height: 100% !important; overflow-x: hidden !important; }

  body.game-active .app-shell {
    --intermediate-table-size: min(calc(100vw - 244px), calc(100dvh - 546px));
    width: 100vw !important;
    min-height: var(--app-visible-height, 100dvh) !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 10px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 210px !important;
    grid-template-rows: 104px 126px var(--intermediate-table-size) 48px 112px 96px !important;
    grid-template-areas:
      "top top"
      "variant score"
      "table score"
      "events score"
      "hand hand"
      "chat chat" !important;
    gap: 8px !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  body.game-active .top-bar {
    grid-area: top !important;
    width: 100% !important;
    height: 104px !important;
    min-width: 0 !important;
    min-height: 104px !important;
    padding: 9px 12px !important;
    overflow: hidden !important;
  }

  body.game-active .top-bar > div:first-child { min-width: 0 !important; }
  body.game-active .top-bar h1 { font-size: clamp(18px, 2.5vw, 23px) !important; }
  body.game-active .status-grid { min-width: 0 !important; grid-template-columns: minmax(118px, 1.15fr) repeat(2, minmax(86px, .85fr)) !important; gap: 7px !important; }
  body.game-active .status-pill { min-width: 0 !important; padding: 7px 9px !important; }

  body.game-active .variant-banner {
    grid-area: variant !important;
    place-self: stretch !important;
    width: 100% !important;
    height: 126px !important;
    min-width: 0 !important;
    min-height: 126px !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 11px 13px !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 72px !important;
    align-items: center !important;
    gap: 8px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  body.game-active .variant-banner-content { min-width: 0 !important; }
  body.game-active .variant-banner-content > span { font-size: 10px !important; }
  body.game-active .variant-banner-content > strong { display: block !important; font-size: clamp(18px, 2.65vw, 24px) !important; line-height: 1.02 !important; }
  body.game-active .variant-banner-content > p { margin: 4px 0 0 !important; max-width: 34ch !important; font-size: 11px !important; line-height: 1.12 !important; }
  body.game-active .variant-city-mark { width: 72px !important; height: 72px !important; min-width: 72px !important; display: grid !important; place-items: center !important; font-size: 19px !important; }

  body.game-active .score-board {
    grid-area: score !important;
    place-self: stretch !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    padding: 8px !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: repeat(3, 62px) minmax(0, 1fr) !important;
    gap: 7px !important;
    overflow: hidden !important;
  }

  body.game-active .score-board > .score-card { min-height: 62px !important; height: 62px !important; padding: 8px 9px !important; }
  body.game-active .score-board > .score-actions { display: grid !important; grid-template-columns: 1fr !important; align-content: start !important; gap: 8px !important; }
  body.game-active .score-board > .score-actions button { min-height: 44px !important; }

  body.game-active .table {
    grid-area: table !important;
    place-self: center !important;
    width: var(--intermediate-table-size) !important;
    height: var(--intermediate-table-size) !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 100% !important;
    max-height: 100% !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 11px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  body.game-active .deal-animation-layer {
    --deal-card-w: clamp(36px, calc(var(--intermediate-table-size) * .11), 44px) !important;
  }

  body.game-active .played-card {
    width: clamp(48px, calc(var(--intermediate-table-size) * .145), 58px) !important;
  }

  body.game-active .played-card .mini-card {
    width: clamp(48px, calc(var(--intermediate-table-size) * .145), 58px) !important;
    height: auto !important;
    aspect-ratio: .69 !important;
    border-radius: clamp(6px, calc(var(--intermediate-table-size) * .018), 8px) !important;
  }

  body.game-active .played-card .mini-card .corner { top: 7px !important; left: 7px !important; font-size: clamp(12px, calc(var(--intermediate-table-size) * .04), 15px) !important; }
  body.game-active .played-card .mini-card .corner > span:last-child,
  body.game-active .played-card .mini-card .rank-center { display: none !important; }
  body.game-active .played-card .mini-card .suit { inset: 0 !important; padding-top: 14% !important; display: grid !important; place-items: center !important; font-size: clamp(28px, calc(var(--intermediate-table-size) * .1), 36px) !important; }
  body.game-active .played-card > span { font-size: 11px !important; }

  body.game-active .bid-panel { display: none !important; }
  body.game-active .bid-popup-dialog { width: min(420px, calc(100vw - 28px)) !important; }

  body.game-active .game-events {
    grid-area: events !important;
    place-self: stretch !important;
    width: 100% !important;
    height: 48px !important;
    min-width: 0 !important;
    min-height: 48px !important;
    padding: 5px !important;
    overflow: hidden !important;
  }

  body.game-active .game-events .message { height: 100% !important; min-height: 0 !important; padding: 5px 9px !important; display: flex !important; align-items: center !important; font-size: 13px !important; overflow: hidden !important; }

  body.game-active .hand-panel {
    grid-area: hand !important;
    place-self: stretch !important;
    width: 100% !important;
    height: 112px !important;
    min-width: 0 !important;
    min-height: 112px !important;
    max-width: none !important;
    padding: 7px 10px !important;
    display: grid !important;
    grid-template-rows: 28px 70px !important;
    gap: 5px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  body.game-active .hand-heading { min-width: 0 !important; min-height: 28px !important; margin: 0 !important; display: grid !important; grid-template-columns: minmax(0, 1fr) minmax(190px, auto) !important; align-items: center !important; gap: 8px !important; }
  body.game-active .your-player-label .avatar { width: 28px !important; height: 28px !important; min-width: 28px !important; font-size: 14px !important; }
  body.game-active .hand-heading h2 { font-size: 17px !important; }
  body.game-active .hand-heading p { font-size: 11px !important; line-height: 1.1 !important; text-align: right !important; }

  body.game-active #playerHand.hand {
    width: 100% !important;
    height: 70px !important;
    min-width: 0 !important;
    min-height: 70px !important;
    max-width: 100% !important;
    margin: 0 !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: center !important;
    gap: clamp(5px, 1.25vw, 11px) !important;
    overflow: hidden !important;
  }

  body.game-active #playerHand .card { flex: 0 1 48px !important; width: 48px !important; height: 70px !important; min-width: 0 !important; min-height: 70px !important; max-width: 48px !important; max-height: 70px !important; aspect-ratio: .69 !important; border-radius: 7px !important; }
  body.game-active #playerHand .card .corner > span:last-child { display: none !important; }

  body.game-active .table-chat {
    grid-area: chat !important;
    place-self: stretch !important;
    width: 100% !important;
    height: 96px !important;
    min-width: 0 !important;
    min-height: 96px !important;
    padding: 8px !important;
    overflow: hidden !important;
  }

  body.game-active .table-chat-header { min-width: 190px !important; }
  body.game-active .table-chat-log { min-height: 0 !important; height: 100% !important; overflow-y: auto !important; }
}

/* Kleine tablet / smal browservenster: compacte spelvariant links van een
   volwaardige vierkante tafel. De beschikbare hoogte bepaalt de tafelmaat. */
@media (min-width: 820px) and (max-width: 980px) and (min-height: 700px) {
  body.game-active .app-shell {
    --intermediate-table-size: min(calc(100vw - 436px), calc(100dvh - 420px)) !important;
    grid-template-columns: 190px minmax(0, 1fr) 210px !important;
    grid-template-rows: 104px var(--intermediate-table-size) 48px 112px 96px !important;
    grid-template-areas:
      "top top top"
      "variant table score"
      "events events score"
      "hand hand hand"
      "chat chat chat" !important;
  }

  body.game-active .variant-banner {
    width: 190px !important;
    height: 112px !important;
    min-height: 112px !important;
    align-self: start !important;
    justify-self: center !important;
    padding: 10px 11px !important;
    grid-template-columns: minmax(0, 1fr) 48px !important;
    gap: 5px !important;
  }

  body.game-active .variant-banner-content > span { font-size: 9px !important; }
  body.game-active .variant-banner-content > strong { font-size: 16px !important; line-height: 1.03 !important; }
  body.game-active .variant-banner-content > p { margin-top: 4px !important; font-size: 9px !important; line-height: 1.08 !important; }

  body.game-active .variant-city-mark {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    font-size: 15px !important;
  }

  body.game-active .table {
    place-self: center !important;
    width: var(--intermediate-table-size) !important;
    height: var(--intermediate-table-size) !important;
    max-width: 100% !important;
    max-height: 100% !important;
  }
}
