:root {
  --c-bg: #0a0e1a;
  --c-surface: #131a2e;
  --c-surface-2: #182140;
  --c-text: #e6ecf5;
  --c-text-muted: #8a97b5;
  --c-border: #24304d;
  --c-accent: #2fe6d6;
  --c-accent-2: #ffb454;
  --c-danger: #ff5c72;
}

html,
body {
  height: 100%;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: "Inter", system-ui, sans-serif;
  overflow-x: hidden;
}

.font-display {
  font-family: "Exo 2", "Inter", sans-serif;
  letter-spacing: 0.02em;
}

.font-mono-stat {
  font-family: "JetBrains Mono", monospace;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, #101932 0%, var(--c-bg) 70%);
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- HUD ---------- */

.hud {
  border-bottom: 1px solid var(--c-border);
  background: rgba(19, 26, 46, 0.85);
  backdrop-filter: blur(6px);
}

.hud-stat {
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  border-radius: 0.5rem;
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.hud-stat .bar-track {
  background: rgba(255, 255, 255, 0.06);
}

.hud-stat.flash-up {
  animation: flashUp 0.6s ease;
}

.hud-stat.flash-down {
  animation: flashDown 0.6s ease;
}

@keyframes flashUp {
  0% {
    box-shadow: 0 0 0 rgba(47, 230, 214, 0);
    border-color: var(--c-border);
  }
  30% {
    box-shadow: 0 0 16px rgba(47, 230, 214, 0.55);
    border-color: var(--c-accent);
  }
  100% {
    box-shadow: 0 0 0 rgba(47, 230, 214, 0);
    border-color: var(--c-border);
  }
}

@keyframes flashDown {
  0% {
    box-shadow: 0 0 0 rgba(255, 92, 114, 0);
    border-color: var(--c-border);
  }
  30% {
    box-shadow: 0 0 16px rgba(255, 92, 114, 0.55);
    border-color: var(--c-danger);
  }
  100% {
    box-shadow: 0 0 0 rgba(255, 92, 114, 0);
    border-color: var(--c-border);
  }
}

/* ---------- Illustration + scanline placeholder ---------- */

.scene-illustration {
  aspect-ratio: 16 / 9;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  overflow: hidden;
  position: relative;
}

.scene-illustration img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.scene-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
  background: linear-gradient(160deg, #131a2e 0%, #0e1424 60%, #131a2e 100%);
  color: var(--c-text-muted);
}

.scene-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(47, 230, 214, 0.06) 0px,
    rgba(47, 230, 214, 0.06) 1px,
    transparent 2px,
    transparent 4px
  );
  animation: scanline-drift 3.5s linear infinite;
  opacity: 0.7;
}

.scene-placeholder .placeholder-glow {
  position: absolute;
  width: 60%;
  height: 40%;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(47, 230, 214, 0.18), transparent 70%);
  animation: pulse-glow 2.4s ease-in-out infinite;
}

.scene-placeholder .placeholder-icon {
  position: relative;
  font-size: 1.75rem;
  color: var(--c-accent);
  animation: pulse-glow 2.4s ease-in-out infinite;
}

.scene-placeholder .placeholder-label {
  position: relative;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@keyframes scanline-drift {
  0% {
    transform: translateY(-8px);
  }
  100% {
    transform: translateY(8px);
  }
}

@keyframes pulse-glow {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.96);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.03);
  }
}

.scene-illustration.errored .scene-placeholder {
  background: linear-gradient(160deg, #1c1420 0%, #131a2e 70%);
}

.scene-illustration.errored .placeholder-icon {
  color: var(--c-text-muted);
}

/* ---------- Scene text + choices ---------- */

.scene-fade-in {
  animation: sceneFadeIn 0.5s ease both;
}

@keyframes sceneFadeIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.scene-text p + p {
  margin-top: 0.9em;
}

.choice-btn {
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  color: var(--c-text);
  text-align: left;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, background 0.2s ease;
}

.choice-btn:hover,
.choice-btn:focus-visible {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 1px rgba(47, 230, 214, 0.35), 0 0 22px rgba(47, 230, 214, 0.18);
  background: #16223a;
  outline: none;
}

.choice-btn:active {
  transform: scale(0.99);
}

.choice-btn .choice-index {
  font-family: "JetBrains Mono", monospace;
  color: var(--c-accent);
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translate(-50%, -140%);
  z-index: 50;
  transition: transform 0.35s ease;
}

#toast.show {
  transform: translate(-50%, 0);
}

/* ---------- Scrollbar (webkit) ---------- */

.scene-scroll::-webkit-scrollbar {
  width: 8px;
}

.scene-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.scene-scroll::-webkit-scrollbar-thumb {
  background: var(--c-border);
  border-radius: 999px;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .scene-fade-in,
  .hud-stat.flash-up,
  .hud-stat.flash-down,
  .scene-placeholder::before,
  .scene-placeholder .placeholder-glow,
  .scene-placeholder .placeholder-icon {
    animation: none !important;
  }
}

/* ---------- Mobile stack (<768px handled mostly by Tailwind, extra tuning) ---------- */

@media (max-width: 767px) {
  .choice-btn {
    min-height: 3.25rem;
  }
}
