html, body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  font-family: Arial, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game {
  height: 100dvh;
  width: 100%;
  max-width: 900px;
  margin: auto;
  display: grid;
  grid-template-rows: 80% 20%;
  background: black;
  position: relative;
}

#visualLayer {
  min-width: 100%;
  height: 100%;
  position: relative;
}

#backgroundImage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: 0;
  display: none;
  border-radius: 8px;
}

#bgVideo {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  z-index: 0;
  display: none;
  border-radius: 8px;
  pointer-events: none;
}

#characterLayer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#leftCharacter, #rightCharacter {
  position: absolute;
  bottom: 0;
  max-height: 100%;
  max-width: 45%;
  opacity: 0;
  display: none;
  transition: opacity 0.5s ease;
  user-select: none;
  pointer-events: none;
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.5));
}

#leftCharacter { left: 5%; }
#rightCharacter { right: 5%; }

#dialogueBox {
  grid-row: 2;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 20px;
  font-size: 18px;
  box-sizing: border-box;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  height: 140px;
}

#dialogueText {
  flex-grow: 1;
  overflow-y: auto;
  max-height: 85px;
  margin: 0;
  animation: textPop 0.5s ease;
}

#controls {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  z-index: 11;
  padding-bottom: 8px;
}

#controls button {
  background: #007bff;
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  transition: background-color 0.3s ease;
}

#controls button:disabled {
  background: #555;
  cursor: not-allowed;
}

#controls button:hover:not(:disabled) {
  background: #0056b3;
}

#autoBtn.active {
  background: #28a745;
}

/* Estilos especiais */
.hinata        { color: #d28fff; }
.orihime       { color: #ffa74d; }
.centered      { text-align: center; font-style: italic; color: #ccc; }
.hinata-thought {
  color: #d28fff; font-style: italic;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
}
.orihime-thought {
  color: #ffa74d; font-style: italic;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
}
.full-center {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  font-size: 24px;
  text-align: center;
  color: #fff;
  padding: 20px;
}
.centered-transition {
  width: 100%;
}

/* Animações */
@keyframes textPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.fade-out { opacity: 0; transition: opacity 0.3s ease; }
.fade-in  { opacity: 1; transition: opacity 0.3s ease; }

/* ✅ Landscape: tudo cabe sem rolagem */
@media screen and (orientation: landscape) and (max-height: 500px) {
  html, body {
    height: 100dvh;
    overflow: hidden;
    align-items: center;
  }

  #game {
    height: 100dvh;
    width: 100%;
    max-width: 900px;
    grid-template-rows: 78% 22%;
  }

  /* visual ocupa bem a tela */
  #backgroundImage, #bgVideo {
    border-radius: 0; /* opcional: dá sensação de tela cheia */
  }

  /* diálogo mais compacto */
  #dialogueBox {
    height: auto;           /* deixa o grid controlar */
    padding: 8px 14px;
    font-size: 14px;
  }

  #dialogueTextContainer {
    flex-grow: 1;
    overflow: hidden;
  }

  #dialogueText {
    max-height: none;       /* grid manda */
    overflow-y: auto;       /* se o texto for maior, rola aqui */
    -webkit-overflow-scrolling: touch;
  }

  /* controles menores */
  #controls {
    justify-content: center;
    gap: 8px;
    padding-bottom: 4px;
  }

  #controls button {
    font-size: 13px;
    padding: 6px 10px;
    min-width: 88px;
  }

  /* personagens um pouco maiores no landscape (opcional) */
  #leftCharacter, #rightCharacter {
    max-width: 52%;
    max-height: 100%;
  }
  #leftCharacter { left: 0%; }
  #rightCharacter { right: 0%; }
}


/* ✅ Mobile portrait: personagens maiores */
@media screen and (orientation: portrait) and (max-width: 600px) {
  #leftCharacter, #rightCharacter {
    max-width: 50%;
    max-height: 105%;
  }
  #leftCharacter { left: 0%; }
  #rightCharacter { right: 0%; }
}