/* Preserve zoom, readable inputs and usable controls on narrow and touch screens. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
button, select { touch-action: manipulation; }
.game .tile { touch-action: pan-x pan-y pinch-zoom; -webkit-user-select: none; }
.brand, .brand-mark, .top-meta button { flex-shrink: 0; }
.brand { white-space: nowrap; }
.board, .rack, .chat-messages { -webkit-overflow-scrolling: touch; }
dialog { max-height: calc(100vh - 24px); max-height: calc(var(--visible-height, 100dvh) - 24px); overflow-y: auto; overscroll-behavior: contain; }
.result-score, .result-actions { min-width: 0; overflow-wrap: anywhere; }

@media (min-width: 900px) and (min-height: 620px) {
  body.in-game { height: 100vh; height: 100dvh; }
  .in-game #app { height: calc(100vh - 91px); height: calc(var(--smcho-game-height,100dvh) - 52px); }
}
@media (min-width: 900px) and (max-width: 1099px) and (min-height: 620px) {
  body.chat-open.in-game { height: auto; }
  .chat-open.in-game #app { height: auto; }
}
@media (max-width: 1099px), (pointer: coarse) {
  .field input, .chat-form textarea, .size-control select { font-size: 16px; }
  .game .insert { min-width: 32px; width: 32px; min-height: 40px; }
  .meld-head button { min-height: 32px; padding: 4px; }
  .game-heading .quiet, .size-control select, .rack-tools button, .move-tools button,
  .spectator-actions button, .result-actions button, .chat-heading button, .chat-compose-footer button { min-height: 40px; }
  .game .tile:hover:enabled { transform: none; }
  .game .tile.selected { transform: translateY(-2px); }
  .chat-form textarea { min-height: 64px; resize: none; }
  .chat-panel { scroll-margin: 12px; }
  .chat-open .chat-panel { height: 400px; height: min(440px, calc(var(--visible-height, 100dvh) - 20px)); min-height: 270px; }
  .chat-messages { min-height: 32px; }
}
@media (max-width: 899px) {
  .topbar, .in-game .topbar { height: auto; min-height: 52px; gap: 8px; padding: calc(8px + env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px)); }
  .brand, .in-game .brand { font-size: 14px; gap: 8px; letter-spacing: 1px; }
  .brand-mark, .in-game .brand-mark { width: 25px; height: 30px; font-size: 19px; }
  .top-meta { gap: 6px; }
  .top-meta button, .in-game .top-meta button { min-height: 40px; padding: 6px 8px; white-space: nowrap; font-size: 12px; }
  main, .in-game main { padding: 12px max(10px, env(safe-area-inset-right, 0px)) 12px max(10px, env(safe-area-inset-left, 0px)); }
  .entry h1 { font-size: 28px; }
  .panel { padding: 18px; }
  .seats { gap: 8px; }
  .seat { padding: 12px 8px; gap: 8px; }
  .seat > div { min-width: 0; }
  .seat .avatar { width: 28px; height: 28px; }
  .game-heading, .game-heading > div { min-width: 0; }
  .game-heading .table-options { gap: 6px; }
  .game-heading .quiet { padding: 6px 8px; }
  .table-options .room-code { letter-spacing: 1px; }
  .game { padding-bottom: calc(114px + env(safe-area-inset-bottom, 0px)); }
  .game.is-finished, .game.is-spectator { padding-bottom: env(safe-area-inset-bottom, 0px); }
  .game .player-name { font-size: 11px; }
  .table-bar { gap: 8px; }
  .board { height: 40vh; height: 40svh; min-height: 220px; }
  .rack { max-height: 24vh; max-height: 24svh; min-height: calc(var(--tile-height) + 16px); }
  .move-tools { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px; }
  .selection-count { grid-column: 1 / -1; }
  .move-tools button { padding: 6px; min-width: 0; }
  .turn-actions { position: fixed; left: 0; right: 0; bottom: 0; margin: 0; padding: 8px max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)); display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; z-index: 5; box-shadow: 0 -3px 12px #080b1040; }
  .turn-actions .validation { grid-column: 1 / -1; min-width: 0; max-height: 36px; overflow-y: auto; line-height: 18px; }
  .turn-actions button { min-height: 44px; min-width: 0; padding: 8px; }
  .chat-open .turn-actions, .input-focused .turn-actions { position: static; box-shadow: none; }
  .chat-open .game, .input-focused .game { padding-bottom: 0; }
  .chat-panel { margin-left: max(10px, env(safe-area-inset-left, 0px)); margin-right: max(10px, env(safe-area-inset-right, 0px)); margin-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .toast { bottom: calc(114px + env(safe-area-inset-bottom, 0px)); padding: 10px 14px; font-size: 12px; }
  .chat-open .toast, .input-focused .toast { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  dialog { padding: 18px; width: calc(100% - 24px); }
  .dialog-head { gap: 8px; }
  .dialog-head h2 { font-size: 17px; }
  .dialog-head button, .exit-actions button { min-height: 44px; }
}
@media (max-width: 899px) and (max-height: 500px) {
  .players { grid-template-columns: repeat(6,minmax(0,1fr)); }
  .game .player { padding: 5px; }
  .game .player-bottom { flex-wrap: wrap; }
  .board { min-height: 180px; height: 55svh; }
  .rack { max-height: 38svh; }
  .hold-hint { display: none; }
}
