/* ============================================================
   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; /* blanc derrière l'image semi-transparente → éclaircit */
}

/* ============================================================
   ECRAN -- fond img/Fond Bouteilles et Cepages2.png (::before, opacity 0.55)
   Technique identique à Pa_Capona_26Bis.
   Ordre vertical (flex colonne) :
     .contenu  → 2 blocs B6904A + liste + saisie (flex 1, scrollable)
     .bas-zone → retour | lézard | score (flex 0)
============================================================ */
.screen {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('img/Fond Bouteilles et Cepages2.png');
  background-size: cover;
  background-position: center center;
  opacity: 0.55;
  z-index: -1;
  pointer-events: none;
}

/* ============================================================
   CONTENU SCROLLABLE
   Contient les 2 blocs texte + .bas-contenu (liste + saisie).
   Les blocs s'ancrent en haut ; .bas-contenu pousse vers le bas
   via margin-top: auto.
============================================================ */
.contenu {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5dvh, 16px);
  padding: clamp(12px, 2.5dvh, 24px) 0 clamp(8px, 1.5dvh, 14px);
}

/* ============================================================
   BLOCS TEXTE : fond #B6904A, texte blanc, coins arrondis
============================================================ */
.bloc-texte {
  flex: 0 0 auto;
  background: #B6904A;
  border-radius: clamp(6px, 1.8vw, 12px);
  margin: 0 clamp(10px, 4%, 22px);
  padding: clamp(10px, 2dvh, 18px) clamp(14px, 5%, 28px);
  text-align: center;
}

.bloc-p {
  color: #ffffff;
  font-weight: 700;
  font-size: clamp(0.78rem, 3.8vw, 1.1rem);
  line-height: 1.5;
}

/* ============================================================
   BAS CONTENU -- bloc doré #B6904A, poussé en bas de .contenu
   Contient la grille cépages ET la zone saisie.
   margin: auto ... 0 → margin-top:auto pousse le bloc vers le bas.
============================================================ */
.bas-contenu {
  flex: 0 0 auto;
  margin: auto clamp(10px, 4%, 22px) 0;
  background: #B6904A;
  border-radius: clamp(6px, 1.8vw, 12px);
  padding: clamp(10px, 2dvh, 18px) clamp(14px, 5%, 26px);
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.5dvh, 14px);
}

/* ============================================================
   GRILLE CÉPAGES : 3 colonnes × 2 rangées
   Hérite du fond #B6904A de .bas-contenu.
============================================================ */
.liste-cepages {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: clamp(4px, 0.8dvh, 8px) clamp(6px, 2vw, 14px);
}

.liste-cell {
  color: #ffffff;
  font-weight: 700;
  font-size: clamp(0.80rem, 3.8vw, 1.05rem);
  white-space: nowrap;
}

/* ============================================================
   ZONE SAISIE : "7)" + champ texte 1 lettre
============================================================ */
.zone-saisie {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.5vw, 16px);
}

.saisie-label {
  color: #ffffff;
  font-weight: 700;
  font-size: clamp(0.82rem, 3.8vw, 1.1rem);
  /* pas de text-shadow : fond opaque #B6904A */
}

.saisie-input {
  width: clamp(44px, 12vw, 30px);
  height: clamp(38px, 7.5dvh, 30px);
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: clamp(4px, 1.2vw, 8px);
  background: rgba(255, 255, 255, 0.92);
  color: #333333;
  font-size: clamp(1.1rem, 5.5vw, 1.8rem);
  font-weight: 700;
  text-align: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  /* Autoriser la saisie dans ce champ */
  user-select: text;
  -webkit-user-select: text;
}

.saisie-input::placeholder { color: #999999; }

.saisie-input:focus {
  border-color: #B6904A;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(182, 144, 74, 0.35);
}

/* ============================================================
   BARRE BAS : retour (G) | lézard (C) | score (D)
============================================================ */
.bas-zone {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  padding: clamp(4px, 0.9dvh, 10px) clamp(10px, 3%, 20px) clamp(6px, 1.3dvh, 14px);
  margin-top: clamp(4px, 0.8dvh, 10px);
  z-index: 4;
}

.retour-img {
  height: clamp(36px, 8dvh, 64px);
  width: auto;
  display: block;
  cursor: pointer;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
  transition: transform 0.12s ease;
}
.retour-img:active { transform: scale(0.90); }

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

.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;
  -webkit-user-drag: none;
}

.points-box {
  background: #cc0000;
  color: #ffffff;
  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;
}

/* ============================================================
   TOAST -- message temporaire (essai restant)
============================================================ */
.toast {
  position: fixed;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.82);
  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: 82vw;
  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)
============================================================ */
.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(18px, 4dvh, 36px) clamp(20px, 6vw, 44px);
  max-width: 82vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2dvh, 20px);
  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;
  min-height: 1.2em; /* garde la hauteur même si vide */
}

.panel-text {
  font-size: clamp(0.78rem, 3.5vw, 1.15rem);
  color: #333333;
  line-height: 1.55;
}

.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 ÉTROIT (<= 360px)
============================================================ */
@media (max-width: 360px) {
  .bloc-p       { font-size: 0.9rem; line-height: 1.4; }
  .liste-cell   { font-size: 0.9rem; }
  .saisie-label { font-size: 0.9rem; }
  .saisie-input { width: 34px; height: 28px; font-size: 0.90rem; }
  .coffre-img   { height: 22px; }
  .points-box   { font-size: 0.66rem; min-width: 24px; }
  .lezard-img   { height: 38px; }
  .retour-img   { height: 28px; }
}

/* ============================================================
   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) {
  .bloc-p     { font-size: clamp(0.82rem, 3.8vw, 1.05rem); }
  .liste-cell { font-size: clamp(0.82rem, 3.8vw, 1.05rem); }
  .lezard-img { height: clamp(52px, 9dvh, 76px); }
}

/* ============================================================
   RESPONSIVE -- TABLETTE (>= 600px)
============================================================ */
@media (min-width: 600px) {
  .bloc-p     { font-size: clamp(0.90rem, 3vw, 1.5rem); }
  .liste-cell { font-size: clamp(0.90rem, 2.8vw, 1.4rem); }
  .coffre-img { height: clamp(34px, 6dvh, 54px); }
  .points-box { font-size: clamp(0.9rem, 2.2vw, 1.15rem); }
  .lezard-img { height: clamp(54px, 10dvh, 100px); }
  .retour-img { height: clamp(44px, 8dvh, 72px); }
}

/* ============================================================
   RESPONSIVE -- PAYSAGE MOBILE (hauteur <= 430px)
============================================================ */
@media (max-height: 430px) and (orientation: landscape) {
  .contenu      { padding: 3px 0 2px; gap: 4px; }
  .bloc-texte   { padding: 4px 10px; margin: 0 6px; border-radius: 5px; }
  .bloc-p       { font-size: 0.44rem; line-height: 1.3; }
  .bas-contenu  { padding: 5px 8px; gap: 4px; border-radius: 5px; }
  .liste-cell   { font-size: 0.44rem; }
  .zone-saisie  { gap: 6px; }
  .saisie-label { font-size: 0.44rem; }
  .saisie-input { width: 28px; height: 20px; font-size: 0.76rem; }
  .bas-zone     { padding: 2px 10px 3px; margin-top: 2px; }
  .coffre-img   { height: 18px; }
  .points-box   { font-size: 0.58rem; min-width: 20px; padding: 1px 3px; }
  .lezard-img   { height: 28px; }
  .retour-img   { height: 22px; }
}
