:root {
  color-scheme: dark;
  --ink: #f7f1e8;
  --muted: #cfc3b6;
  --panel: rgba(18, 18, 22, 0.78);
  --panel-strong: rgba(12, 12, 16, 0.92);
  --line: rgba(255, 255, 255, 0.18);
  --accent: #d9496a;
  --accent-2: #ffd38a;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #111;
  color: var(--ink);
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

button:hover,
button:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.18);
}

button.active {
  border-color: rgba(255, 211, 138, 0.72);
  background: rgba(217, 73, 106, 0.38);
}

.app,
.title-screen,
.game-screen,
.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.title-screen {
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(10, 10, 14, 0.78) 0%, rgba(10, 10, 14, 0.35) 48%, rgba(10, 10, 14, 0.65) 100%),
    url("./images/backgrounds/title.webp"),
    linear-gradient(135deg, #1b2530, #443643 52%, #221921);
  background-size: cover;
  background-position: center;
}

.title-copy {
  position: absolute;
  left: clamp(24px, 8vw, 108px);
  top: clamp(48px, 12vh, 118px);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-2);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(54px, 11vw, 148px);
  line-height: 0.9;
  font-weight: 800;
  text-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
}

.title-actions {
  position: absolute;
  right: clamp(32px, 11vw, 148px);
  bottom: clamp(80px, 20vh, 190px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 180px;
}

.title-actions button {
  width: 100%;
  font-size: 20px;
  background: rgba(18, 18, 22, 0.72);
}

.game-screen {
  overflow: hidden;
  background: #101014;
}

.background {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(16, 16, 20, 0.1), rgba(16, 16, 20, 0.28)),
    linear-gradient(135deg, #293040, #574a55);
  background-size: cover;
  background-position: center;
  transition: opacity 220ms ease;
}

.characters {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.character {
  position: absolute;
  bottom: 5vh;
  max-height: 82vh;
  max-width: 42vw;
  object-fit: contain;
  opacity: 0;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.38));
  transform: translateY(18px);
  transition: opacity 180ms ease, transform 180ms ease, left 180ms ease;
}

.character[src]:not([src=""]) {
  opacity: 1;
  transform: translateY(0);
}

.character.left {
  left: 22%;
  translate: -50% 0;
}

.character.center {
  left: 50%;
  translate: -50% 0;
}

.character.right {
  left: 78%;
  translate: -50% 0;
}

.textbox {
  position: absolute;
  left: clamp(16px, 4vw, 54px);
  right: clamp(16px, 4vw, 54px);
  bottom: clamp(18px, 5vh, 54px);
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 24px 22px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(10px);
}

.textbox.hidden {
  display: none;
}

.speaker {
  min-height: 26px;
  margin-bottom: 8px;
  color: var(--accent-2);
  font-weight: 700;
  font-size: 20px;
}

.dialogue {
  font-size: clamp(18px, 2.6vw, 26px);
  line-height: 1.7;
  white-space: pre-wrap;
}

.toolbar {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.toolbar button {
  padding: 8px 12px;
  font-size: 14px;
}

.notice {
  position: absolute;
  top: 82px;
  right: 24px;
  min-width: 120px;
  min-height: 28px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--muted);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.notice.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .title-actions {
    right: 24px;
    bottom: 86px;
    min-width: 150px;
  }

  .toolbar {
    left: 10px;
    right: 10px;
    justify-content: center;
    flex-wrap: wrap;
  }

  .textbox {
    left: 12px;
    right: 12px;
    min-height: 132px;
    padding: 16px;
  }

  .character {
    max-width: 54vw;
  }
}
