/* A mesa usa a altura disponível; controles e identidades não disputam a mão. */
@media (max-width: 600px) {
  body.in-game {
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }
  .in-game main {
    height: 100%;
    min-height: 0;
    padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  }
  .in-game .arena {
    padding: 8px 8px 0;
    border-radius: 16px 16px 0 0;
  }
  .in-game .arena-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
    min-height: 0;
    padding: 0 2px 8px;
    letter-spacing: 0;
  }
  .in-game .arena-top #mode-label { display: none; }
  .in-game .arena-top .score-panel {
    grid-column: 1 / -1;
    grid-row: 1;
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 8px;
  }
  .in-game .arena-top .score { gap: 8px; min-width: 0; }
  .in-game .score > div { gap: 5px; min-width: 0; }
  .in-game .score div span { max-width: 62px; font-size: 11px; }
  .in-game .arena-top .score strong { font-size: 25px; }
  .in-game .arena-top .score-panel .rounds { gap: 4px; }
  .in-game .arena-top .turn-clock {
    grid-column: 1;
    grid-row: 2;
    order: initial;
    width: 100%;
    margin: 0;
    padding: 5px 9px;
  }
  .in-game .arena-top #clock-label { max-width: none; font-size: 11px; }
  .in-game .arena-top .sound-control { grid-column: 2; grid-row: 2; position: relative; }
  .in-game .sound-control summary { min-width: 44px; min-height: 44px; display: grid; place-items: center; padding: 0; }
  .in-game .felt {
    container-type: size;
    flex: 1;
    min-height: 0;
    border-radius: 26px;
  }
  .in-game .felt:before { inset: 6px; border-radius: 21px; }
  .in-game .opponent { top: 10px; max-width: 70%; }
  .in-game .player strong { font-size: 12px; }
  .in-game .opponent-cards { top: 57px; margin: 0; }
  .in-game .opponent-cards .card { width: 26px; height: 36px; }
  .in-game .side-seat { top: 34%; width: 65px; }
  .in-game .side-seat.left { left: 4px; }
  .in-game .side-seat.right { right: 4px; }
  .in-game .side-seat strong:before { font-size: 10px; overflow-wrap: anywhere; }
  .in-game .side-identity { padding: 3px; }
  .in-game .side-seat .mini-cards { gap: 0; margin-top: 9px; }
  .in-game .side-seat .mini-cards .card { width: 22px; min-width: 22px; height: 31px; min-height: 31px; margin-left: -4px; }
  .in-game .table-center, .in-game .doubles .table-center {
    top: 47%;
    height: clamp(112px, 32cqh, 170px);
    transform: translateY(-50%);
  }
  .in-game .played, .in-game .doubles .played {
    position: relative;
    inset: auto;
    transform: none;
    display: block;
    margin: auto;
    width: clamp(142px, 46vw, 180px);
    height: 100%;
  }
  .in-game .played .trick-card, .in-game .doubles .played .trick-card[data-position] {
    position: absolute;
    inset: auto;
    margin: 0;
    transform: none;
  }
  .in-game .played .trick-card[data-position='0'] { bottom: 0; left: 50%; transform: translateX(-50%); }
  .in-game .played .trick-card[data-position='1'] { top: 0; left: 50%; transform: translateX(-50%); }
  .in-game .doubles .played .trick-card[data-position='0'] { bottom: 0; left: 50%; transform: translateX(-50%); }
  .in-game .doubles .played .trick-card[data-position='2'] { top: 0; left: 50%; transform: translateX(-50%); }
  .in-game .doubles .played .trick-card[data-position='1'] { top: 50%; left: 0; transform: translateY(-50%); }
  .in-game .doubles .played .trick-card[data-position='3'] { top: 50%; right: 0; transform: translateY(-50%); }
  .in-game .trick-card .card { width: clamp(35px, 12cqh, 48px); height: clamp(49px, 16.8cqh, 67px); }
  .in-game .trick-card small { display: none; }
  .in-game .watermark { position: absolute; inset: 0; display: grid; align-content: center; }
  .in-game .my-hand {
    bottom: 48px;
    gap: 14px;
    height: auto;
    z-index: 2;
  }
  .in-game .my-hand .card {
    width: clamp(54px, 15cqh, 72px);
    height: clamp(76px, 21cqh, 101px);
    min-width: 0;
    min-height: 0;
  }
  .in-game .my-hand .card b { font-size: clamp(32px, 9cqh, 42px); }
  .in-game .my-hand .corner { font-size: 13px; }
  .in-game .card-button { touch-action: manipulation; border-radius: 7px; }
  .in-game .card-button:not(:disabled):active { transform: translateY(-8px); }
  .in-game .me { bottom: 9px; max-width: calc(100% - 80px); }
  .in-game .felt > .deck-area, .in-game .doubles > .deck-area {
    inset: auto 16px calc(64px + clamp(76px, 21cqh, 101px)) auto;
    width: 50px;
    height: 70px;
    transform: none;
  }
  .in-game .felt > .deck-area #vira { width: 50px; min-width: 50px; height: 70px; min-height: 70px; }
  .in-game .felt > .deck-area #vira b { font-size: 32px; }
  .in-game .felt > .deck-area #vira .corner { font-size: 12px; }
  .in-game .felt > .deck-area .deck { display: none; }
  .in-game .felt > .deck-area small { top: 76px; font-size: 9px; }
  .in-game .table-footer {
    flex: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 0;
    gap: 6px 10px;
    margin-top: 6px;
    padding: 6px 0 max(8px, env(safe-area-inset-bottom));
  }
  .in-game .table-footer > div:first-child { grid-column: 1 / -1; grid-row: 1; padding: 0; }
  .in-game .table-footer p {
    max-width: none;
    font-size: 12px;
    line-height: 1.4;
    margin: 0;
  }
  .in-game .table-footer #actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 48px;
    justify-content: flex-start;
  }
  .in-game .table-footer #actions button {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 48px;
    padding: 10px 8px;
    font-size: 13px;
    white-space: normal;
    touch-action: manipulation;
  }
  .in-game .table-footer #actions .afk-toggle { flex: 1 1 0; min-width: 0; }
  .in-game .table-footer .stake { font-size: 11px; margin: 0; }
  .in-game .table-footer > #leave, .in-game .table-footer #guide-toggle {
    grid-row: 3;
    width: 100%;
    min-width: 0;
    justify-self: stretch;
    min-height: 44px;
    padding: 8px;
    font-size: 12px;
    touch-action: manipulation;
  }
  .in-game .table-footer > #leave { grid-column: 1; }
  .in-game .table-footer #guide-toggle { grid-column: 2; }
  .in-game #card-guide { top: 8px; max-height: calc(100% - 16px); }
  .in-game .guide-heading button { min-width: 44px; min-height: 44px; }
}

/* Em telas baixas, preservar a mão antes de aumentar os elementos decorativos. */
@media (max-width: 600px) and (max-height: 650px) {
  .in-game .arena { padding-top: 5px; }
  .in-game .arena-top { gap: 3px 8px; padding-bottom: 5px; }
  .in-game .opponent { top: 7px; }
  .in-game .opponent small { display: none; }
  .in-game .opponent-cards { top: 43px; }
  .in-game .opponent-cards .card { width: 22px; min-width: 22px; height: 31px; min-height: 31px; }
  .in-game .side-seat { top: 26%; }
  .in-game .side-seat .mini-cards { display: none; }
  .in-game .table-center, .in-game .doubles .table-center { top: 44%; }
  .in-game .my-hand { bottom: 43px; gap: 12px; }
  .in-game .table-footer { gap: 4px 8px; margin-top: 4px; }
}

/* O toque não deve manter o efeito de hover depois de jogar uma carta. */
@media (hover: none) {
  .card-button:not(:disabled):hover { transform: none; }
}
