* {
  box-sizing: border-box;
}
html {
  color-scheme: dark;
}
body {
  margin: 0;
  background: repeating-linear-gradient(
    94deg,
    #201e1c 0,
    #211f1d 2px,
    #201d1b 5px
  );
  color: #eee4d4;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
  display: grid;
  place-items: center;
  min-height: 100svh;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
  border: 0;
  background: none;
  padding: 0;
  touch-action: manipulation;
}
button img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
button:hover {
  filter: brightness(1.12);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
#speech:focus-visible {
  outline: 2px solid #cb9252;
  outline-offset: 2px;
}
button:disabled {
  opacity: 0.58;
  cursor: default;
}
[hidden] {
  display: none !important;
}
#book {
  width: min(100%, 510px);
  height: min(var(--height, 100dvh), 980px);
  position: relative;
  background: #171412;
  overflow: hidden;
  box-shadow:
    0 0 0 1px #776958,
    0 12px 80px #050403;
}
#cover,
#room {
  position: absolute;
  inset: 0;
}
#cover {
  background: #191511;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  isolation: isolate;
}
#door {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
}
#door img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#cover:after {
  pointer-events: none;
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    #15110ff2,
    transparent 28%,
    transparent 65%,
    #14110e 93%
  );
}
.mast,
.entry {
  pointer-events: none;
  width: 100%;
}
.mast {
  padding-top: clamp(12px, 3vh, 30px);
}
.mast span {
  font-size: 11px;
  letter-spacing: 0.4em;
  text-shadow: 0 1px 3px #000;
}
.mast h1 {
  margin: 4px auto;
  width: 69%;
  line-height: 0;
}
.mast img {
  width: 100%;
  filter: drop-shadow(0 3px 5px #16120e);
}
.entry {
  padding: 0 8px max(18px, env(safe-area-inset-bottom));
  text-shadow: 0 1px 5px black;
}
.entry p {
  font-size: clamp(12px, 2vh, 16px);
  letter-spacing: 0.06em;
}
.entry button,
dialog > button {
  pointer-events: auto;
  background: #e5d7bc;
  color: #261f19;
  border: 4px double #504634;
  padding: 10px 35px;
  letter-spacing: 0.15em;
  box-shadow: 0 0 0 1px #c9bda5;
}
.entry small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.15em;
  margin-top: 10px;
  color: #d4c9b9;
}
#shade {
  position: absolute;
  inset: 0;
  background: #100e0d;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
#shade.on {
  opacity: 1;
  pointer-events: auto;
}
#room {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom));
  background: linear-gradient(115deg, #28231f, #191614 70%);
}
header {
  height: clamp(40px, 7vh, 62px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #807263;
  padding-bottom: 4px;
}
header > img {
  height: 100%;
  width: auto;
}
#music {
  width: 76px;
}
#music[aria-pressed="false"] {
  opacity: 0.55;
}
#scene {
  min-height: 0;
  flex: 1;
  position: relative;
  background: #191614;
  border: 1px solid #625a4f;
}
.portrait {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.16s;
}
.portrait.active {
  opacity: 1;
}
#phase {
  position: absolute;
  right: 5px;
  bottom: 8px;
  width: 30%;
}
.paper {
  position: relative;
  margin-top: 9px;
  background: #e9dfd0;
  color: #241f1a;
  border: 4px double #524438;
  box-shadow: inset 0 0 14px #bcac96;
  height: clamp(96px, 18vh, 160px);
  flex-shrink: 0;
}
.name {
  position: absolute;
  width: 103px;
  left: 5px;
  top: -14px;
}
#speech {
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 13px 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.68;
  font-size: clamp(15px, 2.1vh, 18px);
}
.turn {
  position: absolute;
  bottom: 0;
  right: 5px;
  pointer-events: none;
  color: #776956;
}
form {
  display: flex;
  gap: 6px;
  align-items: center;
}
input#q {
  width: 0;
  flex: 1;
  min-height: 44px;
  border: 3px double #51473c;
  color: #241d17;
  background: #efe6d7;
  padding: 4px 9px;
  font-size: 16px;
}
#ask {
  width: 24%;
  min-height: 44px;
}
nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 4px;
  align-items: center;
}
nav button {
  height: clamp(31px, 4.9vh, 44px);
}
#leave {
  font-size: 13px;
  color: #cec1af;
  text-decoration: underline;
  text-underline-offset: 4px;
}
#verification {
  text-align: center;
  max-height: 70px;
}
dialog {
  width: min(90%, 410px);
  max-height: 85dvh;
  overflow: auto;
  background: #e9dfce;
  color: #241e19;
  border: 5px double #675b4d;
  padding: 20px;
}
dialog::backdrop {
  background: #100d0ad9;
}
h2 {
  font-size: 21px;
  margin: 0 0 15px;
}
dialog p {
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
dialog label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 14px 0;
}
dialog input {
  accent-color: #665543;
}
dialog button {
  color: #31261d;
}
dialog > button {
  display: block;
  margin: 18px auto 0;
  padding: 6px 20px;
}
dialog a {
  color: #5a4128;
  overflow-wrap: anywhere;
}
dialog hr {
  border: 0;
  border-top: 1px solid #b9ac99;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (max-height: 520px) {
  header {
    height: 30px;
  }
  .paper {
    height: 78px;
  }
  #room {
    gap: 3px;
  }
  nav {
    grid-template-columns: repeat(5, 1fr);
  }
  nav button {
    height: 30px;
  }
  .mast img {
    max-height: 80px;
    object-fit: contain;
  }
  .entry p {
    margin: 0 0 5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
.paper {
  background: #ebe2d4;
  border: 12px solid transparent;
  border-image: url("art/frame.webp") 55 65 fill / 16px 18px stretch;
  box-shadow: none;
}
.name {
  top: -22px;
  left: -5px;
}
#speech {
  padding: 3px 2px;
}
.turn {
  right: -2px;
  bottom: -8px;
}
