:root {
  color-scheme: dark;
  --panel: rgba(12, 15, 22, 0.78);
  --panel-strong: rgba(12, 15, 22, 0.92);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f7f4ec;
  --muted: #c9c7be;
  --accent: #f2c45b;
  --blue: #7fc8ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: #111722;
  color: var(--text);
}

button {
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

button:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.36);
  transform: translateY(-1px);
}

.game {
  position: relative;
  width: 100vw;
  height: 100vh;
  isolation: isolate;
}

.bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
  transition: background-image 600ms ease, filter 300ms ease;
  z-index: -3;
}

.vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(4, 6, 10, 0.1), rgba(4, 6, 10, 0.28) 55%, rgba(4, 6, 10, 0.68)),
    radial-gradient(circle at 50% 35%, transparent 0, rgba(0, 0, 0, 0.54) 86%);
  z-index: -2;
  pointer-events: none;
}

.stage {
  position: absolute;
  inset: 9vh 4vw 20vh;
  pointer-events: none;
}

.character {
  position: absolute;
  bottom: 0;
  width: min(29vw, 360px);
  max-height: 72vh;
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.55));
  opacity: 1;
  transition: opacity 260ms ease, transform 260ms ease;
  border-radius: 18px;
  mask-image: linear-gradient(to bottom, #000 82%, transparent 100%);
}

.character.left { left: 4vw; transform: translateX(0); }
.character.center { left: 50%; transform: translateX(-50%); }
.character.right { right: 4vw; transform: translateX(0); }
.character.hidden { opacity: 0; transform: translateY(18px) scale(0.98); }
.character.left.hidden { transform: translateX(-24px) translateY(18px) scale(0.98); }
.character.right.hidden { transform: translateX(24px) translateY(18px) scale(0.98); }

.hud {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.chapter,
.scene-label {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(8px);
  font-size: 13px;
}

.chapter {
  color: var(--accent);
  font-weight: 700;
}

.title-screen {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: start;
  padding: min(9vw, 96px);
  gap: 28px;
  background: linear-gradient(90deg, rgba(5, 8, 14, 0.78), rgba(5, 8, 14, 0.2));
  z-index: 10;
}

.title-screen.hidden { display: none; }

.title-copy {
  max-width: 760px;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.7);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 14px;
  letter-spacing: 0;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 8vw, 92px);
  line-height: 1;
  letter-spacing: 0;
}

.title-copy p:last-child {
  font-size: clamp(16px, 2.1vw, 22px);
  line-height: 1.75;
  max-width: 620px;
}

.title-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.title-actions button {
  min-width: 150px;
  background: rgba(255, 255, 255, 0.14);
}

.dialogue {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: min(1120px, calc(100vw - 32px));
  min-height: 142px;
  padding: 20px 24px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(16px);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

.speaker {
  display: inline-flex;
  min-width: 112px;
  padding: 7px 12px;
  margin-bottom: 12px;
  background: rgba(242, 196, 91, 0.16);
  border: 1px solid rgba(242, 196, 91, 0.35);
  color: #ffe2a0;
  border-radius: 8px;
  font-weight: 700;
}

.text {
  min-height: 52px;
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.72;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.prompt {
  position: absolute;
  right: 18px;
  bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.choices {
  position: absolute;
  left: 50%;
  bottom: 188px;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 32px));
  display: grid;
  gap: 10px;
  z-index: 4;
}

.choices.hidden { display: none; }

.choices button {
  width: 100%;
  padding: 13px 18px;
  background: rgba(20, 25, 34, 0.86);
  border-color: rgba(255, 255, 255, 0.22);
  text-align: left;
}

.controls {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 8px;
}

.controls button {
  min-width: 58px;
  padding: 8px 10px;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.34);
}

.log-panel {
  position: absolute;
  top: 72px;
  right: 18px;
  width: min(460px, calc(100vw - 36px));
  max-height: calc(100vh - 250px);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  backdrop-filter: blur(18px);
  z-index: 20;
  overflow: hidden;
}

.log-panel.hidden { display: none; }

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.log-body {
  padding: 12px;
  overflow: auto;
  max-height: calc(100vh - 320px);
  font-size: 13px;
  line-height: 1.6;
}

.log-entry {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.log-entry strong { color: var(--blue); }

@media (max-width: 720px) {
  .stage { inset: 13vh 1vw 23vh; }
  .character { width: 43vw; max-height: 56vh; }
  .character.center { width: 52vw; }
  .hud { left: 10px; top: 10px; gap: 6px; }
  .controls {
    top: auto;
    right: auto;
    left: 50%;
    bottom: 178px;
    transform: translateX(-50%);
    width: calc(100vw - 20px);
    justify-content: center;
  }
  .controls button {
    min-width: 0;
    flex: 1;
    padding: 8px 6px;
  }
  .dialogue {
    bottom: 12px;
    width: calc(100vw - 20px);
    min-height: 154px;
    padding: 16px 16px 22px;
  }
  .choices { bottom: 234px; }
  .title-screen { padding: 28px; }
}
