/* ==========================================================================
   Imobiliário 1904 · palco em tela cheia (padrão NATAC, docs/ROADMAP-JOGOS.md)
   O tabuleiro em canvas ocupa a janela inteira; jogadores, ações, suas
   propriedades, troca e chat flutuam por cima com a mesma receita de painel.
   ========================================================================== */
body:has(.imob-stage) {
  --edge: 12px;
  --gap: 8px;
  --top-h: 44px;
  --left-w: 214px;
  --right-w: 300px;
  --toolbar-h: 56px;
  --hand-h: 112px;
  --dock-h: calc(var(--toolbar-h) + var(--gap) + var(--hand-h));
  --stage-top: calc(var(--edge) + var(--top-h) + var(--gap));
  --rail-top: var(--stage-top);
}
body:has(.imob-stage.hand-collapsed) {
  --hand-h: 38px;
}
body:has(.imob-stage.players-collapsed) {
  --left-w: 66px;
}
.game-viewport.canvas-table.imob-stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #e8dcc1;
}
.imob-stage > .table-play-area {
  position: absolute;
  inset: 0;
  display: block;
  padding: 0;
  margin: 0;
}
.game-viewport.canvas-table.imob-stage .game-map,
.game-viewport.canvas-table.imob-stage:has(.player-expanded) .game-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(
      ellipse at 50% 45%,
      rgb(173 209 160 / 0.5),
      rgb(173 209 160 / 0) 60%
    ),
    radial-gradient(circle at 50% 50%, #f1e6cf 0, #e2d3b2 100%);
  overflow: hidden;
}
.game-viewport.canvas-table.imob-stage .board-container {
  --board-safe-top: calc(var(--stage-top) + 4px);
  --board-safe-left: calc(var(--edge) + var(--left-w) + 12px);
  --board-safe-right: calc(var(--edge) + 12px);
  --board-safe-bottom: calc(var(--edge) + var(--dock-h) + 52px);
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}
body:has(#chat-panel:not([hidden])) .imob-stage .board-container,
.imob-stage:has(.imob-offer) .board-container,
.imob-stage:has(.game-drawer) .board-container {
  --board-safe-right: calc(var(--edge) + var(--right-w) + 12px);
}
.imob-stage .board-svg {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  cursor: grab;
  touch-action: none;
}
.imob-stage .board-svg [role="button"]:focus {
  outline: none;
}
/* --- Panel recipe ---------------------------------------------------------- */
.imob-stage > .game-topbar,
.imob-stage > .turn-notice,
.imob-stage .game-players,
.imob-stage .imob-view-controls,
.imob-stage .imob-actions,
.imob-stage .imob-dice,
.imob-stage .imob-hand,
.imob-stage .game-drawer,
.imob-stage .imob-offer,
.imob-stage .imob-toast {
  border: var(--mesa-panel-edge);
  box-shadow: var(--mesa-panel-shadow);
  -webkit-backdrop-filter: var(--mesa-panel-blur);
  backdrop-filter: var(--mesa-panel-blur);
  color: var(--mesa-ink);
}
/* --- Top row ---------------------------------------------------------------- */
.game-viewport.canvas-table.imob-stage > .game-topbar {
  position: absolute;
  top: var(--edge);
  left: var(--edge);
  right: auto;
  z-index: 6;
  display: flex;
  align-items: center;
  width: max-content;
  max-width: min(460px, calc(50% - 176px));
  height: var(--top-h);
  padding: 0 8px 0 14px;
  margin: 0;
  border-radius: var(--mesa-panel-radius);
  background: var(--mesa-panel-bg);
}
.imob-stage > .game-topbar h1 {
  min-width: 72px;
  flex: 0 1 auto;
}
.game-viewport.canvas-table.imob-stage .game-extras {
  margin: 0 0 0 4px;
}
.game-viewport.canvas-table.imob-stage > .turn-notice,
.game-viewport.canvas-table.imob-stage > .turn-notice.your-turn {
  position: absolute;
  top: var(--edge);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: min(640px, calc(100% - 2 * 450px));
  height: var(--top-h);
  min-height: 0;
  margin: 0;
  padding: 0 14px;
  border-radius: var(--mesa-panel-radius);
  background: var(--mesa-panel-bg-strong);
}
.game-viewport.canvas-table.imob-stage > .turn-notice.your-turn {
  border: 2px solid var(--player);
  background: color-mix(in srgb, var(--player) 13%, #fffaf0);
}
.imob-stage > .turn-notice p {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}
.imob-stage > .turn-notice strong {
  font-size: 15px;
  white-space: nowrap;
}
body[data-playing="true"]:has(.imob-stage) .room-social,
body[data-playing="true"].focus-mode:has(.imob-stage) .room-social {
  position: fixed;
  top: var(--edge);
  right: var(--edge);
  bottom: auto;
  left: auto;
  z-index: 16;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  width: 300px;
  max-width: calc(100vw - 24px);
}
body[data-playing="true"]:has(.imob-stage .game-drawer) .room-social {
  display: none;
}
body[data-playing="true"]:has(.imob-stage) .social-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin: 0;
}
body[data-playing="true"]:has(.imob-stage) .social-buttons .button {
  height: var(--top-h);
  min-height: 0;
  padding: 0 12px;
  border-radius: var(--mesa-panel-radius);
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--mesa-panel-shadow);
  -webkit-backdrop-filter: var(--mesa-panel-blur);
  backdrop-filter: var(--mesa-panel-blur);
}
body[data-playing="true"]:has(.imob-stage) .chat-panel {
  height: min(330px, 42dvh);
  min-height: 0;
  max-height: none;
  background: var(--mesa-panel-bg-strong);
  border-radius: var(--mesa-panel-radius);
}
body[data-playing="true"]:has(.imob-stage) .chat-messages {
  height: auto;
  min-height: 0;
}
/* --- Left: players ----------------------------------------------------------- */
.game-viewport.canvas-table.imob-stage .game-players {
  position: absolute;
  top: var(--stage-top);
  left: var(--edge);
  right: auto;
  bottom: auto;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: var(--left-w);
  max-height: calc(100% - var(--stage-top) - var(--edge) - 52px);
  padding: 6px;
  margin: 0;
  border-radius: calc(var(--mesa-panel-radius) + 4px);
  background: rgb(255 250 240 / 0.38);
  overflow-x: hidden;
  overflow-y: auto;
  pointer-events: auto;
}
.imob-stage .game-players > .game-player {
  flex-shrink: 0;
  box-shadow: none;
}
.imob-stage .imob-panel-toggle {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--mesa-panel-border);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--mesa-ink);
  font:
    800 13px/1 Bricolage,
    sans-serif;
  cursor: pointer;
}
.imob-stage .imob-panel-toggle:hover,
.imob-stage .imob-panel-toggle:focus-visible {
  border-color: #2446ed;
  color: #2446ed;
  outline: none;
}
.imob-stage .imob-players-toggle {
  align-self: flex-end;
  flex-shrink: 0;
  margin: -2px -2px -4px 0;
}
.imob-stage.players-collapsed .game-players {
  align-items: center;
}
.imob-stage.players-collapsed .imob-players-toggle {
  align-self: center;
  margin: 0;
}
.imob-stage.players-collapsed .game-player,
.imob-stage.players-collapsed .game-player.current-player {
  width: 52px;
  padding: 5px;
  border-left-width: 1.5px;
}
.imob-stage.players-collapsed .player-identity {
  justify-content: center;
}
.imob-stage.players-collapsed .player-identity > strong,
.imob-stage.players-collapsed .player-identity > .player-countdown,
.imob-stage.players-collapsed .player-metrics,
.imob-stage.players-collapsed .player-turn-label {
  display: none;
}
.imob-stage.players-collapsed .compact-score {
  display: grid;
  place-items: center;
  position: absolute;
  right: -6px;
  bottom: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #2446ed;
  color: #fffaf0;
  font:
    800 10px/1 Bricolage,
    sans-serif;
}
/* --- Bottom-left: board controls -------------------------------------------- */
.imob-stage .imob-view-controls {
  position: absolute;
  left: var(--edge);
  bottom: var(--edge);
  z-index: 6;
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--mesa-panel-radius);
  background: var(--mesa-panel-bg);
}
.imob-stage .imob-view-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--mesa-ink);
  cursor: pointer;
}
.imob-stage .imob-view-button .icon {
  width: 20px;
  height: 20px;
}
.imob-stage .imob-view-button:hover,
.imob-stage .imob-view-button:focus-visible {
  background: #2446ed14;
  border-color: #2446ed;
  color: #2446ed;
  outline: none;
}
.imob-stage .imob-view-button[aria-pressed="true"] {
  background: #2446ed;
  color: #fffaf0;
}
/* --- Bottom-centre dock: actions + own properties --------------------------- */
.game-viewport.canvas-table.imob-stage .game-dock {
  position: absolute;
  left: 50%;
  bottom: var(--edge);
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  width: min(
    880px,
    calc(100% - 2 * (var(--edge) + max(var(--left-w), 172px) + 16px))
  );
  height: auto;
  margin: 0;
  padding: 0;
  pointer-events: none;
}
.imob-stage .game-dock > * {
  pointer-events: auto;
}
.game-viewport.canvas-table.imob-stage .table-toolbar {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  gap: var(--gap);
  width: auto;
  max-width: 100%;
  height: var(--toolbar-h);
  min-height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}
.imob-stage .table-toolbar > * {
  pointer-events: auto;
}
.imob-stage .imob-dice,
.imob-stage .imob-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  margin: 0;
  padding: 0 10px;
  border-radius: var(--mesa-panel-radius);
  background: var(--mesa-panel-bg);
  min-width: 0;
}
.imob-stage .imob-actions {
  overflow-x: auto;
  scrollbar-width: thin;
}
.imob-stage .imob-actions > * {
  flex-shrink: 0;
}
.imob-stage .imob-dice .die {
  width: 28px;
  height: 28px;
  padding: 4px;
}
.imob-stage .imob-dice strong {
  min-width: 22px;
  font:
    800 18px/1 Bricolage,
    sans-serif;
  text-align: center;
}
.imob-stage .imob-dice.waiting-dice .die {
  opacity: 0.45;
}
.imob-stage .imob-waiting {
  padding: 0 6px;
  color: var(--mesa-ink-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.imob-stage .button.danger {
  background: #fde3dd;
  border-color: #b3261e;
  color: #8f1f17;
}
.imob-stage .imob-bid {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.imob-stage .imob-bid label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}
.imob-stage .imob-bid input {
  width: 92px;
  height: 34px;
  padding: 0 8px;
  font:
    800 15px/1 Bricolage,
    sans-serif;
}
/* Roll call: strong, in yellow, docked in the action bar. */
.imob-stage .imob-roll {
  position: relative;
  display: flex;
  height: 100%;
  border: 2px solid var(--mesa-ink);
  border-radius: var(--mesa-panel-radius);
  background: #ffda55;
  box-shadow:
    0 4px 0 var(--mesa-ink),
    0 10px 24px rgb(57 52 43 / 0.25);
  overflow: hidden;
}
.imob-stage .imob-roll-button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 0 12px 4px 10px;
  border: 0;
  background: transparent;
  color: var(--mesa-ink);
  cursor: pointer;
}
.imob-stage .imob-roll-button:focus-visible {
  outline: 3px solid #2446ed;
  outline-offset: -5px;
}
.imob-stage .imob-roll-dice {
  display: flex;
  gap: 5px;
}
.imob-stage .imob-roll-dice .die {
  width: 32px;
  height: 32px;
  padding: 5px;
  border-radius: 8px;
  border-width: 2px;
  box-shadow: 0 2px 0 var(--mesa-ink);
  animation: mesa-roll-invite 1.6s ease-in-out infinite;
}
.imob-stage .imob-roll-dice .die + .die {
  animation-delay: -0.8s;
}
.imob-stage .imob-roll-text {
  display: grid;
  justify-items: start;
  gap: 1px;
}
.imob-stage .imob-roll-text strong {
  font:
    800 17px/1 Bricolage,
    sans-serif;
}
.imob-stage .imob-roll-text span {
  font:
    800 12px/1.1 Bricolage,
    sans-serif;
  color: #1d3fc4;
  white-space: nowrap;
}
.imob-stage .imob-roll-timer {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1.5px solid var(--mesa-ink);
  border-radius: 999px;
  background: #fffaf0;
  font:
    800 13px/1 Bricolage,
    sans-serif;
  font-variant-numeric: tabular-nums;
}
.imob-stage .imob-roll-timer.urgent {
  color: #b3261e;
}
.imob-stage .imob-roll-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--mesa-ink) calc(var(--turn-remaining, 1) * 100%),
    rgb(57 52 43 / 0.18) 0
  );
}
/* Own properties: a horizontal row of small deeds. */
.game-viewport.canvas-table.imob-stage .imob-hand {
  position: relative;
  width: 100%;
  height: var(--hand-h);
  margin: 0;
  padding: 6px 12px 8px;
  border-radius: calc(var(--mesa-panel-radius) + 2px);
  background: rgb(255 250 240 / 0.88);
  overflow: hidden;
}
.imob-stage .imob-hand-heading {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 22px;
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--mesa-ink-muted);
}
.imob-stage .imob-hand-heading b {
  color: var(--mesa-ink);
  font:
    800 15px/1 Bricolage,
    sans-serif;
}
.imob-stage .imob-hand-heading .imob-panel-toggle {
  position: absolute;
  right: -4px;
  top: -1px;
}
.imob-stage.hand-collapsed .imob-cards {
  display: none;
}
.imob-stage .imob-cards {
  display: flex;
  gap: 6px;
  height: calc(100% - 26px);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
.imob-stage .imob-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  flex: 0 0 112px;
  height: 100%;
  min-height: 0;
  padding: 0 7px 6px;
  border: 1.5px solid var(--mesa-ink);
  border-radius: 9px;
  background: #fffaf0;
  color: var(--mesa-ink);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}
.imob-stage .imob-card:hover,
.imob-stage .imob-card:focus-visible,
.imob-stage .imob-card.is-open {
  border-color: #2446ed;
  box-shadow: 0 0 0 2px #2446ed55;
  outline: none;
}
.imob-stage .imob-card-band {
  display: block;
  align-self: stretch;
  height: 16px;
  margin: 0 -7px 2px;
  background: var(--group);
  color: #fffaf0;
  font:
    800 10px/16px Bricolage,
    sans-serif;
  letter-spacing: 1px;
  text-align: center;
}
.imob-stage .imob-card strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font:
    800 12px/1.15 Bricolage,
    sans-serif;
}
.imob-stage .imob-card small {
  font-size: 11px;
  color: var(--mesa-ink-muted);
}
.imob-stage .imob-card.is-mortgaged {
  background: repeating-linear-gradient(
    135deg,
    #f1e6cf 0 6px,
    #e5d6b6 6px 12px
  );
}
.imob-stage .imob-badges {
  display: flex;
  gap: 3px;
  margin-top: auto;
}
.imob-stage .imob-badge {
  padding: 1px 5px;
  border-radius: 6px;
  background: #2446ed;
  color: #fffaf0;
  font:
    800 10px/1.4 Bricolage,
    sans-serif;
}
.imob-stage .imob-badge.build {
  background: #2f8a57;
}
.imob-stage .imob-badge.warn {
  background: #b3261e;
}
.imob-stage .imob-empty {
  margin: 4px auto;
  color: var(--mesa-ink-muted);
  font-size: 13px;
  text-align: center;
}
/* Last table line: a short toast above the dock, never over the board. */
.imob-stage .imob-toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--edge) + var(--dock-h) + 12px);
  z-index: 9;
  max-width: min(560px, calc(100% - 2 * var(--edge)));
  padding: 8px 14px;
  border-radius: var(--mesa-panel-radius);
  background: var(--mesa-panel-bg-strong);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  animation: imob-toast 4.2s ease both;
}
@keyframes imob-toast {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  10%,
  78% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 4px);
  }
}
/* --- Right column: trade proposal under the chat ---------------------------- */
.imob-stage .imob-offer {
  position: absolute;
  top: var(--stage-top);
  right: var(--edge);
  z-index: 8;
  display: grid;
  gap: 6px;
  width: var(--right-w);
  padding: 12px 14px;
  border-radius: var(--mesa-panel-radius);
  background: var(--mesa-panel-bg-strong);
}
body[data-playing="true"]:has(#chat-panel:not([hidden]))
  .imob-stage
  .imob-offer {
  top: calc(var(--stage-top) + min(330px, 42dvh) + var(--gap));
}
.imob-stage .imob-offer p {
  margin: 0;
  font-size: 13px;
}
.imob-stage .imob-offer p span {
  display: inline-block;
  min-width: 58px;
  color: var(--mesa-ink-muted);
  font-weight: 700;
}
.imob-stage .imob-offer-actions {
  display: flex;
  gap: 6px;
}
.imob-stage .imob-offer-note {
  color: var(--mesa-ink-muted);
}
/* --- Drawers: property sheet and trade -------------------------------------- */
.game-viewport.canvas-table.imob-stage .game-drawer {
  position: absolute;
  top: var(--stage-top);
  right: var(--edge);
  bottom: auto;
  left: auto;
  z-index: 14;
  width: min(var(--right-w), calc(100% - 2 * var(--edge)));
  max-height: calc(100% - var(--stage-top) - var(--edge) - 52px);
  margin: 0;
  padding: 14px;
  transform: none;
  border-radius: calc(var(--mesa-panel-radius) + 4px);
  background: var(--mesa-panel-bg-strong);
  overflow-y: auto;
}
.imob-stage .game-drawer > .close-dialog {
  position: absolute;
  top: 8px;
  right: 8px;
}
.imob-stage .game-drawer h2 {
  margin: 0 28px 6px 0;
  font-size: 20px;
}
.imob-stage .imob-sheet-head {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}
.imob-stage .imob-sheet-band {
  flex: 0 0 10px;
  border-radius: 6px;
  background: var(--group);
}
.imob-stage .imob-sheet-head p {
  margin: 0;
  font-size: 13px;
}
.imob-stage .imob-sheet-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 0 0 8px;
  color: var(--mesa-ink-muted);
  font-size: 12px;
  font-weight: 700;
}
.imob-stage .imob-rents {
  display: grid;
  gap: 2px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  font-size: 13px;
}
.imob-stage .imob-rents li {
  display: flex;
  justify-content: space-between;
  padding: 3px 8px;
  border-radius: 6px;
}
.imob-stage .imob-rents li:nth-child(odd) {
  background: rgb(57 52 43 / 0.05);
}
.imob-stage .imob-rents li.is-current {
  background: color-mix(in srgb, var(--group) 22%, #fffaf0);
  font-weight: 800;
}
.imob-stage .imob-sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.imob-stage .imob-trade form {
  display: grid;
  gap: 10px;
}
.imob-stage .imob-trade label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}
.imob-stage .imob-trade-sides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.imob-stage .imob-trade fieldset {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 1.5px solid var(--mesa-panel-border);
  border-radius: 10px;
}
.imob-stage .imob-trade legend {
  padding: 0 4px;
  font-size: 12px;
  font-weight: 800;
}
.imob-stage .imob-trade input[type="number"] {
  width: 100%;
  height: 34px;
}
.imob-stage .imob-trade .imob-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px;
  border-left: 5px solid var(--group);
  border-radius: 6px;
  background: #fffaf0;
  font-weight: 600;
  font-size: 12px;
}
.imob-stage .imob-trade-note {
  margin: 0;
  color: var(--mesa-ink-muted);
  font-size: 12px;
}
.imob-stage .match-result {
  top: var(--stage-top);
  max-height: calc(100% - var(--stage-top) - var(--edge) - var(--dock-h) - 8px);
}
/* --- Lobby preview ------------------------------------------------------------ */
.imob-preview {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 12px;
  text-align: center;
}
.imob-preview-strip {
  display: flex;
  gap: 6px;
}
.imob-preview-strip span {
  width: 34px;
  height: 46px;
  border: 2px solid #39342b;
  border-top: 14px solid var(--group);
  border-radius: 6px;
  background: #fffaf0;
}
/* --- Medium desktop ----------------------------------------------------------- */
@media (min-width: 641px) and (max-width: 1239px) {
  body:has(.imob-stage) {
    --left-w: 190px;
    --right-w: 260px;
    --stage-top: calc(var(--edge) + var(--top-h) + var(--gap) + 38px);
  }
  body:has(.imob-stage.players-collapsed) {
    --left-w: 66px;
  }
  .game-viewport.canvas-table.imob-stage > .game-topbar {
    max-width: calc(100% - 2 * var(--edge) - 300px);
  }
  .game-viewport.canvas-table.imob-stage > .turn-notice,
  .game-viewport.canvas-table.imob-stage > .turn-notice.your-turn {
    top: calc(var(--edge) + var(--top-h) + var(--gap));
    left: var(--edge);
    transform: none;
    height: 32px;
    max-width: calc(100% - 2 * var(--edge) - var(--right-w) - var(--gap));
  }
  body[data-playing="true"]:has(.imob-stage) .room-social,
  body[data-playing="true"].focus-mode:has(.imob-stage) .room-social {
    width: 260px;
  }
  .game-viewport.canvas-table.imob-stage .game-dock {
    width: calc(100% - 2 * var(--edge) - 2 * 180px);
  }
}
@media (min-width: 641px) and (max-height: 760px) {
  body:has(.imob-stage) {
    --toolbar-h: 50px;
    --hand-h: 100px;
  }
  body:has(.imob-stage.hand-collapsed) {
    --hand-h: 38px;
  }
}
/* --- Phones: board behind everything, panels as bars, drawers as sheets ----- */
@media (max-width: 640px) {
  body:has(.imob-stage) {
    --edge: 8px;
    --gap: 6px;
    --top-h: 40px;
    --left-w: 0px;
    --right-w: calc(100vw - 16px);
    --toolbar-h: 48px;
    --hand-h: 106px;
    --stage-top: calc(var(--edge) + var(--top-h) + var(--gap));
    --rail-top: calc(var(--stage-top) + 34px + var(--gap));
  }
  body:has(.imob-stage.hand-collapsed) {
    --hand-h: 36px;
  }
  /* The roll call takes its own row above the other actions. */
  body:has(.imob-stage .imob-roll) {
    --toolbar-h: calc(48px * 2 + 4px);
  }
  .game-viewport.canvas-table.imob-stage .table-toolbar:has(.imob-roll) {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .imob-stage .imob-roll {
    flex: 1 0 100%;
    height: 48px;
  }
  .imob-stage .imob-roll-button {
    width: 100%;
    justify-content: space-between;
  }
  .imob-stage .table-toolbar > :not(.imob-roll) {
    height: 48px;
  }
  .game-viewport.canvas-table.imob-stage .board-container,
  body:has(#chat-panel:not([hidden])) .imob-stage .board-container,
  .imob-stage:has(.imob-offer) .board-container,
  .imob-stage:has(.game-drawer) .board-container {
    --board-safe-top: calc(var(--rail-top) + 56px);
    --board-safe-left: 2px;
    --board-safe-right: 2px;
    --board-safe-bottom: calc(var(--edge) + var(--dock-h) + 48px);
  }
  body[data-playing="true"]:has(.imob-stage) #fullscreen-toggle::before {
    content: none;
  }
  .game-viewport.canvas-table.imob-stage > .game-topbar {
    left: var(--edge);
    right: var(--edge);
    width: auto;
    max-width: none;
    padding: 0 88px 0 10px;
    gap: 6px;
  }
  .game-viewport.canvas-table.imob-stage > .turn-notice,
  .game-viewport.canvas-table.imob-stage > .turn-notice.your-turn {
    top: var(--stage-top);
    left: var(--edge);
    right: var(--edge);
    transform: none;
    width: auto;
    max-width: none;
    height: 34px;
    padding: 0 10px;
    gap: 8px;
  }
  .imob-stage > .turn-notice p {
    font-size: 12px;
  }
  .imob-stage > .turn-notice strong {
    font-size: 13px;
  }
  body[data-playing="true"]:has(.imob-stage) .room-social,
  body[data-playing="true"].focus-mode:has(.imob-stage) .room-social {
    top: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    gap: 0;
  }
  body[data-playing="true"]:has(.imob-stage) .social-buttons .button {
    width: 36px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: 10px;
    font-size: 0;
    box-shadow: none;
  }
  body[data-playing="true"]:has(.imob-stage) .social-buttons .button .icon {
    width: 19px;
    height: 19px;
  }
  body[data-playing="true"]:has(.imob-stage) .chat-panel {
    position: fixed;
    left: var(--edge);
    right: var(--edge);
    bottom: calc(var(--edge) + var(--dock-h) + var(--gap));
    top: auto;
    width: auto;
    height: min(
      52dvh,
      calc(100dvh - var(--rail-top) - var(--dock-h) - 3 * var(--edge))
    );
    border-radius: 18px;
    z-index: 40;
    background: rgb(255 250 240 / 0.95);
  }
  .game-viewport.canvas-table.imob-stage .game-players {
    top: var(--rail-top);
    left: var(--edge);
    right: var(--edge);
    flex-direction: row;
    width: auto;
    max-height: none;
    padding: 0;
    gap: 6px;
    border: 0;
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .game-viewport.canvas-table.imob-stage .game-players:has(.player-expanded) {
    overflow-y: visible;
  }
  .imob-stage .imob-players-toggle {
    display: none;
  }
  .game-viewport.canvas-table.imob-stage .imob-view-controls {
    left: auto;
    right: var(--edge);
    bottom: calc(var(--edge) + var(--dock-h) + var(--gap));
    padding: 2px;
  }
  .imob-stage .imob-view-button {
    width: 34px;
    height: 34px;
  }
  .game-viewport.canvas-table.imob-stage .game-dock {
    left: var(--edge);
    right: var(--edge);
    bottom: calc(var(--edge) + env(safe-area-inset-bottom, 0px));
    transform: none;
    width: auto;
  }
  .game-viewport.canvas-table.imob-stage .table-toolbar {
    gap: 4px;
    width: 100%;
  }
  .imob-stage .imob-dice {
    padding: 0 6px;
  }
  .imob-stage .imob-dice .die {
    width: 22px;
    height: 22px;
    padding: 3px;
  }
  .imob-stage .imob-dice strong {
    font-size: 15px;
  }
  .imob-stage .imob-actions {
    flex: 1 1 auto;
    padding: 0 6px;
  }
  .imob-stage .imob-roll-dice .die {
    width: 26px;
    height: 26px;
    padding: 4px;
  }
  .imob-stage .imob-toast {
    bottom: calc(var(--edge) + var(--dock-h) + 50px);
    max-width: calc(100% - 2 * var(--edge));
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
  }
  .imob-stage .imob-card {
    flex-basis: 100px;
  }
  .imob-stage .imob-offer,
  body[data-playing="true"]:has(#chat-panel:not([hidden]))
    .imob-stage
    .imob-offer {
    top: auto;
    left: var(--edge);
    right: var(--edge);
    bottom: calc(var(--edge) + var(--dock-h) + var(--gap));
    width: auto;
  }
  .game-viewport.canvas-table.imob-stage .game-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: min(80dvh, calc(100% - var(--stage-top)));
    padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 20px 20px 0 0;
    z-index: 30;
  }
  .imob-stage .match-result {
    top: var(--stage-top);
    left: var(--edge);
    right: var(--edge);
    max-height: calc(100% - var(--stage-top) - var(--edge));
  }
}
@media (prefers-reduced-motion: reduce) {
  .imob-stage .imob-roll-dice .die,
  .imob-stage .imob-toast {
    animation: none;
  }
}
.imob-stage .imob-trade .imob-pick input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
}
