:root {
  color-scheme: dark;
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
  background: #050507;
  color: #f5f7fb;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050507;
}

button {
  font: inherit;
}

#stage {
  position: relative;
  width: 816px;
  height: 624px;
  overflow: hidden;
  transform-origin: center;
  background: #000;
  box-shadow: 0 0 0 1px #252a32, 0 22px 80px rgba(0, 0, 0, 0.62);
}

#view,
#ui {
  position: absolute;
  inset: 0;
}

#view {
  width: 816px;
  height: 624px;
  image-rendering: pixelated;
}

#view.puzzle-active {
  cursor: pointer;
}

#ui {
  pointer-events: none;
}

.phase-badge {
  position: absolute;
  top: 16px;
  left: 18px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid currentColor;
  color: #111;
  background: rgba(255, 255, 255, 0.9);
  font-family: "Consolas", "Yu Gothic", monospace;
  font-size: 14px;
  letter-spacing: 0;
}

.phase-badge.vr {
  color: #b7fff1;
  background: rgba(1, 18, 32, 0.8);
  border-color: rgba(79, 235, 219, 0.55);
}

.phase-badge.real {
  color: #f0f4ff;
  background: rgba(16, 20, 38, 0.82);
  border-color: rgba(175, 191, 255, 0.35);
}

.hp-hud {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 316px;
  padding: 10px 12px 12px;
  border: 1px solid rgba(10, 10, 12, 0.46);
  background: rgba(255, 255, 255, 0.92);
  color: #090a0c;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 420ms ease, transform 420ms ease;
}

.hp-hud.visible {
  opacity: 1;
  transform: translateY(0);
}

.hp-label {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 7px;
  font-family: "Consolas", monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.hp-frame {
  height: 14px;
  padding: 2px;
  border: 1px solid #111;
  background: #eef0f1;
}

.hp-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #58d66b, #f1df5b);
  transform-origin: left center;
  transition: transform 300ms ease, background 300ms ease;
}

.hp-fill.danger {
  background: linear-gradient(90deg, #d74040, #f1a95b);
}

.message-panel {
  position: absolute;
  left: 38px;
  right: 38px;
  bottom: 36px;
  min-height: 132px;
  padding: 18px 20px 20px;
  border: 2px solid currentColor;
  background: rgba(255, 255, 255, 0.93);
  color: #08090b;
  pointer-events: auto;
}

.message-panel.ghost {
  border-color: #8ef7ff;
  background: rgba(2, 12, 20, 0.91);
  color: #c7fff2;
  font-family: "Consolas", "Yu Gothic", monospace;
}

.message-panel.boyhood {
  border-color: #272727;
  background: rgba(255, 255, 255, 0.95);
  color: #020203;
  font-family: "Consolas", "Yu Gothic", monospace;
}

.message-panel.lobelia {
  border-color: #5b0e19;
  background: rgba(255, 246, 248, 0.95);
  color: #24040a;
}

.message-prefix {
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.message-text {
  min-height: 58px;
  white-space: pre-wrap;
  font-size: 22px;
  line-height: 1.55;
}

.message-cue {
  position: absolute;
  right: 16px;
  bottom: 10px;
  font-size: 16px;
  animation: cueBlink 900ms steps(2, end) infinite;
}

@keyframes cueBlink {
  50% {
    opacity: 0;
  }
}

.choice-panel {
  position: absolute;
  left: 70px;
  right: 70px;
  bottom: 36px;
  padding: 16px;
  border: 2px solid #111;
  background: rgba(255, 255, 255, 0.96);
  color: #09090a;
  pointer-events: auto;
}

.choice-prompt {
  margin-bottom: 12px;
  font-size: 17px;
  font-weight: 700;
}

.choice-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.choice-button {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0 16px;
  border: 1px solid #191919;
  background: #f7f7f7;
  color: #070707;
  cursor: pointer;
  text-align: left;
}

.choice-button:hover,
.choice-button:focus-visible,
.choice-button.selected {
  outline: none;
  background: #111;
  color: #fff;
}

.toast {
  position: absolute;
  top: 70px;
  left: 50%;
  min-width: 260px;
  transform: translateX(-50%);
  padding: 12px 16px;
  border: 1px solid #111;
  background: rgba(255, 255, 255, 0.95);
  color: #101012;
  text-align: center;
  font-size: 16px;
}

.flash,
.fade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

.flash {
  background: #fff;
}

.flash.on {
  animation: flashWhite 360ms ease-out;
}

@keyframes flashWhite {
  0% {
    opacity: 0;
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.fade {
  background: #000;
  transition: opacity 360ms ease;
}

.fade.on {
  opacity: 1;
}

.start-overlay,
.finish-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 7, 0.86);
  pointer-events: auto;
}

.start-box {
  width: 430px;
  padding: 28px;
  border: 1px solid #d8d8d8;
  background: #fff;
  color: #09090a;
}

.start-box h1 {
  margin: 0 0 12px;
  font-size: 27px;
  line-height: 1.3;
}

.start-box p {
  margin: 0 0 22px;
  color: #3a3d44;
  line-height: 1.6;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  min-width: 136px;
  padding: 0 18px;
  border: 1px solid currentColor;
  cursor: pointer;
}

.primary-button {
  background: #09090a;
  color: #fff;
}

.secondary-button {
  background: transparent;
  color: #f7f7f7;
}

.primary-button:focus-visible,
.secondary-button:focus-visible {
  outline: 3px solid #69d4ff;
  outline-offset: 3px;
}

.finish-overlay,
.game-over-overlay,
.ending-overlay {
  align-content: center;
  gap: 16px;
  background: #040406;
  color: #f4f4f4;
  text-align: center;
}

.finish-title {
  font-family: "Consolas", monospace;
  font-size: 30px;
}

.finish-text {
  max-width: 520px;
  color: #cfd4df;
  line-height: 1.7;
}

.game-over-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  pointer-events: auto;
  background: #000;
  color: #ff4a5f;
}

.game-over-title {
  font-family: "Consolas", monospace;
  font-size: 42px;
}

.game-over-text {
  max-width: 540px;
  color: #ffb5bf;
  line-height: 1.7;
}

.game-over-sub {
  color: #7b7f88;
  font-family: "Consolas", monospace;
  font-size: 16px;
}

.ending-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  pointer-events: auto;
  background:
    linear-gradient(180deg, rgba(8, 12, 24, 0.96), rgba(0, 0, 0, 0.98)),
    #000;
  color: #eaffff;
}

.ending-kicker {
  color: #8ef7ff;
  font-family: "Consolas", monospace;
  font-size: 15px;
}

.ending-title {
  font-family: "Consolas", monospace;
  font-size: 42px;
}

.ending-text {
  color: #cbd4ec;
  font-size: 18px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
  }
}
