:root {
  color-scheme: dark;
  --ink: #150f19;
  --paper: #f0dfbf;
  --cream: #f5e1c2;
  --gold: #e3bd8d;
  --muted: #cbb19a;
  --rule: #86645065;
  --red: #8f1434;
  --title: "STLiti", "STKaiti", "Kaiti SC", KaiTi, "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  --serif: "STSong", "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  --body: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  background: #0e0a12;
  color: var(--cream);
  font: 16px/1.5 var(--body);
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
a { color: inherit; }
a:focus-visible, button:focus-visible, canvas:focus-visible { outline: 2px solid #f7d590; outline-offset: 4px; }

.exhibit {
  width: min(100%, 34rem); min-height: 100vh; min-height: 100svh; margin: auto;
  padding: max(15px, env(safe-area-inset-top)) clamp(16px, 5.25vw, 30px) calc(89px + env(safe-area-inset-bottom));
  background: radial-gradient(ellipse 110% 25rem at 50% 290px, #3c1828, var(--ink) 92%);
  box-shadow: 0 0 65px #0006;
}
.masthead {
  min-height: 59px; display: flex; justify-content: space-between; align-items: center; gap: 7px;
  border-bottom: 1px solid var(--rule); color: var(--gold); font-family: var(--serif);
}
.brand { display: inline-flex; align-items: center; gap: .62rem; text-decoration: none; font-size: 1rem; white-space: nowrap; }
.seal {
  display: grid; place-items: center; width: 31px; height: 32px; background: #79132d;
  border: 1px solid #d4a271; border-radius: 5px; box-shadow: inset 0 0 0 3px #79132d, inset 0 0 0 4px #c38c66;
  font: 1.24rem/1 var(--title);
}
.current { font-size: .91rem; color: var(--muted); white-space: nowrap; }
.screen { animation: enter .28s ease both; }
.screen-title { text-align: center; margin: 19px 0 13px; }
.screen-title h1 { margin: 0; font: 700 clamp(1.95rem, 9.3vw, 3.15rem)/1.15 var(--title); letter-spacing: .055em; }
.screen-title p { margin: 8px 0 0; color: var(--muted); font: .91rem/1.5 var(--serif); }

.stage { position: relative; display: grid; place-items: center; isolation: isolate; height: clamp(236px, 68vw, 345px); }
.artifact-stage, .join-stage { margin-inline: -6px; }
.rings {
  position: absolute; width: min(75%, 61vw, 310px); aspect-ratio: 1; border-radius: 50%;
  border: 1px solid #9b6d457c;
  background: radial-gradient(circle, #792d3b33, transparent 70%); pointer-events: none;
}
.rings::before { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 1px dashed #a77d4b66; }
.rings::after { content: ""; position: absolute; left: 0; top: 50%; width: 5px; height: 5px; background: var(--gold); transform: translate(-50%,-50%) rotate(45deg); box-shadow: 0 0 16px #dda16660; }
.layers, .artifact { width: 91%; height: 91%; }
.layers { position: relative; }
.layers img, .artifact { object-fit: contain; }
.layers img { position: absolute; inset: 0; width: 100%; height: 100%; transition: filter .25s, opacity .25s; }
.layers img.muted { opacity: .60; filter: brightness(.67) saturate(.79); }
.model { position: absolute; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.model:active { cursor: grabbing; }
.understage {
  min-height: 34px; margin: 0 0 8px; display: flex; align-items: center; justify-content: space-between; gap: .5em;
  border-bottom: 1px solid var(--rule); color: var(--muted); font: .88rem/1.4 var(--serif);
}
.quiet { border: 0; padding: 0; background: none; color: var(--gold); font: inherit; min-height: 42px; }
.quiet:disabled { color: var(--gold); }
.center { justify-content: center; text-align: center; }
.layer-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 13px; }
.layer-tabs button {
  justify-self: center; min-width: min(90px,100%); min-height: 58px; padding: 3px 10px;
  background: transparent; border: 1px solid transparent; border-radius: 50px; color: var(--gold); font: 1.46rem/1.1 var(--title);
}
.layer-tabs small { display: block; padding-bottom: .18em; font: .73rem/1.2 var(--serif); }
.layer-tabs button[aria-pressed=true], .red {
  background: linear-gradient(180deg,#941332,#750925); border: 1px solid #c78e65; color: #fff0d2;
}
.paper {
  color: #392328; background: linear-gradient(125deg,#f5e8ce,#ead5ae);
  border: 1px solid #d9ae78; outline: 1px solid #b58f6c; outline-offset: -5px;
  padding: 14px 16px 16px; font-family: var(--serif);
}
.paper-title {
  display: flex; min-height: 35px; gap: .5rem; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #b99a79; padding-bottom: 7px; margin-bottom: 8px;
}
.paper-title h2 { margin: 0; border-left: 3px solid #841831; padding-left: 7px; font: 700 clamp(1.25rem,5.4vw,1.75rem)/1.15 var(--title); }
.paper-title span { font-size: .76rem; white-space: nowrap; color: #7c3541; }
.label-copy { display: grid; grid-template-columns: max-content 1fr; gap: 6px 10px; margin: 9px 0 0; font: .99rem/1.6 var(--serif); }
.label-copy dt { color: #922f43; }
.label-copy dd { margin: 0; }
.fineprint { margin: 11px 0 0; color: var(--muted); font: .76rem/1.4 var(--serif); }
.bottom-nav {
  position: fixed; z-index: 4; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 34rem);
  background: #1d1320f7; border-top: 1px solid #785447; backdrop-filter: blur(14px);
  padding: 4px 8px max(7px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4,1fr);
}
.bottom-nav a {
  display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 52px; text-decoration: none;
  color: var(--muted); font: .76rem/1.2 var(--serif); outline-offset: -4px;
}
.bottom-nav a span { font: 1.04rem/1.2 var(--title); }
.bottom-nav a[aria-current=page] { color: #ffe0a8; }
.bottom-nav a[aria-current=page] span { color: #ffe0a8; text-shadow: 0 0 15px #f76473; }
.red, .text-dark {
  min-height: 44px; padding: 6px 15px; border-radius: 7px; display: inline-flex;
  justify-content: center; align-items: center; text-decoration: none; font: .95rem var(--serif);
}
.text-dark { color: #712742; background: transparent; border: 1px solid #9e715b; }
.compact { min-height: 44px; min-width: 70px; padding-inline: 9px; }
.paper-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.next { display: flex; margin-top: 14px; width: 100%; font: 1.2rem/1.25 var(--title); min-height: 48px; }

.join-stage { height: clamp(185px, 55vw, 295px); }
.hotspot {
  display: grid; place-items: center; width: 47px; height: 47px; position: absolute; left: 31%; top: 75%; transform: translate(-50%,-50%);
  border: 1px solid #e3bd8db3; background: #7a143b42; border-radius: 50%; box-shadow: 0 0 13px #ffba6960;
}
.hotspot i { width: 15px; height: 15px; border-radius: 50%; background: #f7d796; border: 3px solid #9a163c; }
.join-paper { scroll-margin: 12px; }
.join-paper.reveal { animation: flash .6s ease; }
#joint { display: block; width: 100%; max-height: 245px; touch-action: none; }
#joint text { fill: #592a33; font: 12px var(--body); }
#tenon { touch-action: none; cursor: grab; }
#tenon:active { cursor: grabbing; }
.joint-status, .paper-note { margin: 3px 0 0; font: .88rem/1.5 var(--serif); }
.joint-status { text-align: center; min-height: 1.4em; color: #67332f; }

.drum-stage { height: clamp(238px,70vw,350px); }
.drum-stage .rings { width: min(77%, 66vw, 318px); }
.drum-shadow { position: absolute; width: 88%; height: 92%; object-fit: contain; opacity: .22; }
.drum-hit {
  position: relative; width: min(59%,250px); padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; touch-action: manipulation; isolation: isolate;
}
.drum-hit img { width: 100%; height: auto; filter: drop-shadow(0 3px 16px #d1754039); }
.drum-hit.active img { animation: beat .27s ease-out; }
.hit-ring { position: absolute; inset: 5%; border: 2px solid transparent; border-radius: 50%; }
.drum-hit.active .hit-ring { animation: ripple .48s ease-out forwards; }
.beat-count { color: var(--gold); font: 1rem Georgia,serif; }
.timeline { display: block; width: 100%; height: auto; }
.pattern-time { display: flex; justify-content: space-between; margin-top: 21px; font: .9rem var(--serif); color: var(--gold); }
.pattern-stage { height: auto; padding-block: 5px 10px; }
.pattern-stage canvas { display: block; width: min(74%,300px); height: auto; }
.option-row {
  display: grid; grid-template-columns: 2.75rem 1fr; align-items: center; gap: 1px;
  padding-block: 3px; color: var(--gold); font: .93rem var(--serif);
}
.option-set { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 7px; }
.option-set button { background: #281c29; border: 1px solid #85645281; border-radius: 50px; min-height: 44px; padding: 4px 6px; }
.option-set button[aria-pressed=true] { border-color: #d3a174; color: #ffe2b9; background: #7f1434; }
.swatches button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap; }
.swatches i { width: 12px; height: 12px; border-radius: 100%; border: 1px solid #c49973; background: #251d2b; }
.swatches button[data-paint=red] i { background: #8b2542; }
.swatches button[data-paint=gold] i { background: #ab7b56; }
.own-rhythm { display: grid; place-items: center; margin-top: 4px; font: .91rem var(--serif); }
.result { margin-top: 18px; text-align: center; scroll-margin: 14px; }
.result img { display: block; width: min(160px, 64%); height: auto; margin: 12px auto; box-shadow: 0 7px 16px #2d19203b; }
.result .paper-note { margin-top: 8px; }
@keyframes enter { from { opacity: .55; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes beat { 22% { transform: scale(.956); filter: brightness(1.15) drop-shadow(0 0 14px #e69d5255); } }
@keyframes ripple { from { transform: scale(.82); border-color: #fdd99c; opacity: .9; } to { transform: scale(1.35); border-color: #d89267; opacity: 0; } }
@keyframes flash { 40% { box-shadow: 0 0 18px #efbc7680; } }
@media (max-width: 365px) {
  .screen-title { margin-top: 16px; }
  .screen-title p { font-size: .84rem; }
  .label-copy { font-size: .9rem; }
  .paper { padding-inline: 12px; }
  .swatches button { font-size: .83rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
