.dialogue {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow: hidden;
}

.dialogue__scene {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #2a2119;
}

.dialogue__scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(16, 12, 9, 0.08) 0%, rgba(16, 12, 9, 0.18) 55%, rgba(16, 12, 9, 0.72) 100%);
}

.dialogue__grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0, rgba(255, 255, 255, 0.06) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: overlay;
}

.dialogue__topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(16, 12, 9, 0.62), transparent);
}

.dialogue__top-action {
  padding: 7px 11px;
  border: 1px solid rgba(231, 215, 183, 0.42);
  border-radius: 999px;
  background: rgba(16, 12, 9, 0.42);
  color: #F1D38B;
  font-size: 0.78rem;
  cursor: pointer;
}

.dialogue__avatar {
  position: absolute;
  z-index: 2;
  width: min(240px, 30vw);
  max-height: 52vh;
  object-fit: contain;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.36));
  animation: avatar-in 0.38s ease both;
}

.dialogue__avatar--left {
  left: 5%;
  bottom: 24%;
}

.dialogue__avatar--right {
  right: 5%;
  bottom: 24%;
}

.dialogue__box {
  position: absolute;
  left: 50%;
  bottom: 3.4%;
  z-index: 3;
  width: min(880px, calc(100% - 32px));
  min-height: 25vh;
  transform: translateX(-50%);
  padding: 18px 22px 16px;
  border-radius: 18px;
  border: 1px solid rgba(231, 215, 183, 0.34);
  background: rgba(16, 12, 9, 0.82);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.30);
  color: #F5F0EB;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.dialogue__box--feedback {
  bottom: 50%;
  transform: translate(-50%, 50%);
  border-color: rgba(201, 169, 110, 0.66);
  background: rgba(34, 25, 20, 0.92);
}

.dialogue__speaker {
  margin-bottom: 8px;
  color: #F1D38B;
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
}

.dialogue__text {
  min-height: 62px;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  line-height: 1.75;
  letter-spacing: 0.02em;
}

.dialogue__text--static {
  white-space: pre-wrap;
}

.dialogue__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 12px;
}

.dialogue__hint {
  color: rgba(245, 240, 235, 0.66);
  font-size: 0.78rem;
}

.dialogue__choice-layer {
  position: absolute;
  left: 50%;
  bottom: 4%;
  z-index: 3;
  width: min(760px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 18px;
  border-radius: 18px;
  background: rgba(16, 12, 9, 0.84);
  border: 1px solid rgba(201, 169, 110, 0.36);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.34);
}

.dialogue__choice-prompt {
  margin-bottom: 12px;
  color: #F5F0EB;
  font-size: 1.06rem;
  line-height: 1.6;
}

.dialogue__choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dialogue__choice {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid rgba(201, 169, 110, 0.36);
  border-radius: 12px;
  background: rgba(245, 240, 235, 0.08);
  color: #F5F0EB;
  text-align: left;
  cursor: pointer;
  transition: border 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.dialogue__choice:hover {
  border-color: #F1D38B;
  background: rgba(201, 169, 110, 0.14);
  transform: translateY(-1px);
}

.dialogue__choice-index {
  flex: 0 0 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #C41A1A;
  color: #fff;
  font-weight: 700;
}

.dialogue__choice-tip {
  margin-top: 12px;
  color: rgba(245, 240, 235, 0.62);
  font-size: 0.76rem;
  text-align: center;
}

.dialogue-history-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(16, 12, 9, 0.68);
}

.dialogue-history-modal__panel {
  width: min(620px, 100%);
  max-height: 78vh;
  overflow-y: auto;
  padding: 24px;
  border-radius: 18px;
  border: 1px solid rgba(201, 169, 110, 0.44);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.dialogue-history-modal__title {
  margin: 0 0 14px;
  font-family: var(--font-title);
  font-size: 1.4rem;
}

.dialogue-history-modal__item {
  margin: 0 0 10px;
  color: var(--ink-soft);
  line-height: 1.7;
}

@keyframes avatar-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .dialogue__avatar {
    width: min(150px, 32vw);
    bottom: 28%;
  }

  .dialogue__box {
    min-height: 27vh;
    padding: 15px 16px 13px;
    border-radius: 14px;
  }

  .dialogue__choice {
    min-height: 44px;
  }

  .dialogue__choice-layer {
    bottom: 3%;
    padding: 14px;
  }
}