/* ============================================================================
   ÉCRAN DE PARTIE SUR TÉLÉPHONE (V308) — tout l'écran visible, plateau inchangé
   ----------------------------------------------------------------------------
   Retour de Tony sur Android : le bas de l'écran (rangée Accueil / Reprendre / Passer /
   Échanger / Chat) était coupé, et le bandeau « Dernier coup » chevauchait parfois les mots.
   Consigne : NE PAS toucher à la taille du plateau, réduire les espaces ailleurs.

   Trois causes, trois corrections :
   1. La colonne de jeu mesurait 100vh. Sur Chrome Android, 100vh est la hauteur de l'écran
      SANS la barre d'adresse : avec la barre affichée, le bas de la colonne passait sous le
      bord de l'écran, et comme elle ne défilait pas (overflow:hidden), il était inatteignable.
      La hauteur suit désormais la zone réellement visible (100dvh) ; si un écran très court ne
      peut vraiment pas tout contenir, la colonne défile au lieu de couper.
   2. Le bandeau « Dernier coup » occupait 90 à 115 px sur trois lignes (étiquette, joueur,
      mots en très gros). Il tient maintenant sur UNE ligne : joueur, mots (défilables d'un
      glissement s'ils sont nombreux), points. Le texte n'est plus agrandi par le navigateur
      (text-size-adjust) : c'est ce grossissement automatique qui faisait chevaucher le pseudo
      et les mots.
   3. Les marges et hauteurs fixes (rangée d'icônes 44 px, bandeau des scores 76 px, bouton
      Valider, ligne du sac) sont resserrées sans rien retirer.

   Le plateau garde exactement sa taille : il occupe toute la largeur (règle V302 de
   android.css, conservée) et sa taille est calculée sur la largeur (updateBoardAndCellSize).
   Ce fichier est chargé en DERNIER : il reprend aussi les règles de l'ancien
   entete-partie-v300.css (profils et code contenus), désormais retiré.
   ============================================================================ */

/* Seulement pendant la partie : ailleurs, le grossissement du texte choisi par le joueur reste actif. */
#view-game{ -webkit-text-size-adjust:100%; text-size-adjust:100%; }
@supports (height:100dvh){ :root{ --vh100:100dvh; } }

/* Emplacement au-dessus du plateau (index.html) : transparent hors téléphone et en mode
   agrandi, où ses éléments gardent leur placement d'origine. Voir la section 3 ci-dessous. */
.bandeau-coup{ display:contents; }

/* ---- Profils et code contenus (ex-entete-partie-v300.css) ---- */
#view-game .game-center #g-code{ min-width:0; max-width:100%; box-sizing:border-box; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#view-game .game-center .score-stack{ min-width:0; }

@media (max-width:860px){
  #view-game:not(.game-zoom) .game-center .game-header{
    grid-template-columns:minmax(0,1fr) minmax(0,clamp(44px,16vw,88px)) minmax(0,1fr);
    height:auto !important; min-height:0 !important; flex:0 0 auto !important;
    row-gap:0; box-sizing:border-box;
    padding:4px 8px !important; margin:0 4px 3px !important;
  }
  #view-game:not(.game-zoom) .game-center .game-header::after{ content:none; }
  #view-game:not(.game-zoom) #mobile-score-a{ grid-column:1; grid-row:1; }
  #view-game:not(.game-zoom) #g-code{
    grid-column:2; grid-row:1; width:100%; min-height:0; align-content:center; line-height:1.25;
    padding:4px 5px !important; font-size:10.5px !important;
  }
  #view-game:not(.game-zoom) #mobile-score-b{ grid-column:3; grid-row:1; }
  #view-game:not(.game-zoom) .game-header .score-box{ max-width:100%; min-width:0; box-sizing:border-box; gap:6px; padding:2px 4px !important; }
  #view-game:not(.game-zoom) .game-header .score-stack{ flex:1 1 0; max-width:100%; overflow:hidden; }
  #view-game:not(.game-zoom) .game-header .score-stack .name{
    display:block; width:100%; max-width:100%; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
    font-size:12px !important; line-height:1.2;
  }
  #view-game:not(.game-zoom) .game-header .score-stack .pts{ font-size:24px !important; line-height:1.05; }
  #view-game:not(.game-zoom) .game-header .mini-avatar{
    width:clamp(28px,8.5vw,36px) !important; height:clamp(28px,8.5vw,36px) !important; flex-shrink:0; font-size:15px !important;
  }
  #view-game:not(.game-zoom) #mobile-jauge-aide{ grid-column:1/-1; grid-row:2; min-width:0; }
  #view-game:not(.game-zoom) #mobile-jauge-aide:empty{ display:none; }

  /* ---- 1. Jamais de commande coupée ---- */
  #view-game:not(.game-zoom) .game-center{
    overflow-x:hidden !important; overflow-y:auto !important; overscroll-behavior:contain;
    padding:2px 0 calc(4px + env(safe-area-inset-bottom, 0px)) !important;
    scrollbar-width:none;
  }
  #view-game:not(.game-zoom) .game-center::-webkit-scrollbar{ display:none; }

  /* ---- 2. Rangée Menu / Agrandir / Emojis : 38 px au lieu de 46 (cible tactile de 44 × 36 px) ---- */
  #view-game:not(.game-zoom) .game-icon-row-mobile{ margin:0 0 2px !important; padding:0 6px !important; min-height:0; }
  #view-game:not(.game-zoom) .game-icon-row-mobile .game-header-icon-btn{ width:44px !important; height:36px !important; min-height:36px !important; padding:0 !important; }

  /* ---- 3. Emplacement au-dessus du plateau, hauteur réservée ----
     Il contient le bandeau du dernier coup ; l'aperçu des points et les messages s'y
     superposent. Poser une lettre, recevoir un message ou ouvrir la partie avant tout coup
     ne déplace donc plus le plateau sous le doigt (avant : 33 px de décalage à la première
     lettre posée). Seul un bandeau de deux lignes l'agrandit, au changement de tour. */
  #view-game:not(.game-zoom) .game-center .bandeau-coup{
    display:block; position:relative; z-index:6; flex:0 0 auto;
    min-height:32px; margin:0 6px 3px;
  }
  #view-game:not(.game-zoom) .game-center #game-feedback{
    position:absolute; left:0; right:0; top:0; z-index:2; min-height:100%; box-sizing:border-box;
    display:flex; align-items:center; justify-content:center; text-align:center;
    margin:0 !important; padding:5px 10px !important; font-size:13.5px; line-height:1.25;
    box-shadow:0 4px 12px rgba(55,38,20,.18); cursor:pointer;
  }
  #view-game:not(.game-zoom) .game-center #hebdo-locked-banner{ margin:0 0 3px !important; }

  /* ---- « Dernier coup » sur une ligne ---- */
  #view-game:not(.game-zoom) .game-center #last-move-banner{
    display:flex; align-items:center; justify-content:center; gap:6px;
    flex:0 0 auto; min-height:32px; max-height:none; overflow:hidden; box-sizing:border-box;
    margin:0 !important; padding:5px 10px !important;
    text-align:left; white-space:nowrap; line-height:1.25;
    box-shadow:0 2px 6px rgba(55,38,20,.12);
  }
  #view-game:not(.game-zoom) .game-center #last-move-banner.hidden{ display:none !important; }
  #view-game:not(.game-zoom) #last-move-banner .lm-label{ display:none; }
  #view-game:not(.game-zoom) #last-move-banner .lm-who{
    flex:0 0 auto; min-width:0; max-width:38%; overflow:hidden; text-overflow:ellipsis;
    font-size:12.5px; font-weight:800; color:var(--ink-soft);
  }
  /* Passe, échange, abandon, revendication : la phrase est tout le contenu. */
  #view-game:not(.game-zoom) #last-move-banner .lm-who:last-child{
    max-width:100%; font-size:14px; color:var(--ink); text-align:center;
    white-space:normal; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; overflow:hidden;
  }
  /* Les mots : une ligne d'ordinaire ; une liste longue passe en plus petit, puis sur deux
     lignes au plus (classes posées par showLastMove), jamais par-dessus le pseudo. */
  #view-game:not(.game-zoom) #last-move-banner .lm-words{
    flex:0 1 auto; min-width:0; margin:0;
    display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-clamp:2; overflow:hidden;
    white-space:normal; overflow-wrap:anywhere; text-align:center;
    font-size:clamp(16px,4.6vw,20px); line-height:1.2;
  }
  #view-game:not(.game-zoom) #last-move-banner.lm-mots-longs .lm-words{ font-size:clamp(14px,4vw,17px); }
  #view-game:not(.game-zoom) #last-move-banner.lm-mots-tres-longs .lm-words{ font-size:clamp(13px,3.6vw,15px); }
  #view-game:not(.game-zoom) #last-move-banner .lm-sep{ display:none; }
  #view-game:not(.game-zoom) #last-move-banner .last-move-pts{ flex:0 0 auto; font-size:16px; }

  /* Aperçu des points pendant la pose : il se superpose au bandeau, qui garde sa place. */
  #view-game:not(.game-zoom) .game-center:has(#score-preview:not(.hidden)) #last-move-banner{ visibility:hidden; }
  #view-game:not(.game-zoom) .game-center #score-preview{
    position:absolute; left:0; right:0; top:50%; transform:translateY(-50%); z-index:1;
    margin:0 !important; padding:0 8px; box-sizing:border-box; max-height:none !important; line-height:1.3;
    font-size:15px !important; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
  }

  /* ---- 4. Plateau : même largeur (V302), marge du bas resserrée ---- */
  #view-game:not(.game-zoom) .game-center .board-wrap{ margin:0 0 4px !important; }

  /* ---- 5. Chevalet, sac, actions ---- */
  #view-game:not(.game-zoom) .game-center .rack-wrap{ margin-top:0 !important; padding-top:0 !important; }
  #view-game:not(.game-zoom) #bag-count{ font-size:12px; line-height:16px; margin:2px 0 3px; }
  #view-game:not(.game-zoom) #bag-count .sac-detail{ display:none; }
  #view-game:not(.game-zoom) .game-center .controls{ margin-top:0 !important; }

  /* ---- 6. La mascotte se tient sur le bord bas du plateau (variable posée par
          placerMascotteSurPlateau, app-part6.js), jamais sur le chevalet. Pendant la partie,
          seul le corps de l'animal capte les touchers (finitions-jeu.css) : il danse et se
          déplace, tandis que les cases sous ses marges transparentes restent jouables. Pendant
          un déplacement de tuile, tuiles-v335.css laisse atteindre les cases sous elle. ---- */
  body.mascot-on.in-game #mascot{ bottom:var(--mascotte-bas, 118px); }
  body.mascot-on.in-game #mascot.burst{ bottom:auto; }
}

/* « Valider le coup » entre le plateau et le chevalet (Android, controles-android.js). */
@media (max-width:860px){
  html.controles-permutes #view-game:not(.game-zoom) #btn-validate{
    margin:0 auto 5px !important; padding:8px 18px !important; min-height:44px; font-size:16.5px !important;
  }
  html.controles-permutes #view-game:not(.game-zoom) .controls > button{ min-height:48px; padding:4px 1px !important; }
}

/* Écrans courts (barre d'adresse affichée sur un petit téléphone) : on gagne encore une
   vingtaine de pixels sur les éléments secondaires. Le plateau, lui, ne change toujours pas. */
@media (max-width:860px) and (max-height:700px){
  #view-game:not(.game-zoom) .game-icon-row-mobile .game-header-icon-btn{ height:32px !important; min-height:32px !important; }
  #view-game:not(.game-zoom) .game-header .score-stack .pts{ font-size:21px !important; }
  #view-game:not(.game-zoom) .game-header .mini-avatar{ width:28px !important; height:28px !important; }
  #view-game:not(.game-zoom) .game-center #last-move-banner{ padding:3px 10px !important; }
  html.controles-permutes #view-game:not(.game-zoom) #btn-validate{ min-height:40px; padding:6px 18px !important; margin-bottom:4px !important; }
  #view-game:not(.game-zoom) .game-center .rack-tile{ width:40px; height:40px; }
  #view-game:not(.game-zoom) .game-center #rack{ padding-top:5px !important; padding-bottom:5px !important; min-height:0 !important; }
  #view-game:not(.game-zoom) #bag-count{ margin:1px 0 2px; }
  #view-game:not(.game-zoom) .game-center .game-header{ padding:2px 8px !important; }
  html.controles-permutes #view-game:not(.game-zoom) .controls > button{ min-height:44px; }
}
