/* ============================================================
   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: #1a4a6b;
}

/* ============================================================
   ECRAN -- fond image directe (pas de semi-transparence)
   Position relative pour le sac en absolue
============================================================ */
.screen {
  position: relative;
  width: 100%;
  height: 100dvh;
  background-image: url('img/Fond_MotMystere24.jpg');
  background-size: cover;
  background-position: center center;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================================
   SAC A DOS -- haut droite (position absolue)
============================================================ */
.sac-btn {
  position: absolute;
  top: clamp(6px, 1.5dvh, 14px);
  right: clamp(8px, 2.5%, 18px);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 10;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}

.sac-img {
  height: clamp(40px, 9dvh, 72px);
  width: auto;
  display: block;
  filter: drop-shadow(1px 2px 5px rgba(0, 0, 0, 0.4));
  transition: transform 0.12s ease;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
.sac-btn:active .sac-img { transform: scale(0.90); }

/* ============================================================
   IMAGE TITRE (MotMystere24b.png)
============================================================ */
.mystere-zone {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(8px, 1.8dvh, 18px) clamp(10px, 4%, 22px) 0;
  /* Decalage a droite pour ne pas masquer le sac */
  padding-top: clamp(10px, 1.8dvh, 18px);
  animation: fadeIn 0.5s ease 0.1s both;
}

.mystere-img {
  max-width: 90%;
  max-height: clamp(50px, 20dvh, 200px);
  width: auto;
  height: auto;
  display: block;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  margin-top: 15%;

}

/* ============================================================
   GRILLE DE DECHIFFRAGE -- bordure noire 2px
   La zone est toujours visible (boite vide si aucun document)
   L'image est cachee quand gnNumDocument == 0
============================================================ */
.grille-zone {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(6px, 1.2dvh, 14px) clamp(10px, 4%, 22px);
  animation: fadeIn 0.5s ease 0.15s both;
}

/* La boite avec bordure -- toujours affichee */
.grille-zone::after {
  /* Pas d'utilisation de pseudo-element ici car l'image est a l'interieur */
  content: none;
}

.grille-img-wrapper {
  border: 2px solid #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: clamp(200px, 80vw, 900px);
  /* min-height garantit la hauteur meme quand l'image est cachee */
  min-height: clamp(140px, 38dvh, 200px);
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  overflow: hidden;
}

.grille-img {
  display: block;
  max-width: 100%;
  max-height: clamp(140px, 38dvh, 250px);
  width: auto;
  height: auto;
  object-fit: contain;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.grille-img.hidden { display: none; }

/* ============================================================
   ZONE SAISIE DU MOT
============================================================ */
.input-zone {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 0.8dvh, 8px);
  padding: 0 clamp(16px, 6%, 36px) clamp(4px, 0.8dvh, 10px);
  animation: fadeIn 0.5s ease 0.2s both;
}

.input-label {
  font-size: clamp(0.72rem, 3vw, 1.1rem);
  color: #ffffff;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

.input-field {
  width: 100%;
  max-width: clamp(220px, 70vw, 400px);
  padding: clamp(7px, 1.4dvh, 12px) clamp(10px, 3%, 16px);
  font-size: clamp(0.88rem, 3.5vw, 1.2rem);
  font-family: inherit;
  border: 2px solid #ffffff;
  border-radius: clamp(5px, 1.5vw, 10px);
  background: rgba(255, 255, 255, 0.92);
  color: #1a1a1a;
  text-align: center;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.input-field:focus {
  border-color: #3388cc;
  background: #ffffff;
}

/* ============================================================
   LEZARD -- validation
============================================================ */
.lezard-zone {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(3px, 0.6dvh, 7px);
  padding: clamp(4px, 1dvh, 10px) 0 clamp(2px, 0.5dvh, 6px);
  animation: fadeIn 0.5s ease 0.25s both;
}

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

.lezard-hint {
  font-size: clamp(0.58rem, 2vw, 0.80rem);
  color: #000000;
  font-style: italic;
  text-align: center;
  /*text-shadow: 0 1px 3px rgba(0, 0, 0, 0.60);*/
  pointer-events: none;
}

/* ============================================================
   BARRE BAS : retour (gauche) + score (droite)
============================================================ */
.bas-zone {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: clamp(4px, 0.8dvh, 10px) clamp(10px, 3%, 20px) clamp(6px, 1.2dvh, 12px);
  animation: fadeIn 0.5s ease 0.3s both;
}

/* Bouton retour (fleche) */
.retour-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.retour-fleche-img {
  height: clamp(30px, 7dvh, 48px);
  width: auto;
  display: block;
  filter: drop-shadow(1px 1px 3px rgba(0, 0, 0, 0.5));
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}
.retour-btn:active .retour-fleche-img { transform: scale(0.92); }

/* Coffre + points */
.score-zone {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(4px, 1.2vw, 10px);
}

.coffre-img {
  height: clamp(28px, 6dvh, 48px);
  width: auto;
  display: block;
}

.points-box {
  background: #cc0000;
  color: #fff;
  font-weight: 700;
  font-size: clamp(0.80rem, 2.8vw, 1.1rem);
  min-width: clamp(32px, 9vw, 58px);
  padding: clamp(3px, 0.6dvh, 6px) clamp(4px, 1vw, 9px);
  border-radius: 5px;
  text-align: center;
  line-height: 1.2;
}

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

/* ============================================================
   PANELS -- base commune
============================================================ */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 5%, 32px);
  animation: fadeIn 0.25s ease;
}

.panel-box {
  background: #fff;
  border-radius: clamp(8px, 2vw, 16px);
  box-shadow: 0 4px 28px rgba(0, 0, 0, 0.38);
  width: 100%;
  max-width: clamp(280px, 88vw, 460px);
}

/* ============================================================
   PANEL BRAVO
============================================================ */
.panel-bravo {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(10px, 3vw, 18px);
  padding: clamp(14px, 4vw, 22px);
}

.panel-bravo-img {
  height: clamp(50px, 13vw, 80px);
  width: auto;
  flex-shrink: 0;
}

.panel-bravo-body { flex: 1; }

.panel-bravo-title {
  font-size: clamp(1.2rem, 5.5vw, 1.9rem);
  font-weight: 900;
  color: #22aa55;
  line-height: 1.1;
}

.panel-bravo-pts {
  font-size: clamp(0.75rem, 3vw, 1rem);
  color: #444;
  margin-top: clamp(4px, 1vw, 8px);
}

/* Fleche -> bleue */
.panel-bravo-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(36px, 9vw, 52px);
  height: clamp(36px, 9vw, 52px);
  background: #3388cc;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: clamp(18px, 5vw, 26px);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.panel-bravo-arrow:active { transform: scale(0.92); }

/* ============================================================
   PANEL ERREUR
============================================================ */
.panel-erreur {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.5vw, 16px);
  padding: clamp(14px, 4vw, 22px);
}

.panel-erreur-top {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: clamp(10px, 3vw, 16px);
}

.panel-erreur-img {
  height: clamp(44px, 11vw, 68px);
  width: auto;
  flex-shrink: 0;
}

.panel-erreur-text { flex: 1; }

.panel-title {
  font-size: clamp(0.88rem, 3.5vw, 1.15rem);
  font-weight: 700;
  color: #222;
  margin-bottom: clamp(3px, 0.8vw, 6px);
}

.panel-text {
  font-size: clamp(0.78rem, 3vw, 1rem);
  color: #333;
  line-height: 1.45;
}

.panel-erreur-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.panel-sous-texte {
  font-size: clamp(0.72rem, 2.8vw, 0.92rem);
  color: #555;
}

.panel-fermer-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
  -webkit-tap-highlight-color: transparent;
}
.panel-fermer-img {
  height: clamp(28px, 7vw, 42px);
  width: auto;
  display: block;
}
.panel-fermer-btn:active .panel-fermer-img { transform: scale(0.88); }

/* ============================================================
   TOAST -- essai rate
============================================================ */
.toast-msg {
  position: fixed;
  left: 50%;
  bottom: clamp(60px, 12dvh, 100px);
  transform: translateX(-50%);
  background: rgba(30, 30, 30, 0.88);
  color: #fff;
  font-size: clamp(0.75rem, 3vw, 1rem);
  padding: clamp(8px, 1.8dvh, 14px) clamp(14px, 5%, 24px);
  border-radius: 8px;
  text-align: center;
  white-space: pre-line;
  max-width: 80vw;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: none;
}
.toast-msg.toast-visible { opacity: 1; }

/* ============================================================
   ANIMATIONS
============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   RESPONSIVE -- PORTRAIT ETROIT (<= 360px)
============================================================ */
@media (max-width: 361px) {
  .sac-img         { height: 54px; }
  .mystere-img     { max-height: 132px; }
  .grille-img      { max-height: 70px; }
  .input-label     { font-size: 1rem; }
  .input-field     { font-size: 1rem; }
  .lezard-img      { height: 42px; }
  .lezard-hint     { font-size: 0.6rem; }
  .coffre-img      { height: 22px; }
  .points-box      { font-size: 0.68rem; min-width: 26px; }
  .retour-fleche-img { height: 26px; }
}

/* ============================================================
   RESPONSIVE -- TABLETTE (>= 600px)
============================================================ */
@media (min-width: 600px) {
  .sac-img         { height: clamp(50px, 9dvh, 80px); }
  .mystere-img     { max-height: clamp(50px, 20dvh, 200px); }
  .grille-img      { max-height: clamp(110px, 25dvh, 500px); }
  .input-label     { font-size: clamp(0.82rem, 2.5vw, 1.2rem); }
  .input-field     { font-size: clamp(1rem, 3vw, 1.4rem); }
  .lezard-img      { height: clamp(60px, 12dvh, 110px); }
  .lezard-hint     { font-size: clamp(0.68rem, 1.8vw, 0.90rem); }
  .coffre-img      { height: clamp(34px, 6dvh, 54px); }
  .points-box      { font-size: clamp(0.9rem, 2.2vw, 1.15rem); }
  .retour-fleche-img { height: clamp(36px, 7dvh, 56px); }
}

/* ============================================================
   RESPONSIVE -- TABLETTE PORTRAIT CONTRAINTE (>= 600px, <= 1099px h)
============================================================ */
@media (min-width: 600px) and (max-height: 1099px) {
  .mystere-zone  { padding-top: clamp(8px, 1.4dvh, 14px); }
  .grille-zone   { padding: clamp(4px, 0.9dvh, 10px) clamp(10px, 4%, 22px); }
  .lezard-zone   { padding: clamp(2px, 0.6dvh, 7px) 0; }
  .bas-zone      { padding: clamp(3px, 0.6dvh, 7px) clamp(10px, 3%, 20px) clamp(4px, 0.8dvh, 8px); }
}

/* ============================================================
   RESPONSIVE -- PAYSAGE MOBILE (hauteur <= 450px)
============================================================ */
@media (max-height: 450px) and (orientation: landscape) {
  .sac-img         { height: 30px; }
  .mystere-zone    { padding: 2px 8px 0; }
  .mystere-img     { max-height: 34px; }
  .grille-zone     { padding: 2px 8px; }
  .grille-img      { max-height: 60px; }
  .grille-img-wrapper { min-height: 36px; }
  .input-zone      { padding: 0 10px 2px; gap: 2px; }
  .input-label     { font-size: 0.44rem; }
  .input-field     { font-size: 0.56rem; padding: 3px 8px; }
  .lezard-zone     { padding: 1px 0; gap: 1px; }
  .lezard-img      { height: 34px; }
  .lezard-hint     { font-size: 0.40rem; }
  .bas-zone        { padding: 2px 10px 3px; }
  .coffre-img      { height: 20px; }
  .points-box      { font-size: 0.62rem; min-width: 24px; }
  .retour-fleche-img { height: 22px; }
}
