/* ==================== ВИЗУАЛЬНАЯ НОВЕЛЛА ==================== */

.visual-novel {
  background: url("https://static.vecteezy.com/system/resources/previews/003/532/746/non_2x/class-school-nobody-classroom-blackboard-table-chair-education-illustration-vector.jpg")
    center/cover no-repeat;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
}

/* ==================== NAMEPLATE (ВЫНЕСЕН ЗА ТЕКСТБОКС) ==================== */

.vn-nameplate {
  background: var(--gradient-primary);
  color: white;
  padding: 10px 30px;
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 5px 20px rgba(17, 141, 145, 0.6);
  white-space: nowrap;
  z-index: 10003; /* ВЫШЕ ВСЕГО */
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  pointer-events: none; /* Не блокирует клики */
}

/* ==================== ТЕКСТБОКС ==================== */

.vn-textbox {
  background: rgba(0, 0, 0, 0.9);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  padding: 30px 10px;
  margin: 0;
  position: relative;
  z-index: 10001;
  border-top: 2px solid rgba(17, 141, 145, 0.5);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  min-height: 200px;
  max-height: 40vh;
  overflow-y: auto;
  overflow-x: hidden; /* ВАЖНО: скрываем только горизонтальный скролл */
  -webkit-animation: slide-up 0.5s ease-out;
  animation: slide-up 0.5s ease-out;
  -webkit-overflow-scrolling: touch;

  height: 100vh;
  height: 100dvh;
}

/* Стилизация скроллбара */
.vn-textbox::-webkit-scrollbar {
  width: 8px;
}

.vn-textbox::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.vn-textbox::-webkit-scrollbar-thumb {
  background: rgba(17, 141, 145, 0.6);
  border-radius: 4px;
}

.vn-textbox::-webkit-scrollbar-thumb:hover {
  background: rgba(17, 141, 145, 0.8);
}

.vn-dialogue-text {
  color: white;
  font-size: 1.3rem;
  line-height: 1.3;
  min-height: 30px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Индикатор печати */
.vn-textbox.typing .vn-dialogue-text::after {
  content: "_";
  -webkit-animation: text-blink 0.7s infinite;
  animation: text-blink 0.7s infinite;
  margin-left: 2px;
}

/* ==================== УПРАВЛЕНИЕ VN ==================== */

.vn-controls {
  position: fixed;
  top: 10px;
  right: 20px;
  display: flex;
  gap: 15px;
  z-index: 10000;
  flex-wrap: wrap;
}

.vn-control-btn {
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 12px 24px;
  border-radius: 50px;
  cursor: pointer;
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
  font-weight: 600;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.vn-control-btn:hover,
.vn-control-btn:active {
  background: rgba(255, 255, 255, 0.2);
  -webkit-transform: scale(1.05);
  transform: scale(1.05);
}

.vn-exit-btn {
  background: rgba(220, 53, 69, 0.9);
}

.vn-exit-btn:hover,
.vn-exit-btn:active {
  background: rgba(220, 53, 69, 1);
}

/* ==================== ПЕРСОНАЖИ (ТОЧНАЯ ЦЕНТРОВКА) ==================== */

#charactersContainer {
  position: absolute;
  bottom: 150px;
  left: 0;
  right: 0;
  width: 100%;
  height: 60%;
  max-height: 70vh;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
  z-index: 100;
  overflow: visible;
}

.vn-character-sprite {
  position: absolute;
  bottom: 0;
  z-index: 10;
  max-height: 100%;
  max-width: 450px; /* Максимальная ширина */
  /* width: auto !important; /* Переопределяем инлайн */
  /* height: auto !important; Переопределяем инлайн */
  width: 450px;
  height: 100%;
  object-fit: contain;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom center;
  -webkit-transition: opacity 0.5s ease;
  transition: opacity 0.5s ease;
  -webkit-backface-visibility: hidden;
  /* backface-visibility: hidden;
  will-change: transform, opacity; */
}

/* IDLE АНИМАЦИЯ (с сохранением центровки) */
@keyframes idle {
  0%,
  100% {
    -webkit-transform: translateX(-50%) translateY(0);
    transform: translateX(-50%) translateY(0);
  }
  50% {
    -webkit-transform: translateX(-50%) translateY(-10px);
    transform: translateX(-50%) translateY(-10px);
  }
}

/* Применяем idle анимацию */
/* .vn-character-sprite.idle-animation {
  -webkit-animation: idle 3s ease-in-out infinite;
  animation: idle 3s ease-in-out infinite;
} */

/* ПОЗИЦИИ ПЕРСОНАЖЕЙ */
.pos-single-center {
  left: 50% !important;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  margin: 0 !important;
}

.pos-dual-left {
  left: 30% !important;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
}

.pos-dual-right {
  left: 70% !important;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
}

/* ==================== ВЫБОРЫ ==================== */

#choicesContainer {
  width: 100%;
  max-width: 800px;
  margin: 20px auto 0;
  padding: 0 20px;
  display: none;
  flex-direction: column;
  gap: 12px;
  position: relative;
  z-index: 10002;
  pointer-events: auto;
}

.vn-choice-btn {
  background: rgba(17, 141, 145, 0.2);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: white;
  border: 2px solid rgba(17, 141, 145, 0.5);
  padding: 18px 30px;
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
  text-align: center;
  border-radius: var(--border-radius-sm);
  position: relative;
  overflow: hidden;
  word-wrap: break-word;
  -webkit-tap-highlight-color: transparent;
}

.vn-choice-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  -webkit-transition: left 0.5s ease;
  transition: left 0.5s ease;
}

.vn-choice-btn:hover::before,
.vn-choice-btn:active::before {
  left: 100%;
}

.vn-choice-btn:hover,
.vn-choice-btn:active {
  background: rgba(17, 141, 145, 0.4);
  border-color: rgba(121, 69, 133, 0.7);
  -webkit-transform: translateX(5px);
  transform: translateX(5px);
  box-shadow: 0 5px 20px rgba(17, 141, 145, 0.4);
}

/* ==================== СТРАНИЦЫ И ЭТАПЫ ==================== */

.page {
  display: none;
}

.page.active {
  display: block;
  height: 100vh;
  height: 100dvh;
}

.stage-container {
  margin-bottom: 20px;
}

.stage-list-item {
  background: rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 2px solid rgba(17, 141, 145, 0.3);
  border-radius: var(--border-radius-sm);
  padding: 20px;
  margin-bottom: 15px;
  position: relative;
  overflow: hidden;
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
}

.stage-list-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  -webkit-transition: left 0.5s ease;
  transition: left 0.5s ease;
}

.stage-list-item:hover::before,
.stage-list-item:active::before {
  left: 100%;
}

.stage-list-item:hover,
.stage-list-item:active {
  -webkit-transform: translateX(5px);
  transform: translateX(5px);
  border-color: rgba(17, 141, 145, 0.5);
  box-shadow: 0 5px 20px rgba(17, 141, 145, 0.3);
}

.stage-list-item h6 {
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.stage-list-item p {
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0;
  position: relative;
  z-index: 1;
}

.stage-list-item.border-success {
  border-color: rgba(197, 217, 46, 0.5) !important;
  background: rgba(197, 217, 46, 0.1);
}

.stage-list-item.border-success:hover,
.stage-list-item.border-success:active {
  border-color: rgba(197, 217, 46, 0.7) !important;
  box-shadow: 0 5px 20px rgba(197, 217, 46, 0.3);
}

.stage-list-item.disabled-stage {
  opacity: 0.4;
  pointer-events: none;
  background: rgba(100, 100, 100, 0.1);
  border-color: rgba(100, 100, 100, 0.3) !important;
}

.stage-placeholder {
  font-style: italic;
  font-size: 0.95rem;
}
