/* ============================================================
   RESET & BASE
============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: #ffffff;
}

/* ============================================================
   ECRAN -- fond blanc, flex colonne
   Ordre :
     header-zone  (auto)
     titre-jeu    (auto)
     chrono-wrapper (auto)
     jeu-zone     (flex 1 1 0  → remplit l'espace restant)
     lezard-zone  (auto)
============================================================ */
.screen {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================================
   HEADER : coffre+score | titre (centré) | bouton ?
   Grid 3 colonnes 1fr / auto / 1fr → titre vraiment centré
   sur l'écran quelle que soit la largeur des éléments latéraux.
============================================================ */
.header-zone {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: clamp(6px, 1.2dvh, 12px) clamp(8px, 2.5%, 16px) clamp(2px, 0.5dvh, 6px);
}

.score-zone {
  justify-self: start;          /* ancré à gauche dans son 1fr */
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(4px, 1.2vw, 10px);
}

.coffre-img {
  height: clamp(28px, 5.5dvh, 46px);
  width: auto;
  display: block;
  -webkit-user-drag: none;
}

.points-box {
  background: #cc0000;
  color: #ffffff;
  font-weight: 700;
  font-size: clamp(0.78rem, 2.6vw, 1.05rem);
  min-width: clamp(30px, 8vw, 52px);
  padding: clamp(2px, 0.5dvh, 5px) clamp(4px, 1vw, 8px);
  border-radius: 5px;
  text-align: center;
  line-height: 1.2;
}

/* ============================================================
   TITRE — colonne centrale (auto) du grid header
   max-width smartphone contrôlé en media query
============================================================ */
.titre-jeu {
  text-align: center;
  font-size: clamp(0.68rem, 3.4vw, 1.05rem);
  font-weight: 800;
  color: #cc0000;
  line-height: 1.35;
  padding: 0 4px;
}

/* ============================================================
   CHRONO (LIB_Minuteur)
   Affiche "120" en décroissant, en vert, dans un cadre arrondi.
   Devient orange sous 30s, rouge sous 10s (géré en JS).
============================================================ */
.chrono-wrapper {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  padding: 0;   /* gap géré par margin-top de .jeu-zone */
}

.chrono-box {
  border: 2.5px solid #888888;
  border-radius: clamp(6px, 2vw, 12px);
  padding: clamp(3px, 0.6dvh, 7px) clamp(14px, 5vw, 28px);
  font-size: clamp(1.4rem, 7.5vw, 2.8rem);
  font-weight: 900;
  color: #00aa00;
  background: #ffffff;
  min-width: clamp(80px, 20vw, 130px);
  text-align: center;
  line-height: 1.1;
  display: inline-block;
  transition: color 0.5s ease, border-color 0.5s ease;
}

/* États d'urgence appliqués par le JS */
.chrono-box.warning { color: #dd7700; border-color: #dd7700; }
.chrono-box.danger  { color: #cc0000; border-color: #cc0000; }

/* ============================================================
   ZONE DE JEU : bouton ? + grille 6×6
   flex: 0 0 auto → la grille se colle au chrono (pas d'étirement)
   margin-top: 3dvh → 3 % d'écran entre le chrono et la grille
============================================================ */
.jeu-zone {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  margin-top: 1dvh;
  padding: 0 clamp(8px, 1%, 5px);
  gap: clamp(6px, 1.8vw, 14px);
}

/* ── Bouton explication (IMG_Explication) ── */
.btn-explication {
  justify-self: end;            /* ancré à droite dans son 1fr */
  width: clamp(30px, 8vw, 46px);
  height: clamp(30px, 8vw, 46px);
  border-radius: 50%;
  border: none;
  background: #2060cc;
  color: #ffffff;
  font-size: clamp(1rem, 4.5vw, 1.8rem);
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-touch-callout: none;
  transition: background 0.15s ease;
}
.btn-explication:active { background: #1040aa; transform: scale(0.92); }

/* ── Grille 6×6 ── */
/*
   Taille = min de :
     - 100vw - 70px   (contrainte largeur)
     - 100dvh - 220px (contrainte hauteur — réserve pour header + lézard)
     - 480px          (cap tablette)
   aspect-ratio: 1 → cellules carrées
*/
.grille {
  flex: 0 0 auto;
  width: min(
    calc(100vw - 70px),
    calc(100dvh - 220px),
    480px
  );
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: clamp(2px, 0.4vw, 4px);
  background: #2a2a2a;        /* "grout" visible entre les cellules via gap */
  padding: clamp(2px, 0.4vw, 4px);
  border-radius: clamp(4px, 1vw, 8px);
  overflow: hidden;
}

/* ── Cellule individuelle (LIB_LrCc) ── */
.cell {
  background: #111111;           /* fond par défaut (noir profond) */
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s ease;
}

/* Fond rouge : bonne lettre, bonne position (WinDev : RougeClair) */
.cell.rouge {
  background: #c40000;
}

/* Fond jaune : bonne lettre, mauvaise position (WinDev : JauneFoncé) */
.cell.jaune {
  background: #b89000;
}

/* ── Input dans la cellule (SAI_LrCc) ── */
/*
   L'input est superposé (absolute inset 0) sur le fond coloré.
   Fond transparent → le fond de .cell est visible.
   user-select: text pour pouvoir taper (overrides .screen)
*/
.cell-input {
  position: absolute;
  inset: 0;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  color: #ffffff;
  font-weight: 900;
  font-size: clamp(1.1rem, 7vw, 2.4rem);
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  padding: 0;
  /* Autoriser la saisie (override du user-select: none du .screen) */
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
  /* Pas de caret coloré visible — le fond suffit */
  caret-color: rgba(255, 255, 255, 0.6);
  /* Désactiver l'input visuellement quand la ligne est verrouillée (géré en JS) */
}

/* Ligne inactive (lignes futures) : input non saisissable */
.cell-input:disabled {
  cursor: default;
  opacity: 1;              /* garder le texte visible même si disabled */
}

/* Lettre figée (rouge / confirmée) — le JS retire readonly */
.cell-input[readonly] {
  cursor: default;
  pointer-events: none;    /* tap impossible sur L1C1 pré-rempli */
}

/* ============================================================
   ZONE LÉZARD (IMG_Lezvert6)
   margin-top: 5dvh → 5 % d'écran entre le bas de la grille et le lézard
============================================================ */
.lezard-zone {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 1dvh;
  padding: 0;
}

.lezard-img {
  height: clamp(46px, 10dvh, 88px);
  width: auto;
  display: block;
  cursor: pointer;
  border-radius: clamp(4px, 1.5vw, 10px);
  filter: drop-shadow(1px 2px 5px rgba(0, 0, 0, 0.35));
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  transition: transform 0.12s ease;
}
.lezard-img:active { transform: scale(0.93); }

/* ============================================================
   TOAST -- message temporaire
============================================================ */
.toast {
  position: fixed;
  bottom: 16%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.84);
  color: #ffffff;
  padding: clamp(8px, 1.5dvh, 14px) clamp(14px, 4vw, 24px);
  border-radius: 10px;
  font-size: clamp(0.70rem, 3vw, 1rem);
  text-align: center;
  max-width: 84vw;
  line-height: 1.5;
  white-space: pre-line;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: none;
}
.toast.toast-visible { opacity: 1; }

/* ============================================================
   PANELS (Bravo / Erreur) -- identiques Pa_Capona_26Ter
============================================================ */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-box {
  background: #ffffff;
  border-radius: clamp(10px, 3vw, 20px);
  padding: clamp(16px, 3.5dvh, 32px) clamp(20px, 6vw, 44px);
  max-width: 82vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.8dvh, 18px);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35);
}

.panel-bravo  { border: 3px solid #22aa44; }
.panel-erreur { border: 3px solid #cc0000; }

.panel-emoticone {
  height: clamp(44px, 9dvh, 72px);
  width: auto;
  display: block;
  -webkit-user-drag: none;
}

.panel-title {
  font-size: clamp(1.1rem, 5.5vw, 2rem);
  font-weight: 900;
  color: #222222;
}

.panel-pts {
  font-size: clamp(0.80rem, 3.5vw, 1.2rem);
  color: #22aa44;
  font-weight: 700;
}

.panel-text {
  font-size: clamp(0.78rem, 3.5vw, 1.15rem);
  color: #333333;
  line-height: 1.55;
  white-space: pre-line;   /* permet les \n dans LIB_Bravo1 */
}

.panel-arrow {
  height: clamp(36px, 7dvh, 56px);
  width: auto;
  display: block;
  cursor: pointer;
  filter: drop-shadow(1px 1px 3px rgba(0, 0, 0, 0.25));
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  transition: transform 0.12s ease;
}
.panel-arrow:active { transform: scale(0.90); }

/* ============================================================
   OVERLAY DE TRANSITION (fondu noir)
============================================================ */
.transition-overlay {
  position: fixed;
  inset: 0;
  background: #000000;
  z-index: 100;
  opacity: 1;
  pointer-events: all;
  transition: opacity 0.4s ease;
}

/* ============================================================
   RESPONSIVE -- PORTRAIT ETROIT (<= 360px)
============================================================ */
@media (max-width: 360px) {
  .titre-jeu        { font-size: 0.58rem; max-width: 46vw; }
  .chrono-box       { font-size: 1.2rem; padding: 3px 10px; }
  .coffre-img       { height: 22px; }
  .points-box       { font-size: 0.66rem; min-width: 24px; }
  .btn-explication  { width: 24px; height: 24px; font-size: 0.8rem; }
  .lezard-img       { height: 38px; }
  .cell-input       { font-size: 0.9rem; }
}

/* ============================================================
   RESPONSIVE -- SMARTPHONES (375-430px, >= 700px hauteur)
   iPhone 12 Pro (390×844), iPhone 16 Pro (402×874), S24 Ultra (412×915)
============================================================ */
@media (min-width: 375px) and (max-width: 430px) and (min-height: 700px) {
  .titre-jeu       { font-size: clamp(0.74rem, 3.2vw, 0.95rem); max-width: 50vw; }
  .chrono-box      { font-size: clamp(1.6rem, 7vw, 2.4rem); }
  .coffre-img      { height: clamp(30px, 5dvh, 42px); }
  .lezard-img      { height: clamp(52px, 9dvh, 76px); }
  .cell-input      { font-size: clamp(1.3rem, 7vw, 2.2rem); }
  .btn-explication { width: clamp(32px, 7.5vw, 42px); height: clamp(32px, 7.5vw, 42px); }
}

/* ============================================================
   RESPONSIVE -- TABLETTE (>= 600px)
============================================================ */
@media (min-width: 600px) {
  .titre-jeu        { font-size: clamp(0.78rem, 2.4vw, 1.2rem); }
  .chrono-box       { font-size: clamp(1.6rem, 5vw, 3rem); }
  .coffre-img       { height: clamp(34px, 5.5dvh, 52px); }
  .btn-explication  { width: clamp(38px, 6vw, 52px); height: clamp(38px, 6vw, 52px); }
  .lezard-img       { height: clamp(54px, 10dvh, 96px); }
  .cell-input       { font-size: clamp(1.4rem, 5vw, 2.8rem); }
}

/* ============================================================
   RESPONSIVE -- PAYSAGE MOBILE (hauteur <= 430px)
============================================================ */
@media (max-height: 430px) and (orientation: landscape) {
  .header-zone      { padding: 3px 8px 2px; }
  .coffre-img       { height: 20px; }
  .points-box       { font-size: 0.60rem; min-width: 22px; padding: 1px 4px; }
  .titre-jeu        { font-size: 0.44rem; max-width: 50vw; }
  .chrono-box       { font-size: 0.9rem; padding: 2px 8px; border-radius: 5px; }
  .jeu-zone         { margin-top: 1dvh; padding: 0 6px; gap: 4px; }
  .btn-explication  { width: 22px; height: 22px; font-size: 0.7rem; }
  .lezard-zone      { margin-top: 2dvh; }
  .lezard-img       { height: 30px; }
}
