/* ===== shared styles ===== */
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Inter', sans-serif;
}

.fsm__root {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.fsm__stage.hidden {
  display: none;
}

.button {
  padding: 8px 16px;
  cursor: pointer;
  border: none;
  background-color: #333;
  color: white;
  border-radius: 4px;
  margin: 4px;
}

/* ===== state specific styles ===== */
.fsm__stage.train {
  background-color: #d98a3d;
}

.fsm__stage.train2 {
  background-color: #000;
}

.fsm__stage.one {
  background-color: #a2d2ff;
}

.fsm__stage.two {
  background-color: #ffd6a5;
}

.fsm__stage.three {
  background-color: #b5ead7;
}

.fsm__stage.four {
  background-color: #241c29;
}

.fsm__stage.five {
  background-color: #78aae6;
}

.fsm__stage.six {
  background-color: #1d3b44;
}

/* centered content */
.fsm__stage > * {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

/* ===== dialog box (speech / narration window) ===== */
.dialog-box {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  max-width: 70vw;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 1.1rem;
  border-radius: 6px;
  text-align: center;
  z-index: 10;
  pointer-events: none;
}

.dialog-box.hidden {
  display: none;
}

/* ===== typewriter text (classic scrolling caption at the top) ===== */
.dialog-typed {
  position: fixed;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80vw;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.8);
  border: 2px solid #9fe3a5;
  color: #9fe3a5;
  font-family: "Courier New", monospace;
  font-size: 1.6rem;
  line-height: 1.5;
  white-space: pre-wrap;
  z-index: 20;
  pointer-events: none;
}

.dialog-typed::after {
  content: "\2588";
  margin-left: 2px;
  animation: caret-blink 1s steps(1) infinite;
}

.dialog-typed.hidden {
  display: none;
}

@keyframes caret-blink {
  50% { opacity: 0; }
}

/* ===== inventory bar ===== */
.inventory {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  z-index: 15;
  font-family: "Courier New", monospace;
}

.inventory.hidden {
  display: none;
}

.inventory__slot {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.75);
  border: 3px solid var(--item-color);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.inventory__slot--selected {
  background: var(--item-color);
  color: #111;
  font-weight: bold;
}

.inventory__hint {
  align-self: center;
  color: #ddd;
  font-size: 0.9rem;
  max-width: 260px;
}

/* ===== conversation panel (NPC line + answer options) ===== */
.conversation {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  width: min(900px, 80vw);
  padding: 16px 22px;
  background: rgba(0, 0, 0, 0.85);
  border: 2px solid #ffd84a;
  color: #fff;
  font-family: "Courier New", monospace;
  font-size: 1.3rem;
  line-height: 1.5;
  z-index: 25;
}

.conversation.hidden {
  display: none;
}

.conversation__speaker {
  color: #ffd84a;
  font-weight: bold;
  margin-bottom: 6px;
}

.conversation__text {
  white-space: pre-wrap;
  min-height: 3em;
}

.conversation__options {
  margin: 12px 0 0;
  padding-left: 1.6em;
  color: #9fe3a5;
}

.conversation__options li {
  cursor: pointer;
  padding: 2px 6px;
}

.conversation__options li:hover {
  background: rgba(159, 227, 165, 0.25);
}

/* ===== credits (bottom-to-top scroll, flashy colours) ===== */
.fsm__stage.credits {
  background: #000;
}

.credits-roll {
  position: fixed;
  inset: 0;
  display: block;
  height: auto;
  overflow: hidden;
  background: #000;
  font-family: "Arial Black", Impact, sans-serif;
  text-align: center;
  z-index: 30;
}

.credits-roll__scroll {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  padding: 0 5vw;
  animation: credits-scroll 60s linear forwards;
}

.credits-roll__hint {
  position: absolute;
  right: 16px;
  bottom: 12px;
  color: #555;
  font: 0.9rem "Courier New", monospace;
}

.credits-roll__line {
  margin: 6px 0;
}

.credits-roll__gap {
  height: 3.2rem;
}

.credits-roll__title,
.credits-roll__end {
  font-size: clamp(2.6rem, 7vw, 5.5rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ff3cac, #ffd84a, #3cffb4, #4aa8ff, #c86bff, #ff3cac);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: credits-rainbow 3s linear infinite, credits-wobble 2.2s ease-in-out infinite alternate;
}

.credits-roll__role {
  font-size: clamp(1rem, 2vw, 1.5rem);
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: #4aa8ff;
  text-shadow: 0 0 12px #4aa8ff;
}

.credits-roll__name {
  font-size: clamp(1.8rem, 4vw, 3rem);
  color: #ffd84a;
  animation: credits-glow 2.4s ease-in-out infinite alternate;
}

.credits-roll__sub {
  font: italic 1.2rem "Courier New", monospace;
  color: #aaa;
}

@keyframes credits-scroll {
  from { transform: translateY(0); }
  to { transform: translateY(calc(-100vh - 100%)); }
}

@keyframes credits-rainbow {
  to { background-position: 300% 0; }
}

@keyframes credits-glow {
  from { filter: hue-rotate(0deg); text-shadow: 0 0 6px currentColor; }
  to { filter: hue-rotate(160deg); text-shadow: 0 0 26px currentColor, 0 0 42px currentColor; }
}

@keyframes credits-wobble {
  from { transform: rotate(-1.5deg) scale(1); }
  to { transform: rotate(1.5deg) scale(1.04); }
}
