/* Mise en page téléphone : l'écran de jeu occupe tout l'écran, le jeu est mis à l'échelle par fit() (app.js) */
.rotate-hint { display: none; }

@media (max-width: 700px), (max-height: 500px) and (pointer: coarse) {
  body:has(#game:not([hidden])) { overflow: hidden; }
  #game:not([hidden]) { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
  #game header { flex: none; display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; min-height: 48px; padding: 6px 56px 6px 8px; }
  #game header .btn { flex: none; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
  #game h2 { flex: 0 1 auto; min-width: 0; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .game-players { order: 0; flex: 1 1 0; min-width: 0; max-width: none; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #gameHelp, #fsBtn { display: none; }
  #stage { flex: 1 1 0; min-height: 0; height: auto !important; padding: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
  #stage > * { flex: none; }

  /* bouton son unique, dans l'en-tête */
  body:has(#game:not([hidden])) .snd { top: 6px; right: 8px; bottom: auto; }
  body:has(#game:not([hidden])) .snd button { width: 40px; height: 40px; }
  body:has(#game:not([hidden])) .snd button:not(:first-child) { display: none; }
  body:has(#game:not([hidden])) .snd-toast { top: 54px; bottom: auto; }
  body:has(#game:not([hidden])) .snd-panel { top: 54px; bottom: auto; }

  .snake-wrap { width: min(630px, calc(100vw - 12px)); }
  .snake-wrap canvas { width: 100%; height: auto; }
  .tetris-wrap { width: min(410px, calc(100vw - 12px)); }
  .mines-wrap { gap: 8px; width: calc(100vw - 12px); }
  .mines-wrap .row { flex-wrap: wrap; justify-content: center; gap: 6px; }
  .mines-wrap .row .btn { padding: 8px 12px; font-size: 13px; }

  /* Patience */
  .sol { --gap: 4px; --cw: calc((100vw - 12px - 6 * var(--gap)) / 7); width: calc(100vw - 12px); }
  .sol .bar { gap: 6px; }

  /* Petits Chevaux */
  .horses-wrap { width: calc(100vw - 12px); min-width: 0; flex-direction: column; align-items: stretch; gap: 8px; }
  .horses-wrap.is-setup { width: min(420px, calc(100vw - 24px)); }
  .horses-wrap canvas { width: 100%; height: auto; aspect-ratio: 1; }
  .hp-board { width: 100%; height: auto; aspect-ratio: 1; }
  .hp-panel { width: 100%; flex: none; height: auto; display: grid; grid-template-columns: 1fr 120px; gap: 8px; padding: 10px; }
  .hp-turn { grid-column: 1; grid-row: 1; padding: 8px 10px; }
  .hp-msg { grid-column: 1; grid-row: 2; min-height: 46px; }
  .hp-panel .dice-stage { grid-column: 2; grid-row: 1 / span 2; height: 100px; }
  .hp-roll { grid-column: 1 / -1; grid-row: 3; }
  .hp-list { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .hp-tools { grid-column: 1 / -1; margin-top: 0; }

  /* Nuée Stellaire */
  .swarm-wrap { width: calc(100vw - 12px); }
  .swarm-wrap canvas { width: 100%; height: auto; }
  .swarm-hud { flex-wrap: wrap; justify-content: center; padding: 4px 6px; }
  .swarm-wrap:has(.sw-levels:not([hidden])) { min-height: 480px; }
  .sw-levels { padding: 12px 10px; overflow-y: auto; gap: 8px; }
  .sw-levels h3 { font-size: 24px; }
  .sw-row { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .sw-gal { width: 100%; }
  .sw-cells { flex-wrap: wrap; gap: 8px; }
  .lv { width: 46px; height: 46px; font-size: 17px; }
}

@media (max-width: 700px) and (orientation: portrait) {
  .rotate-hint { display: block; padding: 6px 10px; border-radius: 10px; background: #ffc75f22; border: 1px solid #ffc75f55; color: #ffe29a; font-size: 12px; text-align: center; }
}

/* Téléphone en paysage : plateau à gauche, panneau à droite */
@media (max-height: 500px) and (pointer: coarse) and (orientation: landscape) {
  #game header { min-height: 40px; padding-top: 3px; padding-bottom: 3px; }
  .horses-wrap { width: auto; flex-direction: row; align-items: center; gap: 10px; }
  .horses-wrap.is-setup { width: min(420px, calc(100vw - 24px)); flex-direction: column; }
  .horses-wrap canvas, .hp-board { width: calc(100vh - 70px); width: calc(100dvh - 70px); height: auto; }
  .hp-panel { width: 290px; }
  .hp-panel .dice-stage { height: 90px; }
  .swarm-wrap { width: min(960px, calc(100vw - 12px)); }
  .snd-toast { top: 46px; }
}
