:root {
  color-scheme: dark;
  --ink: #e5e5d8;
  --muted: #a0a598;
  --line: #343a33;
  --paper: #111513;
  --accent: #d9ed9f;
  --mono: "DejaVu Sans Mono", "SFMono-Regular", Consolas, monospace;
  font-family: system-ui, "Noto Sans CJK JP", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; }
button:enabled { cursor: pointer; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.page {
  width: min(100% - 3.5rem, 68rem);
  margin-inline: auto;
}

.heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .5rem;
  padding-block: clamp(1.7rem, 5vh, 3.5rem) 1.4rem;
}
.site-name {
  margin: 0;
  color: var(--accent);
  font: .77rem/1.4 var(--mono);
  letter-spacing: .17em;
}
h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 550;
  letter-spacing: .12em;
  line-height: 1.3;
}

.stage {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  overflow: hidden;
  height: clamp(29rem, 66svh, 39rem);
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse at 50% 43%, #252c23 0%, #1b211b 31%, #121713 64%, #101411 100%);
}
.stage::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  background-image: radial-gradient(#a2a98e24 .65px, transparent .75px);
  background-size: 8px 8px;
  mask-image: radial-gradient(ellipse at center, #000 8%, #0000 76%);
}
.room {
  position: absolute;
  z-index: -1;
  inset: 7% 9% 17%;
  border: 1px solid #7f89601e;
  background:
    linear-gradient(#67705419, #67705419) center / 1px 100% no-repeat,
    linear-gradient(90deg, #67705419 1px, transparent 1px) 50% 0 / 12.5% 100%;
  mask-image: linear-gradient(#0007, #000 35%, #000);
}
.floor {
  position: absolute;
  z-index: -1;
  inset: 82% -18% 0;
  border-top: 1px solid #7f89602a;
  background:
    repeating-conic-gradient(from 77deg at 50% -145%, transparent 0 11deg, #89937125 11deg 11.18deg, transparent 11.18deg 15deg),
    repeating-linear-gradient(to bottom, transparent 0 17px, #7b866522 18px 19px);
  mask-image: radial-gradient(ellipse at 50% 0%, #000 8%, #0000 76%);
}

.door {
  --depth: 12px;
  --sill: 5px;
  position: relative;
  width: clamp(10.5rem, 32vw, 15rem);
  height: clamp(19rem, 52svh, 26rem);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  perspective: 850px;
}
.jamb {
  position: absolute;
  inset: 0;
  border: 1px solid #8d9672;
  background: linear-gradient(100deg, #4b513e, #575e47 58%, #333b2f);
  box-shadow:
    inset 0 0 0 4px #171d17,
    inset 0 0 0 5px #707857,
    0 0 0 3px #171d16,
    0 0 0 4px #444c3a,
    0 20px 48px #070b08a6;
}
.aperture, .leaf {
  position: absolute;
  inset: var(--depth) var(--depth) calc(var(--depth) - var(--sill));
  overflow: hidden;
  border: 1px solid #818962;
}
.aperture {
  background: #161e16;
  box-shadow: 0 0 0 1px #090e0b;
}
.aperture canvas {
  display: block;
  width: 100%;
  height: 100%;
  font: 500 10px/12px var(--mono);
}
.leaf {
  transform-origin: left center;
  transition: transform .68s cubic-bezier(.19,.75,.23,1), filter .68s ease;
  background: linear-gradient(112deg, #333a2b, #252d23 57%, #20291f);
  box-shadow: inset 0 0 0 4px #ffffff07;
}
.door:enabled:hover .leaf, .door:focus-visible .leaf {
  filter: brightness(1.18);
}
.stage.is-open .leaf {
  transform: rotateY(-83deg);
  filter: brightness(.65);
}
.grain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: #b5bea03d;
  font: 500 9px/12px var(--mono);
  letter-spacing: .06em;
  text-align: center;
  white-space: pre;
  mask-image: radial-gradient(ellipse at 45% 40%, #000 30%, #0003 100%);
}
.panel {
  position: absolute;
  left: 12%;
  width: 76%;
  border: 1px solid #82906d4d;
  box-shadow: inset 0 0 0 4px #141d1638, 0 0 0 3px #141d1655;
}
.panel-top { top: 9%; height: 40%; }
.panel-bottom { top: 58%; height: 33%; }
.handle {
  position: absolute;
  top: 51%;
  right: 10%;
  width: 9%;
  height: 5%;
  border: 1px solid #99a37a78;
  background: #263025;
}
.handle::after {
  position: absolute;
  inset: 39% 15% auto -40%;
  height: 3px;
  border-radius: 1px;
  background: #dce7aa;
  box-shadow: 0 0 9px #c7e69b66;
  content: "";
}
.threshold {
  position: absolute;
  right: -6px;
  bottom: -3px;
  left: -6px;
  height: var(--sill);
  background: #323a2d;
  border: 1px solid #7f8967;
  transition: box-shadow .55s, border-color .55s;
}
.stage.is-open .threshold {
  border-color: #91a97c;
  box-shadow: 0 5px 29px 4px #91bd8654;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  padding-block: .9rem;
  border-bottom: 1px solid var(--line);
}
.status, .shortcut {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: 0;
  color: var(--muted);
  font-size: .875rem;
}
.shortcut { justify-self: end; }
.indicator {
  width: .46rem;
  height: .46rem;
  flex: none;
  border-radius: 50%;
  background: #818878;
}
.stage.is-open + .controls .indicator {
  background: var(--accent);
  box-shadow: 0 0 10px #d9ed9f66;
}
kbd {
  padding: .18rem .42rem;
  border: 1px solid #414b3e;
  border-radius: 3px;
  font: .75rem/1.2 var(--mono);
}
.toggle {
  min-width: 10rem;
  min-height: 2.8rem;
  padding: .5rem 1.1rem;
  border: 1px solid #a5b77e;
  border-radius: 2px;
  background: var(--accent);
  color: #1a2416;
  font-size: .95rem;
  font-weight: 650;
}
.toggle:enabled:hover { background: #e8f6bf; }
.toggle:disabled { opacity: .52; }
footer { padding-block: .8rem 1.2rem; }
footer a {
  color: var(--muted);
  font: .75rem/1.5 var(--mono);
  text-underline-offset: .25em;
}

@media (max-width: 42rem) {
  .page { width: calc(100% - 2rem); }
  .stage { height: clamp(23rem, 62svh, 34rem); }
  .door {
    width: clamp(10rem, 45vw, 13rem);
    height: clamp(16rem, 46svh, 23rem);
  }
  .controls { grid-template-columns: 1fr auto; }
  .shortcut { display: none; }
}
@media (max-width: 23rem) {
  .toggle { min-width: 0; }
  .controls { gap: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .leaf, .threshold { transition: none; }
}
