:root {
  color-scheme: light;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: #000;
  color: #fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #000;
}

button,
a,
input {
  font: inherit;
}

.ios-html-audio-pause-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(30px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgb(0 0 0 / 0.78);
}

.ios-html-audio-pause-overlay[hidden] {
  display: none;
}

.ios-html-audio-pause-overlay__panel {
  display: grid;
  gap: 18px;
  width: min(360px, 100%);
  border: 2px solid #777;
  background: #101214;
  color: #fff;
  padding: 28px 24px;
  text-align: center;
}

.ios-html-audio-pause-overlay__title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0;
}

.ios-html-audio-pause-overlay__button {
  min-height: 46px;
  border: 1px solid #8c7c62;
  border-radius: 6px;
  background: #fffdf8;
  color: #202426;
  padding: 9px 18px;
  font-weight: 700;
  cursor: pointer;
}

.game-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 14px 0 18px;
  border-bottom: 1px solid #555;
}

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

.game-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.bgm-volume {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  border: 1px solid #6c7378;
  border-radius: 6px;
  background: #111;
  color: #ddd;
  padding: 6px 10px;
  font-size: 13px;
}

.bgm-volume input {
  width: 96px;
  accent-color: #d8c08d;
}

.bgm-volume input:disabled {
  opacity: 0.55;
}

.bgm-volume__unsupported {
  max-width: 220px;
  color: #ff5c5c;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.title-screen[hidden],
.info-screen[hidden],
.save-screen[hidden],
.play-screen[hidden] {
  display: none;
}

.title-screen {
  display: grid;
  min-height: calc(100vh - 140px);
  place-items: center;
}

.title-panel {
  width: min(460px, 100%);
  border: 2px solid #777;
  background: #777;
  padding: 10px;
  text-align: center;
}

.title-panel img {
  display: block;
  width: 100%;
  max-width: 400px;
  height: auto;
  margin: 0 auto 12px;
  border: 2px solid #111;
}

.title-actions {
  display: grid;
  gap: 8px;
}

.title-actions button,
.reading-actions button {
  min-height: 40px;
  border: 1px solid #8c7c62;
  border-radius: 6px;
  background: #fffdf8;
  color: #202426;
  padding: 9px 13px;
  cursor: pointer;
}

.title-credit {
  margin: 14px 0 0;
  color: #111;
  font-size: 13px;
}

.title-footer {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 10px 0 0;
  font-size: 13px;
}

.title-footer a,
.title-footer button {
  border: 0;
  background: transparent;
  color: #111;
  padding: 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.title-footer a:hover,
.title-footer a:focus-visible,
.title-footer button:hover,
.title-footer button:focus-visible {
  color: #fff;
  outline: 0;
}

.title-terms-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / 0.74);
  padding: 24px;
}

.title-terms-dialog {
  width: min(840px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  border: 4px solid #777;
  background: #101214;
  color: #f8f2e7;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.title-terms-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #777;
  padding: 14px 18px;
}

.title-terms-dialog__header h2 {
  margin: 0;
  font-size: 20px;
}

.title-terms-dialog__close {
  min-height: 36px;
  border: 1px solid #8c7c62;
  border-radius: 4px;
  background: #fffdf8;
  color: #202426;
  padding: 7px 12px;
  cursor: pointer;
}

.title-terms-dialog__body {
  overflow: auto;
  padding: 18px;
  line-height: 1.75;
}

.title-terms-dialog__body h2 {
  margin: 22px 0 8px;
  font-size: 18px;
}

.title-terms-dialog__body h2:first-child {
  margin-top: 0;
}

.title-terms-dialog__body p {
  margin: 0 0 12px;
}

.title-terms-dialog__body ul {
  margin: 0 0 14px;
  padding-left: 1.4em;
}

.reading-panel {
  width: min(840px, 100%);
  margin: 24px auto 0;
  border: 4px solid #777;
  background: #101214;
  padding: 18px;
}

.reading-panel h2 {
  color: #c8c8c8;
}

.reading-scroll {
  max-height: min(62vh, 620px);
  overflow: auto;
  border: 1px solid #666;
  background: #000;
  color: #c0c0c0;
  padding: 16px;
  line-height: 1.85;
}

.reading-scroll h3 {
  margin: 1.2em 0 0.4em;
  color: #6fa0c8;
}

.reading-scroll p {
  margin: 0 0 0.9em;
}

.reading-scroll form {
  display: inline;
  margin: 0;
}

.legacy-info-button {
  display: inline-block;
  min-height: 34px;
  border: 1px solid #8c7c62;
  border-radius: 6px;
  background: #fffdf8;
  color: #202426;
  padding: 6px 11px;
  text-decoration: none;
  cursor: pointer;
}

.legacy-info-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.legacy-info-button--sample {
  background: #f3f0e8;
}

.ending-share-link {
  margin-left: 8px;
}

.reading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.save-screen {
  min-height: calc(100vh - 140px);
  padding-top: 28px;
  background: #000 url("/legacy/images/timebg.gif") center / cover fixed;
}

.save-room {
  width: min(720px, 100%);
  margin: 0 auto;
  color: #fff;
  text-align: center;
}

.save-room h2 {
  color: #fff;
  font-size: 32px;
}

.save-room__text,
.save-record {
  border: 2px solid steelblue;
  background: #000;
  padding: 14px;
  line-height: 1.8;
}

.save-room__text p {
  margin: 0 0 0.5em;
}

.save-room__actions {
  display: grid;
  gap: 8px;
  margin: 14px auto;
  width: min(360px, 100%);
}

.save-room__actions button {
  min-height: 40px;
  border: 1px solid #8c7c62;
  border-radius: 6px;
  background: #fffdf8;
  color: #202426;
  padding: 9px 13px;
  cursor: pointer;
}

.save-record h3 {
  margin: 0 0 12px;
  font-size: 24px;
}

.save-record p {
  margin: 0;
}

.save-record__stats {
  display: grid;
  gap: 8px;
  margin: 0;
}

.save-record__stats div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  border-top: 1px solid #334c66;
  padding-top: 8px;
}

.save-record__stats dt,
.save-record__stats dd {
  margin: 0;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.game-actions button,
.game-actions a,
.choices button,
.utility-actions button,
.battle-actions button {
  min-height: 40px;
  border: 1px solid #8c7c62;
  border-radius: 6px;
  background: #fffdf8;
  color: #202426;
  padding: 9px 13px;
  text-decoration: none;
  cursor: pointer;
}

.battle-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.game-actions button:hover,
.game-actions a:hover,
.choices button:hover,
.utility-actions button:hover,
.battle-actions button:hover {
  background: #f4efe3;
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px solid #555;
}

.status-item {
  border: 1px solid #666;
  border-radius: 6px;
  background: #111;
  padding: 10px 12px;
}

.status-item span {
  display: block;
  color: #ccc;
  font-size: 12px;
}

.status-item b {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.scene-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 24px;
  align-items: start;
}

.scene-media {
  position: sticky;
  top: 16px;
  min-height: 300px;
  margin-top: 55px;
  border: 4px solid #777;
  border-radius: 6px;
  background: #181c1e;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.scene-media img {
  width: 100%;
  height: auto;
  image-rendering: auto;
  display: block;
}

.image-placeholder {
  color: #d7d1c4;
}

.scene-main {
  min-width: 0;
}

.section-id {
  display: none;
}

h2 {
  margin: 0 0 18px;
  font-size: 24px;
  letter-spacing: 0;
  color: #888;
}

.scene-text {
  min-height: 260px;
  border: 4px solid #777;
  background: #fff;
  color: #000;
  padding: 12px;
  font-size: 16px;
  line-height: 1.85;
}

.legacy-text-bold,
.scene-text strong {
  font-weight: 700;
}

.legacy-text-style {
  color: inherit;
  font-size: inherit;
  font-family: inherit;
}

.legacy-text-gothic {
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

.legacy-text-color-red {
  color: #c00000;
}

body[data-edition="original"] .play-screen[data-original-dice-room-fade="true"] .scene-media,
body[data-edition="original"] .play-screen[data-original-dice-room-fade="true"] .scene-text {
  animation: original-dice-room-fade 360ms ease-out both;
}

@keyframes original-dice-room-fade {
  0% {
    opacity: 0.48;
    filter: brightness(1.2);
  }

  100% {
    opacity: 1;
    filter: brightness(1);
  }
}

.legacy-text-color-black {
  color: #000;
}

.legacy-text-color-white {
  color: #fff;
}

.legacy-text-color-gray {
  color: #808080;
}

.legacy-text-color-silver {
  color: #c0c0c0;
}

.legacy-text-color-steelblue {
  color: steelblue;
}

.legacy-text-color-yellow {
  color: #ffff00;
}

.legacy-text-size-4 {
  font-size: 1.12em;
}

.legacy-text-size-5 {
  font-size: 1.5em;
}

.legacy-align-center {
  text-align: center;
}

body[data-edition="original"] .reading-scroll .legacy-align-center,
body[data-edition="original"] .scene-text .legacy-align-center {
  text-align: left;
}

.legacy-ending-rank-cell {
  background: steelblue;
}

.scene-text p {
  margin: 0 0 0.8em;
}

.choices {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.choices button {
  width: 100%;
  text-align: left;
  background: #fffdf8;
}

.utility-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #666;
}

.utility-actions:empty {
  display: none;
}

.utility-actions button {
  min-height: 38px;
  border: 1px solid #6c7378;
  border-radius: 6px;
  background: #e9eef0;
  color: #202426;
  padding: 8px 12px;
  cursor: pointer;
}

.dice-tray {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-top: 14px;
  color: #d7d1c4;
  contain: layout paint;
}

.dice-tray img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}

.dice-face--empty {
  visibility: hidden;
}

.dice-tray--rolling {
  contain: layout paint;
}

.input-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.input-choice p {
  grid-column: 1 / -1;
  margin: 0;
  color: #f5f0e6;
}

.input-choice[data-input-choice="sec54_call_master"] p {
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-size: 0.9em;
}

.input-choice__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
}

.input-choice__field {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  gap: 6px;
  align-items: center;
}

.input-choice span {
  color: #f5f0e6;
  line-height: 1.5;
}

.input-choice input {
  min-height: 40px;
  border: 1px solid #8c7c62;
  border-radius: 4px;
  background: #fff;
  color: #111;
  padding: 8px 10px;
}

body[data-state="dead"] .scene-card,
body[data-state="ending"] .scene-card {
  border-top: 4px solid #7f2f2f;
  padding-top: 18px;
}

body[data-state="ending"] .scene-card {
  border-top-color: #386c5f;
}

body[data-edition="original"][data-ending-page="true"] .scene-card {
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  border-top: 0;
  padding-top: 0;
}

body[data-edition="original"][data-ending-page="true"] .scene-main {
  width: fit-content;
  max-width: 100%;
}

body[data-edition="original"][data-ending-page="true"] .scene-media {
  display: none;
}

body[data-edition="original"][data-ending-page="true"] #sectionTitle {
  color: silver;
}

body[data-edition="original"][data-ending-page="true"] .scene-text {
  border: 0;
  background: #000;
  color: silver;
  padding: 0;
}

body[data-edition="original"][data-ending-page="true"] .scene-text .legacy-text-color-red {
  color: #ff0000;
}

body[data-edition="original"][data-ending-page="true"] .scene-text .legacy-text-color-red.legacy-text-size-5 {
  font-size: 24px;
  font-weight: 700;
}

body[data-edition="original"][data-ending-page="true"] .scene-text .legacy-text-color-yellow {
  color: #ffff00;
}

.battle-screen {
  margin-top: 20px;
}

.battle-screen[hidden] {
  display: none;
}

.battle-card {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 14px;
  border: 4px solid #777;
  border-radius: 6px;
  background: #000;
  color: #fff;
}

.battle-media {
  min-height: 260px;
  border: 2px solid #777;
  background: #181c1e;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.battle-media img {
  display: block;
  width: 100%;
  height: auto;
}

.battle-main h2 {
  color: #fff;
}

.battle-message {
  display: flex;
  align-items: center;
  min-height: 46px;
  margin: 0 0 14px;
  border: 1px solid #777;
  background: #111;
  color: #fff;
  padding: 8px 10px;
  line-height: 1.5;
}

.battle-status-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.dice-tray--battle {
  color: #fff;
}

.battle-status-grid div {
  border: 1px solid #777;
  background: #111;
  padding: 8px 10px;
}

.battle-status-grid b,
.battle-status-grid span {
  display: inline;
}

.battle-status-grid span {
  color: #c0c0c0;
  font-size: 12px;
}

.battle-ability-lines {
  margin: 10px 0 0;
  color: #c0c0c0;
  line-height: 1.5;
}

.battle-ability-lines p {
  margin: 0;
}

.battle-log {
  margin: 12px 0 0;
  padding-left: 20px;
  color: #30373a;
  line-height: 1.6;
}

.battle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.battle-result {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #777;
}

.battle-result p {
  margin: 0 0 10px;
}

body[data-state="battle"] .scene-card,
body[data-state="battle"] .route-history {
  display: none;
}

.route-history {
  margin-top: 28px;
  border-top: 1px solid #555;
  padding-top: 18px;
}

.route-history h2 {
  font-size: 17px;
  margin-bottom: 10px;
}

.route-history ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-history li {
  min-height: 40px;
  border: 1px solid #666;
  border-radius: 6px;
  background: #111;
  padding: 8px 10px;
  font-size: 13px;
}

@media (max-width: 760px) {
  .game-shell {
    width: min(100% - 20px, 640px);
    padding-top: 12px;
  }

  .game-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .game-actions {
    justify-content: flex-start;
  }

  .status-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-card {
    grid-template-columns: 1fr;
  }

  .scene-media {
    position: static;
    min-height: 220px;
    margin-top: 0;
  }

  .battle-card {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .battle-media {
    min-height: 220px;
  }

  .battle-status-grid {
    grid-template-columns: 1fr;
  }

  .input-choice {
    grid-template-columns: 1fr;
  }
}
