:root {
  color-scheme: dark;
  --w: 816px;
  --h: 624px;
  --black: #05060a;
  --white: #fbfbf4;
  --ink: #11131a;
  --ghost: #0c6a5f;
  --boyhood: #1d57aa;
  --inner: #23ffe6;
  --lobelia: #e95a96;
  --danger: #ff355d;
  --gold: #f2d071;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 50% 0%, rgba(98, 26, 82, 0.35), transparent 34%),
    linear-gradient(145deg, #06070d, #10131a 55%, #05050a);
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  color: #fff;
  overflow: hidden;
}

.app {
  width: min(100vw, var(--w));
  aspect-ratio: 816 / 624;
  max-height: 100dvh;
  display: grid;
  place-items: center;
}

.stage {
  width: var(--w);
  height: var(--h);
  position: relative;
  overflow: hidden;
  background: #000;
  transform-origin: center;
  box-shadow: 0 0 0 1px #3a3140, 0 24px 80px rgba(0, 0, 0, 0.8);
}

#scene {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

.scanline {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.06) 0,
    rgba(255, 255, 255, 0.06) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: overlay;
}

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: rgba(255, 0, 45, 0.42);
}

.flash.is-active {
  animation: flash-red 0.22s linear 5 alternate;
}

@keyframes flash-red {
  from { opacity: 0; }
  to { opacity: 1; }
}

.hud {
  position: absolute;
  inset: 14px 18px auto 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  z-index: 5;
}

.mode {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.mode span,
.hp-wrap {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(4px);
  border-radius: 3px;
}

.hp-wrap {
  min-width: 218px;
  display: grid;
  grid-template-columns: auto minmax(70px, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #fff;
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.hp-wrap strong {
  min-width: 42px;
  text-align: right;
}

.hp-wrap.is-hidden {
  opacity: 0;
  transform: translateY(-10px);
}

.hp-bar {
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.hp-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #e94365, #f8ca64);
  transition: width 0.35s ease;
}

.terminal {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 22px;
  height: 214px;
  display: grid;
  grid-template-rows: 1fr auto;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(8, 11, 18, 0.84);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  z-index: 6;
}

.stage.theme-lounge .terminal,
.stage.theme-real .terminal {
  background: rgba(255, 255, 255, 0.84);
  border-color: rgba(0, 0, 0, 0.22);
  color: #0b0d12;
}

.stage.theme-lounge .scanline,
.stage.theme-real .scanline {
  opacity: 0.08;
}

.stage.theme-vr .terminal,
.stage.theme-boss .terminal,
.stage.theme-gameover .terminal {
  background: rgba(0, 12, 18, 0.88);
  border-color: rgba(87, 255, 224, 0.35);
}

.log {
  padding: 12px 15px 8px;
  overflow-y: auto;
  scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
  font-size: 17px;
  line-height: 1.58;
}

.line {
  margin: 0 0 7px;
  white-space: pre-wrap;
}

.prefix {
  font-weight: 700;
  margin-right: 0.5em;
}

.speaker-ghost .prefix { color: var(--ghost); }
.speaker-boyhood .prefix,
.speaker-giovanni .prefix { color: var(--boyhood); }
.speaker-narration .prefix { color: #71613a; }
.speaker-lobelia .prefix,
.speaker-subunit .prefix { color: var(--lobelia); }

.stage.theme-vr .speaker-narration .prefix,
.stage.theme-boss .speaker-narration .prefix { color: var(--gold); }

.inner {
  color: var(--inner);
  text-shadow: 0 0 8px rgba(35, 255, 230, 0.45);
}

.advance-hint {
  padding: 5px 12px 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.68;
  text-align: right;
}

.choices {
  position: absolute;
  left: 50%;
  bottom: 252px;
  width: min(670px, calc(100% - 44px));
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  z-index: 8;
}

.choices.is-column {
  grid-template-columns: 1fr;
}

.choice {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  color: #f9fbff;
  background: rgba(11, 18, 30, 0.86);
  font: inherit;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}

.stage.theme-lounge .choice,
.stage.theme-real .choice {
  border-color: rgba(0, 0, 0, 0.24);
  color: #0d1117;
  background: rgba(255, 255, 255, 0.9);
}

.choice:hover,
.choice:focus-visible,
.choice.is-selected {
  outline: 0;
  color: #071016;
  background: #fff2a8;
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(242, 208, 113, 0.28);
}

.choice.is-danger {
  border-color: rgba(255, 53, 93, 0.72);
}

.toast {
  position: absolute;
  top: 62px;
  right: 18px;
  max-width: 360px;
  padding: 13px 16px;
  border: 1px solid rgba(242, 208, 113, 0.7);
  color: #fff9d1;
  background: rgba(30, 20, 7, 0.92);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 10;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.stage.visual-ending .hud,
.stage.visual-ending .terminal,
.stage.visual-ending .choices,
.stage.visual-ending .toast {
  display: none;
}

.start-screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 48px;
  background:
    radial-gradient(circle at 76% 26%, rgba(249, 93, 154, 0.2), transparent 26%),
    radial-gradient(circle at 28% 74%, rgba(50, 255, 229, 0.12), transparent 34%),
    rgba(5, 6, 10, 0.95);
  z-index: 20;
}

.start-screen.is-hidden {
  display: none;
}

.start-card {
  width: min(600px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(9, 12, 18, 0.88);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  letter-spacing: 0.12em;
  font-size: 12px;
  text-transform: uppercase;
}

.start-card h1 {
  margin: 0 0 14px;
  font-size: 30px;
}

.start-card p,
.start-card li {
  line-height: 1.75;
}

.start-card button {
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid #fff2a8;
  color: #141006;
  background: #fff2a8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.shake {
  animation: shake 0.38s linear;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 4px); }
  30% { transform: translate(7px, -5px); }
  45% { transform: translate(-5px, -4px); }
  60% { transform: translate(6px, 5px); }
  75% { transform: translate(-4px, 2px); }
}

@media (max-aspect-ratio: 816/624) {
  .stage {
    transform: scale(calc(100vw / 816));
  }
}

@media (min-aspect-ratio: 816/624) {
  .stage {
    transform: scale(calc(100dvh / 624));
  }
}
