/* Rasante no celular (carregado por último).
   Em pé: tudo cabe na tela sem rolar, palco no meio e um botão de saque grande embaixo.
   Deitado: palco à esquerda, placar e controles numa coluna à direita. */

html { -webkit-text-size-adjust: 100%; }
/* Jogo, não documento: tocar num texto não seleciona nem abre a busca do Google (o Chrome do Android faz isso) */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, .fair-code, .fair-history-list code { -webkit-user-select: text; user-select: text; }
button, .action-btn, .mode-tab, .diff-card, .seg-btn, .preset-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.action-btn { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.app-shell > *, .duel-hud > *, .cockpit-grid > *, .control-body > * { min-width: 0; }
.fighter-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sem teclado físico: esconde as dicas de tecla */
@media (hover: none) and (pointer: coarse) {
  .shortcut-badge, .local-keys-info { display: none !important; }
}

/* ===================== Celular em pé ===================== */
@media (max-width: 640px) {
  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    gap: 6px;
    grid-template-rows: auto auto minmax(180px, 1fr) auto;
  }

  /* Topo: marca + ações só com ícone */
  .topbar { padding: 6px 8px; gap: 6px; border-radius: 12px; }
  .brand { gap: 6px; }
  .brand-duel-badge, .engine-pill, .history-strip { display: none; }
  .brand-title { font-size: 1.15rem; }
  .topbar-actions { gap: 6px; margin-left: auto; }
  .icon-btn, .primary-sm-btn { min-width: 40px; min-height: 40px; padding: 6px 10px; justify-content: center; }

  /* Placar: J1 | rodada | J2 numa linha só */
  .duel-hud { grid-template-columns: 1fr auto 1fr; gap: 6px; }
  .round-center-card { order: 0; grid-column: auto; min-width: 0; padding: 6px 8px; gap: 4px; border-radius: 12px; }
  .round-badge { font-size: 0.68rem; white-space: nowrap; }
  .round-dots { gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 92px; }
  .round-dots > * { width: 16px; height: 16px; font-size: 0.6rem; }
  .overtime-badge { font-size: 0.6rem; }
  .room-code-bar { flex-direction: column; gap: 2px; font-size: 0.7rem; }
  .fighter-card { padding: 7px 9px; gap: 4px; border-radius: 12px; }
  .fighter-header { flex-direction: column; align-items: flex-start; gap: 2px; }
  .fighter-card.p2 .fighter-header { align-items: flex-end; }
  .fighter-card.p2 .fighter-meta { justify-content: flex-end; }
  .fighter-identity { gap: 5px; max-width: 100%; }
  .fighter-name { font-size: 0.85rem; }
  .score-value { font-size: 1.35rem; }
  .fighter-meta { gap: 4px; }
  .status-pill { font-size: 0.62rem; padding: 2px 6px; }
  .target-hint { display: none; }

  /* Palco ocupa o que sobrar */
  .stage-wrapper { min-height: 180px; height: auto; border-radius: 14px; }
  .stage-seed-pill { display: none; }
  .live-multiplier { font-size: clamp(2.6rem, 14vw, 3.6rem); }
  .countdown-timer { font-size: 2.4rem; }
  .countdown-sub { display: none; }
  .crashed-multiplier { font-size: 2.6rem; }
  .crashed-seed-tag { display: none; }
  .overlay-waiting h2 { font-size: 1.1rem; }

  /* Controles: o botão de saque é o que importa */
  .cockpit-grid { grid-template-columns: 1fr; gap: 6px; }
  .control-card { padding: 8px; border-radius: 14px; gap: 6px; }
  .control-top-row { display: none; }
  .control-body { grid-template-columns: 1fr; gap: 6px; }
  .action-btn { min-height: 76px; border-radius: 16px; }
  .btn-main-text { font-size: 1.15rem; }
  .auto-cashout-box { padding: 6px 8px; gap: 6px; }
  .auto-header { gap: 8px; }
  .preset-row { gap: 4px; }
  .preset-btn { min-height: 34px; }

  /* Contra bot / online: o painel do adversário sai (o placar de cima já mostra o status dele)
     e o espaço vai para o palco */
  body:not([data-mode="local"]) #p2-control-card { display: none; }

  /* Mesma tela: dois botões lado a lado, sem auto-saque (cada um com um polegar) */
  body[data-mode="local"] .cockpit-grid { grid-template-columns: 1fr 1fr; }
  body[data-mode="local"] .auto-cashout-box { display: none; }
  body[data-mode="local"] .action-btn { min-height: 96px; }

  /* Lobby em pé: cabe sem rolar muito e o botão de jogar fica sempre à mão */
  .lobby-clouds { display: none; }
  .lobby-layout { padding: max(14px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); gap: 10px; }
  .lobby-logo { font-size: 2.7rem; }
  .lobby-tagline { font-size: 0.85rem; margin-top: 4px; }
  .lobby-plane { width: 210px; margin: -6px 0 -10px; }
  .pilot-card { padding: 10px; gap: 8px; border-radius: 14px; }
  .pilot-card .field-group label { font-size: 0.72rem; }
  .lobby-panel.modal-card { padding: 12px; border-radius: 18px; overflow: visible; }
  .lobby-screen .mode-tabs { gap: 6px; }
  .lobby-screen .mode-tab { padding: 8px 4px; font-size: 0.85rem; border-radius: 12px; }
  .lobby-screen .mode-tab .tab-ico { font-size: 1.3rem; }
  .lobby-screen .difficulty-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .lobby-screen .diff-card { padding: 8px 4px; gap: 2px; }
  .lobby-screen .diff-card small { display: none; }
  .lobby-screen .diff-emoji { font-size: 1.3rem; }
  .lobby-screen .cta-btn {
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 5;
    font-size: 1.15rem;
    padding: 14px;
  }
  .lobby-rules-footer { font-size: 0.75rem; }

  /* Pódio */
  .podium-card { padding: 14px; max-height: calc(100dvh - 24px); overflow-y: auto; }
  .trophy-3d { width: 130px; height: 130px; }
  .podium-scores { gap: 8px; }
  .podium-actions { flex-direction: column; }
}

/* ===================== Celular deitado ===================== */
@media (orientation: landscape) and (max-height: 520px) {
  .app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    max-width: none;
    padding: 6px max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 34%);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas:
      "top top"
      "stage hud"
      "stage cockpit";
  }
  .topbar { grid-area: top; padding: 4px 8px; gap: 6px; border-radius: 10px; }
  .brand-duel-badge, .engine-pill { display: none; }
  .brand-title { font-size: 1.05rem; }
  .icon-btn, .primary-sm-btn { min-height: 34px; padding: 4px 10px; }
  .hide-sm { display: none; }

  .stage-wrapper { grid-area: stage; min-height: 0; height: auto; border-radius: 14px; }
  .stage-seed-pill, .countdown-sub, .crashed-seed-tag { display: none; }
  .live-multiplier { font-size: 3rem; }

  .duel-hud { grid-area: hud; grid-template-columns: 1fr 1fr; gap: 6px; }
  .round-center-card { grid-column: 1 / -1; order: -1; min-width: 0; padding: 4px 8px; flex-direction: row; gap: 8px; border-radius: 10px; }
  .round-dots > * { width: 16px; height: 16px; font-size: 0.6rem; }
  .fighter-card { padding: 6px 8px; gap: 2px; border-radius: 10px; }
  .score-value { font-size: 1.2rem; }
  .fighter-name { font-size: 0.8rem; }
  .target-hint { display: none; }

  .cockpit-grid { grid-area: cockpit; grid-template-columns: 1fr; gap: 6px; align-content: end; }
  .control-card { padding: 6px; gap: 4px; border-radius: 12px; }
  .control-top-row { display: none; }
  .control-body { grid-template-columns: 1fr; gap: 4px; }
  .action-btn { min-height: 64px; }
  .auto-cashout-box { padding: 4px 6px; gap: 4px; }
  .preset-row { display: none; }
  body:not([data-mode="local"]) #p2-control-card { display: none; }
  body[data-mode="local"] .cockpit-grid { grid-template-columns: 1fr 1fr; }
  body[data-mode="local"] .auto-cashout-box { display: none; }

  /* Lobby deitado: duas colunas baixas */
  .lobby-clouds { display: none; }
  .lobby-layout { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 14px; padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left)); align-items: start; }
  .lobby-logo { font-size: 2.4rem; }
  .lobby-tagline { font-size: 0.8rem; margin-top: 2px; }
  .lobby-plane { width: 170px; margin: -10px 0 -14px; }
  .pilot-card { padding: 8px; gap: 6px; }
  .lobby-panel.modal-card { padding: 10px; overflow: visible; }
  .lobby-screen .mode-tab { padding: 6px 4px; font-size: 0.85rem; }
  .lobby-screen .mode-tab .tab-ico { font-size: 1.1rem; }
  .lobby-screen .difficulty-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .lobby-screen .diff-card { padding: 6px 4px; }
  .lobby-screen .diff-card small { display: none; }
  .lobby-screen .cta-btn { padding: 10px; font-size: 1.05rem; }
  .lobby-rules-footer { display: none; }

  .podium-card { max-height: calc(100dvh - 16px); overflow-y: auto; }
  .trophy-3d { width: 100px; height: 100px; }
}

/* Auto Saque: a linha inteira é área de toque (antes o alvo tinha 18 px, colado no botão SACAR) */
.auto-header { min-height: 44px; }
.switch-label { min-height: 44px; flex: 1; padding-right: 8px; font-size: 0.9rem; -webkit-tap-highlight-color: transparent; }
@media (hover: none) and (pointer: coarse) {
  .switch-slider { width: 44px; height: 26px; }
  .switch-slider::after { width: 20px; height: 20px; top: 3px; left: 3px; }
  .switch-label input:checked + .switch-slider::after { transform: translateX(18px); }
  .mult-input-wrap input { min-height: 36px; font-size: 16px; } /* 16px evita o zoom automático do iOS */
}
