:root {
  color-scheme: light;
  --paper: #fcfaf5;
  --surface: #fffefa;
  --ink: #38333e;
  --muted: #726a78;
  --purple: #68477e;
  --accent: #9677ac;
  --line: #dfd4e6;
  --wash: #f0eaf3;
  --heading: 'Yu Mincho', 'Hiragino Mincho ProN', 'Noto Serif JP', serif;
  --body: 'Meiryo', 'Yu Gothic', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  --gutter: 16px;
  --fade-time: 1.6s;
  --emphasis: #68417e;
  --warning: #89394f;
  --focus: #8753a1;
  --control-time: 160ms;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.95 var(--body);
  overflow-wrap: anywhere;
}

body[data-stage='1'] {
  --paper: #f1ebf4;
  --wash: #e8deef;
  --purple: #684780;
  --line: #d0bbdc;
  --emphasis: #623576;
  --warning: #8c3358;
}

body[data-stage='2'] {
  color-scheme: dark;
  --paper: #261d32;
  --surface: #34273f;
  --ink: #f2e9f2;
  --muted: #c0afcb;
  --purple: #d3acdf;
  --accent: #b283c6;
  --line: #675177;
  --wash: #3c294d;
  --emphasis: #e2b6f2;
  --warning: #f0a8ba;
  --focus: #dbb1ef;
}

body[data-stage='3'] {
  color-scheme: dark;
  --paper: #120d1b;
  --surface: #251b30;
  --ink: #f5ecf4;
  --muted: #d3bbdb;
  --purple: #e1b8eb;
  --accent: #cfa1db;
  --line: #715582;
  --wash: #352040;
  --emphasis: #ebc7f4;
  --warning: #f4acbd;
  --focus: #ecc7f8;
}

a {
  color: inherit;
  text-underline-offset: .3em;
}

button,
input {
  font: inherit;
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button,
.button {
  min-height: 48px;
  min-width: 48px;
}

button:disabled {
  cursor: wait;
}

button,
.button {
  border: 1px solid var(--purple);
  border-radius: 3px;
  background: var(--purple);
  color: var(--paper);
  padding: 10px 20px;
  line-height: 1.6;
  text-align: center;
  text-decoration: none;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button.secondary,
button.secondary {
  color: var(--purple);
  background: transparent;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

::selection {
  background: #725188;
  color: #fff8f2;
}

.text-key,
.text-warning {
  font-weight: 700;
}

.text-key {
  color: var(--emphasis);
}

.text-warning {
  color: var(--warning);
}

.shiki-text {
  color: var(--purple);
  font-family: var(--heading);
  letter-spacing: .08em;
  text-shadow: 0 0 .55em rgba(126, 82, 150, .26);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--heading);
  font-weight: 500;
  line-height: 1.65;
  text-wrap: pretty;
}

h1 {
  font-size: clamp(1.7rem, 5.8vw, 2.5rem);
  letter-spacing: .1em;
}

h2 {
  font-size: 1.4rem;
  letter-spacing: .07em;
}

h3 {
  font-size: 1.15rem;
}

p + p {
  margin-top: 1.3em;
}

[hidden] {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-top: 4px solid var(--accent);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1040px;
  min-height: 73px;
  margin: auto;
  padding: 8px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  text-decoration: none;
}

.brand-seal {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 3px double var(--accent);
  color: var(--purple);
  display: grid;
  place-items: center;
  font: 22px var(--heading);
}

.brand-name {
  display: block;
  font: 23px/1.45 var(--heading);
  letter-spacing: .16em;
  color: var(--purple);
}

.brand-caption {
  display: block;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .16em;
  line-height: 1.4;
}

.menu-toggle {
  padding: 5px 9px;
  min-width: 62px;
  flex-shrink: 0;
  background: transparent;
  color: var(--purple);
  border-color: var(--line);
  font-size: 12px;
}

.menu-lines {
  display: block;
  width: 23px;
  height: 10px;
  border-block: 1px solid currentColor;
  margin: 3px auto 4px;
}

.page-main {
  width: 100%;
  max-width: 800px;
  margin: auto;
  padding: 27px var(--gutter) 56px;
  position: relative;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.page-title {
  border-bottom: 1px solid var(--line);
  padding-bottom: 23px;
  margin-bottom: 32px;
}

.page-title h1 {
  color: var(--purple);
}

.eyebrow {
  display: block;
  color: var(--purple);
  font-size: 12px;
  letter-spacing: .2em;
  margin-bottom: 9px;
}

.content-section {
  margin-block: 0 44px;
}

.content-section h2 {
  margin-bottom: 18px;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  color: var(--purple);
}

.content-section img {
  width: 100%;
  margin-bottom: 23px;
}

.prose {
  line-height: 2.1;
}

.return-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 14px 12px;
  margin-top: 36px;
  border: 1px solid var(--line);
  background: var(--wash);
  color: var(--purple);
  font-size: 14px;
  text-decoration: none;
}

.site-footer {
  position: relative;
  border-top: 1px solid var(--line);
  background: var(--wash);
  padding: 33px var(--gutter) max(24px, env(safe-area-inset-bottom));
}

.footer-inner {
  max-width: 800px;
  margin: auto;
}

.footer-name {
  font: 20px var(--heading);
  margin-bottom: 14px;
  letter-spacing: .1em;
  color: var(--purple);
}

.footer-info {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.9;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  margin: 16px 0;
  gap: 0 16px;
}

.footer-links button {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.copyright {
  font-size: 12px;
  color: var(--muted);
}

dialog {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 0;
  max-height: calc(100dvh - 32px);
  max-width: calc(100% - 32px);
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgb(16 9 26 / .74);
}

.menu-dialog {
  width: 390px;
  max-width: calc(100% - 32px);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  border: 0;
  border-left: 1px solid var(--line);
}

.menu-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.menu-heading h2 {
  font-size: 1.25rem;
  color: var(--purple);
}

.menu-close {
  min-width: 64px;
  font-size: 14px;
}

.menu-cards {
  display: grid;
  gap: 10px;
  padding: 16px 16px 32px;
}

.menu-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  padding: 15px 16px;
  min-height: 58px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.7 var(--heading);
  text-align: left;
}

.menu-card::after {
  content: '›';
  font: 22px var(--body);
  color: var(--accent);
}

.menu-card[aria-current='page'] {
  border-inline-start: 3px solid var(--purple);
  background: var(--wash);
  color: var(--purple);
}

.mystery-card {
  margin-top: 9px;
  letter-spacing: .3em;
}

.dialog-content {
  padding: 27px 23px;
}

.dialog-content h2 {
  margin-bottom: 20px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 25px;
}

.dialog-actions > * {
  flex: 1;
}

.info-dialog {
  width: 480px;
}

.horror-frame {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  opacity: 0;
  mask-image: linear-gradient(90deg, #000, #000b 18%, #0003 42%, #0003 58%, #000b 82%, #000);
}

body[data-stage='1'] .horror-frame {
  background-image: url('../images/Hair_Light.png');
  opacity: .12;
}

body[data-stage='2'] .horror-frame {
  background-image: url('../images/Hair_Medium.png');
  opacity: .2;
}

body[data-stage='3'] .horror-frame {
  background-image: url('../images/Hair_Heavy.png');
  opacity: .28;
}

body:not([data-stage='0']) h1,
body:not([data-stage='0']) .brand-name {
  position: relative;
}

body:not([data-stage='0']) h1::after,
body:not([data-stage='0']) .brand-name::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: url('../images/Hair_Light.png') center/100% 300%;
  opacity: .2;
}

body[data-stage='2'] .menu-card:nth-child(3n) {
  transform: translateX(-3px) rotate(-.6deg);
}

body[data-stage='3'] .menu-card:nth-child(odd) {
  transform: translateX(4px) rotate(1.3deg);
}

body[data-stage='3'] .menu-card:nth-child(even) {
  transform: translateX(-4px) rotate(-1.4deg);
}

body[data-stage='3'] .brand-name,
body[data-stage='3'] .mystery-card span {
  color: var(--purple);
  background: url('../images/Hair_Heavy.png') center/150px, repeating-linear-gradient(95deg, #dab5e8 0 1px, #503c65 1px 2px, #d4b7df 2px 3px);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 1px 2px 8px #ad68d544;
}

body[data-stage='3'] .mystery-card {
  border-color: var(--purple);
  background: #130c1d;
  min-height: 77px;
  font-size: 25px;
}

body[data-stage='3'] .page-title {
  transform: rotate(-1deg);
}

.spell-dialog {
  width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  max-width: 100vw;
  margin: 0;
  border: 0;
  background: #1b1028;
  color: #f2e8f5;
}

.spell-panel {
  position: relative;
  z-index: 2;
  max-width: 480px;
  margin: clamp(24px, 10dvh, 100px) auto 24px;
  padding: 28px 24px;
  background: #21162bf5;
  border-block: 1px solid #624578;
}

.spell-panel h2 {
  font-size: 1.45rem;
  margin: 16px 0 28px;
}

.spell-panel label {
  display: block;
  font-size: 15px;
  margin-bottom: 12px;
}

.spell-panel input {
  width: 100%;
  min-height: 52px;
  color: #f5e9fb;
  background: #100a19;
  border: 1px solid #a888b8;
  border-radius: 2px;
  padding: 10px 13px;
}

.spell-panel button {
  background: #c7a7d7;
  color: #23152e;
  border-color: #c7a7d7;
}

.spell-panel button.secondary {
  background: transparent;
  color: #decce7;
}

.spell-panel .text-key {
  color: #e4b9f1;
}

.spell-panel input:focus-visible {
  outline-color: #e4b9f1;
}

.spell-status {
  min-height: 32px;
  font-size: 14px;
  margin-top: 16px;
}

.butterfly-swarm {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.butterfly-swarm img {
  position: absolute;
  width: var(--size);
  left: var(--x);
  top: var(--y);
  opacity: .8;
  transform: rotate(var(--angle));
  animation: drift 5s ease-in-out infinite alternate;
  animation-delay: var(--delay);
}

.spell-dialog.is-wrong .butterfly-swarm {
  z-index: 4;
}

.spell-dialog.is-wrong::after {
  content: '';
  position: absolute;
  z-index: 5;
  inset: 0;
  pointer-events: none;
  animation: blackout 1.8s forwards;
}

.spell-dialog.is-correct .butterfly-swarm {
  opacity: 0;
  transform: scale(1.8);
  transition: opacity 1.1s, transform 1.1s;
}

@keyframes drift {
  to {
    translate: 20px -24px;
    rotate: 14deg;
  }
}

@keyframes blackout {
  0%,
  40% {
    background: transparent;
  }
  100% {
    background: #08040e;
  }
}

button,
.button,
.return-link,
.menu-card,
.home-links a {
  transition: background-color var(--control-time), border-color var(--control-time), box-shadow var(--control-time);
}

button:disabled {
  opacity: .65;
}

.button:active,
button:not(.menu-card):active {
  filter: brightness(.93);
}

@media (hover: hover) and (pointer: fine) {
  .menu-card:hover,
  .return-link:hover,
  .home-links a:hover {
    background: var(--wash);
    border-color: var(--accent);
  }
  .menu-toggle:hover {
    background: var(--wash);
  }
  .button:hover,
  .dialog-actions button:hover {
    box-shadow: 0 0 0 2px var(--line);
  }
}

@media (min-width: 700px) {
  :root {
    --gutter: 28px;
  }
  .page-main {
    padding-top: 40px;
  }
  .header-inner {
    min-height: 84px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
