* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: -apple-system, "Segoe UI", Arial, sans-serif; }

/* Mode "encart" : boîte centrée de taille fixe (comme la maquette d'origine) */
body.sz-mode-inset {
  background: #11131c;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.sz-mode-inset #game-container {
  position: relative;
    width: 955px;
    max-width: 96vw;
    
    /* Permet à la hauteur de s'adapter automatiquement selon le ratio 16/9 */
    height: auto;
    max-height: 85vh; /* ou 85svh pour éviter les sauts de barre d'adresse mobile */
    aspect-ratio: 16 / 9;
    
    background-color: #000;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    color: #fff;
}

/* Mode "plein écran" */
body.sz-mode-fullscreen { background: #000; }
body.sz-mode-fullscreen #game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: #fff;
}

#background {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: background-image 0.4s ease;
}

#characters-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sz-character {
  position: absolute;
  transform: translate(-50%, -100%);
  transition: left 0.4s ease, top 0.4s ease, opacity 0.4s ease;
}
/* La hauteur/largeur réelle (px) est calculée et appliquée par public/script.js
   à partir de size_pct / width_pct, pour rester fiable quelle que soit la
   taille du conteneur (identique à admin/assets/js/scene_editor.js). */
.sz-character img {
  height: 240px;
  width: auto;
  display: block;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.4));
}
.sz-character .sz-character-label {
  text-align: center;
  font-size: 0.8rem;
  background: rgba(0,0,0,0.5);
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 4px;
}

#ui-container {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 24px;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 20%, rgba(0,0,0,0));
}

#dialogue-box-wrapper {
  background: rgba(10, 10, 15, 0.72);
  border-radius: 10px;
  padding: 16px 20px;
  backdrop-filter: blur(2px);
  position: relative;
}

#sz-next-btn, #sz-audio-btn {
  position: absolute;
  top: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}
#sz-next-btn { right: 56px; }
#sz-audio-btn { right: 14px; }
#sz-next-btn:hover, #sz-audio-btn:hover { background: rgba(255,255,255,0.28); }
#sz-audio-btn[aria-pressed="true"] { background: #2f9e44; border-color: #2f9e44; }
.sz-tts-icon { font-style: normal; }

#speaker-name {
  font-weight: 700;
  color: #ffd166;
  margin-bottom: 8px;
  min-height: 1.2em;
  padding-right: 86px;
}

#dialogue-box {
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 3em;
  padding-right: 86px;
  white-space: pre-wrap;
}

.choices-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.sz-choice-btn {
  background: rgba(16, 18, 27, 0.95);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}
.sz-choice-btn:hover { background: rgba(9, 17, 51, 0.877); }

.sz-code-form {
  width: 100%;
  margin-top: 4px;
}
.sz-code-form label {
  display: block;
  color: #fff;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.sz-code-row { display: flex; gap: 8px; }
.sz-code-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 0.95rem;
}
.sz-code-input::placeholder { color: rgba(255,255,255,0.6); }
.sz-code-error { color: #fca5a5; font-size: 0.85rem; margin: 6px 0 0; }

/* Modal d'action (info, sans changement de scène) */
.sz-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.sz-modal-card {
  background: #fff;
  color: #1e293b;
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 88%;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3);
  max-height: 85%;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.sz-modal-card h3 { margin-top: 0; flex: 0 0 auto; }
.sz-modal-card p {
  white-space: pre-wrap;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
  -webkit-overflow-scrolling: touch;
}
.sz-modal-card button { flex: 0 0 auto; align-self: flex-start; }

#sz-disclaimer {
  position: fixed;
  left: 0; right: 0; bottom: 26px;
  padding: 3px 16px;
  font-size: 0.7rem;
  line-height: 1.3;
  text-align: center;
  color: rgba(255,255,255,0.55);
  background: rgba(0,0,0,0.35);
  z-index: 5;
}
#sz-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 16px;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  background: rgba(0,0,0,0.45);
  z-index: 5;
}
.sz-modal-card button {
  background: #3b82f6;
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  margin-top: 12px;
}

.sz-lock-body {
  display: flex; align-items: center; justify-content: center;
  height: 100%; background: #111; color: #fff;
}
.sz-lock-card {
  display: flex; flex-direction: column; gap: 10px;
  background: #1e1e1e; padding: 30px; border-radius: 10px; width: 280px;
}
.sz-lock-card input, .sz-lock-card button {
  padding: 10px; border-radius: 6px; border: 1px solid #444; background: #2a2a2a; color: #fff;
}
.sz-lock-card button { background: #3b82f6; border: none; cursor: pointer; }
.sz-lock-error { color: #f87171; font-size: 0.85rem; margin: 0; }


/* ciblage des écrans mobiles ou du format portrait */
/* ciblage des écrans mobiles ou du format portrait */
@media (max-width: 767px), (orientation: portrait) {

  /* 1. On aligne l'écran en haut pour laisser l'espace vide en bas */
  body.sz-mode-inset {
    align-items: flex-start;
    padding-top: 20px;
  }

  /* 2. Le cadre de jeu : Ratio 16/9 STRICT préservé */
  body.sz-mode-inset #game-container {
    width: 95vw;
    max-width: 480px;
    height: auto;
    aspect-ratio: 16 / 9; /* Garantit qu'aucune image ne soit déformée */
    overflow: visible;     /* Permet à l'UI d'aller sous l'image */
    border-radius: 12px;
    position: relative;
  }

  /* 3. L'image de fond remplit exactement ce cadre 16/9 */
  #background {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    overflow: hidden;
    background-size: cover;
    background-position: center;
  }

  #characters-container {
    position: absolute;
    inset: 0;
    border-radius: 12px;
    overflow: hidden;
  }

  /* 4. L'UI glisse EN DESSOUS du cadre 16/9 dans l'espace vide */
  #ui-container {
    position: absolute;
    top: 100%;             /* Se place juste sous le bord inférieur du 16/9 */
    left: 0;
    right: 0;
    bottom: auto;
    height: auto;
    padding-top: 12px;     /* Marge minimale sous l'image */
    background: transparent;
  }

  #dialogue-box-wrapper {
    height: auto;
    background: rgba(16, 18, 27, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    padding: 12px 16px;
  }

  #dialogue-box {
    min-height: auto;
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .choices-grid {
    margin-top: 8px;
    gap: 6px;
  }

  .sz-choice-btn {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.85rem;
    text-align: left;
  }
}
