:root {
  color-scheme: dark;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  background: #05050a;
  color: #f5fbff;
}

* {
  box-sizing: border-box;
}

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

button {
  font: inherit;
}

.shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: #05050a;
}

.stage {
  position: relative;
  width: min(100vw, calc(100dvh * 816 / 624));
  aspect-ratio: 816 / 624;
  max-width: 816px;
  max-height: 624px;
  overflow: hidden;
  background: #090a18;
  image-rendering: pixelated;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #090a18;
}

.notice,
.hud,
.skip-game,
.debug {
  position: absolute;
  z-index: 4;
}

.notice {
  top: 12px;
  right: 12px;
  padding: 4px 9px;
  border: 1px solid rgba(159, 231, 255, 0.5);
  color: #e9fbff;
  background: rgba(5, 12, 24, 0.68);
  font-size: 13px;
  text-shadow: 0 1px 1px #000;
}

.hud {
  top: 12px;
  left: 12px;
  display: grid;
  gap: 4px;
  color: #d8f8ff;
  font-size: 14px;
  text-shadow: 0 2px 2px #000;
  pointer-events: none;
}

#modeLabel {
  color: #fff7a8;
  font-weight: 700;
}

.skip-game {
  top: 48px;
  right: 12px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #8fe9ff;
  color: #dffbff;
  background: rgba(13, 34, 50, 0.84);
}

.skip-game[hidden] {
  display: none;
}

.dialogue {
  position: absolute;
  z-index: 5;
  left: 28px;
  right: 28px;
  bottom: 26px;
  min-height: 138px;
  padding: 18px 22px;
  border: 3px solid #e8e2cf;
  background: rgba(14, 18, 27, 0.94);
  box-shadow: inset 0 0 0 2px #303744, 0 10px 26px rgba(0, 0, 0, 0.46);
}

.stage.game .dialogue {
  left: 18px;
  right: 18px;
  bottom: 16px;
}

.advance-cue {
  position: absolute;
  right: 16px;
  bottom: 8px;
  color: #ffe981;
  font-size: 16px;
  animation: cueBlink 0.85s steps(2) infinite;
}

.advance-cue[hidden] {
  display: none;
}

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

.speaker {
  min-height: 24px;
  color: #ffe981;
  font-size: 18px;
  font-weight: 700;
}

.message {
  margin-top: 8px;
  white-space: pre-line;
  color: #fffdf2;
  font-size: 23px;
  line-height: 1.55;
  letter-spacing: 0;
  text-shadow: 0 2px 0 #000;
}

.console {
  position: absolute;
  z-index: 3;
  left: 18px;
  right: 18px;
  bottom: 16px;
  min-height: 142px;
  padding: 12px 14px 14px;
  border: 1px solid rgba(114, 238, 255, 0.72);
  background: rgba(1, 8, 15, 0.9);
  box-shadow: 0 0 24px rgba(30, 215, 255, 0.17), inset 0 0 0 1px rgba(168, 245, 255, 0.18);
  font-family: "Consolas", "SFMono-Regular", monospace;
}

.console header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 21px;
  color: #79eaff;
  font-size: 13px;
  letter-spacing: 0;
}

.log {
  min-height: 27px;
  margin-top: 8px;
  color: #d3fbff;
  font-size: 15px;
}

.prompt {
  margin-top: 6px;
  color: #fff6a5;
  font-size: 15px;
}

.choices {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.choices button,
.controls button,
.finish button {
  min-height: 42px;
  border: 1px solid #97edff;
  color: #effcff;
  background: rgba(13, 34, 50, 0.92);
}

.choices button:disabled {
  opacity: 0.42;
}

.choices button.back {
  grid-column: 1 / -1;
  min-height: 30px;
  font-size: 13px;
  opacity: 0.8;
}

.choices button:focus-visible,
.controls button:focus-visible,
.skip-game:focus-visible,
.finish button:focus-visible {
  outline: 3px solid #fff3a2;
  outline-offset: 2px;
}

.choices button:hover,
.controls button:hover,
.skip-game:hover,
.finish button:hover {
  background: rgba(22, 66, 89, 0.95);
}

.controls {
  position: absolute;
  z-index: 6;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 160ms ease;
}

.controls.active {
  pointer-events: auto;
  opacity: 1;
}

.controls button {
  min-width: 48px;
  padding: 0 12px;
}

.controls button:active,
.controls button.pressed {
  transform: translateY(1px);
  background: #1f6376;
}

.debug {
  left: 12px;
  top: 84px;
  z-index: 8;
  width: 250px;
  min-height: 86px;
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(255, 246, 166, 0.75);
  color: #fff8bf;
  background: rgba(0, 0, 0, 0.74);
  font: 12px/1.45 "Consolas", monospace;
  white-space: pre-wrap;
}

.finish {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 20px;
  background: rgba(3, 7, 12, 0.38);
  text-align: center;
}

.finish[hidden] {
  display: none;
}

.finish-title {
  color: #fffdf0;
  font-size: 30px;
  font-weight: 700;
  text-shadow: 0 3px 6px #000;
}

.finish-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.finish button {
  min-width: 128px;
  padding: 0 16px;
}

@media (max-width: 720px) {
  .notice {
    top: 8px;
    right: 8px;
    font-size: 11px;
  }

  .skip-game {
    top: 38px;
    right: 8px;
    min-height: 34px;
    padding: 0 9px;
    font-size: 12px;
  }

  .hud {
    top: 8px;
    left: 8px;
    font-size: 12px;
  }

  .dialogue,
  .stage.game .dialogue {
    left: 12px;
    right: 12px;
    bottom: 72px;
    min-height: 126px;
    padding: 14px 16px;
  }

  .stage.game .dialogue {
    bottom: 8px;
  }

  .message {
    font-size: 18px;
  }

  .console {
    left: 8px;
    right: 8px;
    bottom: 8px;
    min-height: 142px;
    padding: 10px;
  }

  .choices {
    gap: 6px;
  }

  .choices button {
    min-height: 38px;
    font-size: 13px;
  }

  .finish-title {
    font-size: 24px;
  }
}
