/* ==========================================================================
   UnderPaint — refonte mobile (≤ 640 px), chargée en dernier
   Écrans : global · fenêtres en « feuilles » · accueil · salon · jeu · vote · fin · paysage
   ========================================================================== */
@media (max-width:640px){

  /* ---------- Global ---------- */
  main#app{padding:calc(12px + env(safe-area-inset-top)) 12px calc(96px + env(safe-area-inset-bottom)) 12px}
  .case-file{padding:18px 14px 16px;border-width:3px;border-radius:18px;box-shadow:0 5px 0 var(--ink)}
  .case-file::before,.case-file::after{display:none}
  input[type="text"],input[type="number"],input[type="password"],select,textarea{min-height:48px;font-size:16px}
  textarea{min-height:0}
  .btn-primary{min-height:50px;font-size:16px}
  .btn-secondary{min-height:44px}
  .hint,.detail{font-size:13px;line-height:1.45}
  h2,.section-title{font-size:23px}

  /* ---------- Fenêtres : « feuilles » ancrées en bas ---------- */
  .skin-modal,.cx-page,.ac-modal,.rp-modal{align-items:flex-end;padding:0}
  .skin-panel,.cx-dialog,.ac-panel{width:100%;max-width:none;max-height:92vh;max-height:92dvh;border-radius:22px 22px 0 0;border-bottom-width:0;box-shadow:0 -6px 0 var(--ink);animation:sheet-up .3s cubic-bezier(.2,.9,.3,1)}
  .skin-panel,.ac-panel{padding:16px 16px calc(18px + env(safe-area-inset-bottom))}
  .skin-panel::before,.ac-panel::before{content:'';display:block;width:44px;height:5px;margin:0 auto 12px;border-radius:5px;background:rgba(36,28,61,.22)}
  .cx-content{padding-bottom:calc(18px + env(safe-area-inset-bottom))}
  @keyframes sheet-up{from{transform:translateY(46px);opacity:.5}}
  .ud-overlay{padding:14px}
  .ban-card{padding:20px 16px 18px}
  .ban-card h2{font-size:30px}

  /* ---------- Accueil ---------- */
  .brand-title{font-size:34px}
  .home-quick{display:block;margin:0 0 10px}
  .home-quick>*{margin:0!important;width:100%;min-width:0;padding:5px 10px 5px 6px;box-shadow:0 3px 0 var(--ink)}
  .home-quick .skin-chip-arrow{display:none}
  .home-quick .skin-chip-face{width:36px;height:36px;font-size:22px}
  .home-quick .skin-chip-text strong{display:none}
  .home-quick .skin-chip-text small{font-size:13px;font-weight:800;letter-spacing:0;text-transform:none;color:var(--ink)}
  .home-topbar{margin:0 0 8px}
  .home-topbar .ac-text strong{max-width:120px}
  .soon-note{margin-top:10px;font-size:12.5px}
  .howto{margin:0 0 10px;padding:8px 12px}
  .howto-toggle{pointer-events:auto;cursor:pointer;font-size:17px;display:flex;align-items:center;justify-content:space-between}
  .howto-toggle::after{content:'▾';font-size:16px;transition:transform .2s}
  .howto.open .howto-toggle::after{transform:rotate(180deg)}
  .howto-body{display:none;margin-top:6px}
  .howto.open .howto-body{display:block}
  .crate-banner{margin:0 0 10px;padding:8px 12px}
  .crate-banner .cb-icon{font-size:28px}.crate-banner .cb-text b{font-size:20px}.crate-banner .cb-text small{display:none}
  .solo-link{margin:-2px 0 10px;padding:4px;font-size:12.5px}
  .tabs{margin-bottom:10px}.tab{flex:1;font-size:14px}

  /* ---------- Salon ---------- */
  .host-settings{gap:10px}
  .host-settings .row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
  #btn-start{position:sticky;bottom:calc(64px + env(safe-area-inset-bottom));z-index:15;box-shadow:0 5px 0 var(--ink),0 0 0 7px var(--paper)}
  .lobby-hint{font-size:12.5px;margin:4px 0 8px}
  .crate-link{align-self:center}

  /* ---------- Jeu ---------- */
  .game-header{position:sticky;top:calc(6px + env(safe-area-inset-top));z-index:30;padding:8px 10px;background:var(--paper);border:2.5px solid var(--ink);border-radius:14px;box-shadow:0 3px 0 var(--ink)}
  .game-header .timer{font-size:30px;min-width:58px}
  .turn-status{font-size:14px;font-weight:700;text-align:center;line-height:1.35}
  .canvas-wrap{margin:0 -4px 10px;padding:4px}
  .canvas-wrap canvas{-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}
  #game-players li{padding:6px 10px;font-size:13.5px}

  /* ---------- Vote ---------- */
  #vote-players li{display:flex;align-items:center;gap:8px;padding:6px 6px 6px 10px}
  #vote-players li button{margin-left:auto;min-height:44px;padding:8px 16px;font-size:14px}

  /* ---------- Fin de partie ---------- */
  .recap{gap:12px}
  .more-btn{min-height:46px}
  .reward-line{padding:8px 10px}

  /* ---------- Éléments flottants plus discrets ---------- */
  .dd-tab{top:30%;padding:9px 5px}.dd-ico{font-size:19px}.dd-txt{font-size:11px}
  .a2hs{padding:10px 12px;font-size:13px;gap:8px}
  .toast,.net-banner{max-width:92vw;font-size:13px}
}

/* ---------- Très petits écrans ---------- */
@media (max-width:360px){
  main#app{padding-left:8px;padding-right:8px}
  .case-file{padding:14px 10px 14px}
  .brand-title{font-size:30px}
}

/* ---------- Paysage (téléphone couché) ---------- */
@media (max-height:480px) and (orientation:landscape){
  .skin-panel,.cx-dialog,.ac-panel{max-height:96vh;max-height:96dvh}
  .game-header{top:calc(2px + env(safe-area-inset-top))}
  #btn-start{bottom:calc(10px + env(safe-area-inset-bottom))}
}

/* ==========================================================================
   Ergonomie tactile (loi de Fitts) : grandes cibles, actions au pouce, rien qui bouge
   ========================================================================== */
@media (max-width:640px){
  /* Cibles d'au moins 44 px */
  .tab{min-height:48px}
  .witness-list li button,.kick-btn{min-height:40px}
  .witness-list li button.report-btn,.recap-list .report-btn{min-width:40px;min-height:40px}
  .react-toggle{width:46px;height:46px}.react-bar button[data-emoji]{width:44px;height:44px;font-size:22px}
  .char-grid button{min-height:52px}
  .skin-tabs button,.cx-tabs button{min-height:44px}
  .more-btn,.ts-chip{min-height:48px}
  .link-btn{min-height:44px}

  /* Actions principales dans la zone du pouce : pied collant */
  .skin-panel .skin-ok{position:sticky;bottom:0;margin-top:10px;box-shadow:0 4px 0 var(--ink),0 0 0 8px var(--paper)}

  /* Mise en page stable : on réserve la place des textes qui apparaissent */
  .turn-status{display:flex;align-items:center;justify-content:center;min-height:44px}
  .lobby-hint{min-height:2.6em}
  #spectator-count{min-height:0}

  /* Crates : tout tient à l'écran, le bouton reste fixe en bas */
  .cx-dialog{max-height:94vh;max-height:94dvh}
  .cx-top{padding:10px 12px}
  .cx-content{gap:10px;padding:10px 12px 12px}
  .cx-crates{gap:8px}
  .cx-crate{padding:10px 6px 10px}
  .cx-crate .cx-box-svg{width:64px;height:64px}
  .cx-crate b{font-size:17px}.cx-crate small{font-size:10.5px}
  .cx-crate.on::after{display:none}
  .cx-wheel{height:112px}
  .cx-strip{padding:8px 0}
  .cx-ri{flex-basis:76px;height:96px}.cx-ri .cx-emoji{font-size:36px}.cx-ri .cx-mini{width:42px;height:60px}.cx-ri .cx-cur{width:44px;height:44px}
  .cx-slot{min-height:112px}
  .cx-reveal.compact{padding:10px 12px;gap:12px}
  .cx-reveal.compact .cx-emoji{font-size:46px}.cx-info .cx-name{font-size:21px}
  .cx-foot{padding:10px 12px calc(12px + env(safe-area-inset-bottom))}
  .cx-foot>*{min-height:56px}

  /* Récompenses quotidiennes : bouton rond + feuille du bas (au lieu d'un volet qui recouvre le menu) */
  .dd-tab{top:auto;left:12px;bottom:calc(14px + env(safe-area-inset-bottom));width:54px;height:54px;padding:0;flex-direction:row;justify-content:center;border:3px solid var(--ink);border-radius:50%;box-shadow:0 4px 0 var(--ink)}
  .dd-tab:hover{padding:0;transform:none}
  .dd-txt{display:none}.dd-ico{font-size:26px}
  .dd-dot{top:-3px;right:-3px}
  .dd-drawer{top:auto;left:0;right:0;bottom:0;width:100%;max-height:86vh;max-height:86dvh;padding:18px 14px calc(18px + env(safe-area-inset-bottom));border-right:0;border-top:4px solid var(--ink);border-radius:22px 22px 0 0;box-shadow:0 -6px 0 var(--ink);transform:translateY(106%)}
  .dd-drawer.open{transform:none}
  .dd-drawer::before{content:'';display:block;width:44px;height:5px;margin:-6px auto 10px;border-radius:5px;background:rgba(36,28,61,.22)}
  .dd-x{top:12px;right:12px}
  .dd-drawer .daily-box{margin-top:6px}
  .dr-head h3{font-size:19px}.dr-sub{display:none}
  .dr-day{min-height:96px}
  .dr-claim{position:sticky;bottom:0}

  /* Animations lourdes coupées sur mobile (fluidité, batterie) */
  .crate-banner,.cx-bar .r-mythic,.cx-bar .r-legendary{animation:none}
}
