:root {
  --bg-deep: #07060a;
  --panel: rgba(8, 7, 12, 0.82);
  --panel-border: rgba(180, 40, 48, 0.55);
  --text: #efe6d6;
  --muted: #a89f90;
  --accent: #c43c3c;
  --accent-2: #8eb4c9;
  --insight: #7ec8e3;
  --mercy: #c5b07a;
  --blood: #c43c3c;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: #000;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
}

.screen.active {
  display: flex;
}

/* ----- Title ----- */
#screen-title {
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  background: #000 center/cover no-repeat;
  padding: 6vh 6vw 8vh;
  text-align: center;
}

#screen-title::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.88) 0%,
    rgba(0, 0, 0, 0.35) 45%,
    rgba(0, 0, 0, 0.25) 100%
  );
  pointer-events: none;
}

.title-card {
  position: relative;
  z-index: 1;
  max-width: 720px;
}

.title-card h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.8rem, 5vw, 3rem);
  letter-spacing: 0.06em;
  font-weight: 600;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.8);
}

.title-card p {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  letter-spacing: 0.04em;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.btn {
  border: 1px solid rgba(232, 220, 200, 0.35);
  background: rgba(12, 10, 14, 0.72);
  padding: 0.75rem 1.35rem;
  min-height: 44px;
  border-radius: 2px;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.btn:hover,
.btn:focus-visible {
  border-color: var(--accent);
  background: rgba(40, 12, 14, 0.85);
  outline: none;
}

.btn-primary {
  border-color: rgba(196, 60, 60, 0.75);
  background: linear-gradient(180deg, rgba(90, 18, 22, 0.95), rgba(40, 8, 10, 0.95));
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ----- Game stage ----- */
#screen-game {
  flex-direction: column;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000 center/cover no-repeat;
  overflow: hidden;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0, 0, 0, 0.45) 100%);
  pointer-events: none;
  z-index: 1;
}

.sprites {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 4vw 0;
  pointer-events: none;
}

.sprite-slot {
  width: min(38vw, 340px);
  height: min(72%, 620px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.35s ease, transform 0.35s ease, filter 0.25s;
}

.sprite-slot.show {
  opacity: 1;
  transform: translateY(0);
}

.sprite-slot.dim {
  filter: brightness(0.55) saturate(0.85);
}

.sprite-slot img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: bottom center;
  /* Keep full-body white-plate sprites readable on dark BGs */
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.55));
  border-radius: 4px 4px 0 0;
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  pointer-events: none;
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  pointer-events: none;
}

.stat-chip {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.stat-chip.insight {
  color: var(--insight);
}
.stat-chip.mercy {
  color: var(--mercy);
}
.stat-chip.blood {
  color: var(--blood);
}

.hud-actions {
  display: flex;
  gap: 0.35rem;
  pointer-events: auto;
}

.hud-actions .btn {
  min-height: 36px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.55);
}

.dialogue-panel {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem 1rem;
  backdrop-filter: blur(10px);
}

.speaker-name {
  min-height: 1.2em;
  margin: 0 0 0.35rem;
  color: var(--accent-2);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dialogue-text {
  margin: 0;
  min-height: 4.5em;
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  line-height: 1.55;
  white-space: pre-wrap;
}

.dialogue-hint {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
}

.choices {
  display: none;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.choices.show {
  display: flex;
}

.choice-btn {
  text-align: left;
  width: 100%;
  border: 1px solid rgba(232, 220, 200, 0.22);
  background: rgba(20, 16, 22, 0.9);
  padding: 0.75rem 0.9rem;
  min-height: 44px;
  border-radius: 2px;
  line-height: 1.35;
}

.choice-btn:hover,
.choice-btn:focus-visible {
  border-color: var(--accent);
  background: rgba(50, 16, 18, 0.92);
  outline: none;
}

.free-speak {
  display: none;
  margin-top: 0.85rem;
  gap: 0.5rem;
  flex-direction: column;
}

.free-speak.show {
  display: flex;
}

.free-speak textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  border: 1px solid rgba(232, 220, 200, 0.25);
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
  border-radius: 2px;
}

.free-speak-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.status-line {
  min-height: 1.2em;
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ----- Ending ----- */
#screen-ending {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000 center/cover no-repeat;
  padding: 2rem;
  text-align: center;
}

#screen-ending::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.ending-card {
  position: relative;
  z-index: 1;
  max-width: 560px;
  background: rgba(10, 8, 12, 0.88);
  border: 1px solid rgba(196, 60, 60, 0.4);
  padding: 1.5rem 1.35rem;
  box-shadow: var(--shadow);
}

.ending-card h2 {
  margin: 0 0 0.5rem;
  letter-spacing: 0.06em;
}

.ending-card p {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.5;
}

.ending-stats {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

/* ----- Modal ----- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  padding: 1rem;
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(480px, 100%);
  background: rgba(12, 10, 14, 0.96);
  border: 1px solid rgba(232, 220, 200, 0.2);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin: 0 0 0.5rem;
}

.modal-card p {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.llm-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  background: rgba(0, 0, 0, 0.35);
}

.llm-badge.ready {
  color: #9fd4a3;
  border-color: rgba(120, 180, 130, 0.45);
}

.llm-badge.off {
  color: #c9a27a;
  border-color: rgba(180, 140, 80, 0.4);
}

@media (max-width: 720px) {
  .sprite-slot {
    width: min(46vw, 220px);
    height: 58%;
  }

  .dialogue-panel {
    padding: 0.75rem 0.75rem 0.9rem;
  }

  .dialogue-text {
    min-height: 5.2em;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .sprite-slot {
    height: 70%;
  }

  .dialogue-text {
    min-height: 3.2em;
    font-size: 0.95rem;
  }
}
