:root {
  color-scheme: light;
  --paper: #f5f0e6;
  --card: #fbf7ee;
  --ink: #322c25;
  --muted: #6a6054;
  --red: #9b4739;
  --line: #ded2c1;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", "Microsoft JhengHei", serif;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, canvas:focus-visible {
  outline: 3px solid #a75e3d;
  outline-offset: 3px;
}
button svg { fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.shell { width: min(1060px, calc(100% - 64px)); margin-inline: auto; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: max(20px, env(safe-area-inset-top)) 19px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand img { display: block; border-radius: 13px; }
.brand strong { display: block; font: 800 1.62rem/1.12 var(--serif); letter-spacing: .08em; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font: 600 .66rem/1 system-ui, sans-serif; letter-spacing: .12em; }
.install-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #d4c5b1;
  padding: 0 14px;
  border-radius: 12px;
  background: #fffaf1;
  color: #5e4539;
  font-size: .84rem;
  font-weight: 700;
}
.install-button svg, .sound-button svg { width: 17px; height: 17px; }
.install-button:hover { background: #f5e9da; }

.experience {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 16px 36px #634a2910;
}
.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  height: clamp(382px, 44vw, 506px);
  border-radius: 23px 23px 0 0;
  background: #d9b49b url("/assets/sky.svg") center / cover no-repeat;
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 52% 44%, transparent 38%, #372d2834 100%);
}
.still, canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.still { object-fit: contain; }
.stage[data-view="3d"] .still { display: none; }
canvas { touch-action: pan-y; cursor: grab; }
canvas:active { cursor: grabbing; }
canvas:focus-visible { outline-offset: -5px; }
.stage-top {
  position: absolute;
  inset: 17px 17px auto;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.scene-tag, .sound-button, .scene-hint {
  color: #fffbf1;
  background: #352c29dd;
  border: 1px solid #fff5de4f;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 650;
}
.scene-tag { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; letter-spacing: .07em; }
.scene-tag i { background: #f3bf7e; width: 6px; height: 6px; border-radius: 50%; }
.scene-tag span { font-family: system-ui, sans-serif; color: #f0cba7; }
.sound-button { display: inline-flex; min-height: 44px; align-items: center; gap: 6px; padding-inline: 11px; pointer-events: auto; }
.sound-button[aria-pressed="true"] { color: #412a21; background: #fae0b9; border-color: #fae0b9; }
.scene-hint {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 13px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 11px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
}
.incense {
  position: absolute;
  z-index: 1;
  left: var(--incense-x, 50%);
  top: var(--incense-y, 74%);
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.incense i {
  position: absolute;
  left: -8px;
  bottom: 0;
  width: 16px;
  height: 24px;
  border-radius: 50%;
  background: #fff5e3;
  filter: blur(4px);
  opacity: 0;
}
.stage[data-offering] .incense i { animation: rise 2.3s ease-out both; }
.stage[data-offering] .incense i:nth-child(2) { animation-delay: .34s; }
.stage[data-offering] .incense i:nth-child(3) { animation-delay: .68s; }
@keyframes rise {
  0% { opacity: 0; transform: translate(0, 0) scale(.45); }
  20% { opacity: .75; }
  72% { opacity: .39; }
  100% { opacity: 0; transform: translate(22px, -96px) scale(2.2); }
}

.ritual {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 25px 30px 28px;
}
.eyebrow { margin: 0; font-size: .75rem; font-weight: 750; color: #8d493a; letter-spacing: .12em; }
.eyebrow span { display: inline-block; vertical-align: middle; width: 14px; height: 1px; margin: 0 4px; background: #bc8a71; }
h1, h2 { font-family: var(--serif); }
h1 { margin: 8px 0 6px; font-size: clamp(1.92rem, 4vw, 2.65rem); font-weight: 800; line-height: 1.22; letter-spacing: .04em; }
.ritual-copy > p:last-child { margin: 0; color: var(--muted); font-size: .96rem; line-height: 1.65; }
.ritual-controls { min-width: 204px; text-align: center; }
.pray-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 9px 24px;
  border: 1px solid #83362c;
  border-radius: 13px;
  background: #9a4437;
  color: #fff7eb;
  font-size: 1.1rem;
  font-weight: 780;
  letter-spacing: .08em;
  box-shadow: 0 3px 0 #742f27;
}
.pray-button:hover { background: #87392f; }
.pray-button[aria-disabled="true"] { cursor: default; background: #784337; box-shadow: none; }
.pray-button svg { width: 26px; height: 26px; }
.ritual-message { margin: 10px 0 0; min-height: 1.3em; font-size: .81rem; color: var(--muted); }
.ritual-message[data-complete] { color: #7e3e32; font-weight: 650; }
.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 16px 2px max(16px, env(safe-area-inset-bottom));
  font-size: .75rem;
  color: var(--muted);
}
.footer-dot { margin-inline: 3px; color: #9b6e51; }
.connection::before {
  content: "";
  display: inline-block;
  vertical-align: 1px;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: #ae8264;
}
.connection[data-ready]::before { background: #59745f; }

dialog {
  width: min(430px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 12px 45px #24180f4f;
}
dialog::backdrop { background: #2d211c9c; }
dialog h2 { margin: 8px 0 16px; }
dialog dl { margin: 0 0 20px; }
dialog dt { margin: 12px 0 4px; font-weight: 750; }
dialog dd { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.65; }
.dialog-close { min-height: 44px; padding: 0 18px; border: 0; border-radius: 10px; background: var(--red); color: #fff7eb; font-weight: 700; }

@media (max-width: 620px) {
  .shell { width: calc(100% - 24px); }
  .masthead { padding-block: max(11px, env(safe-area-inset-top)) 11px; }
  .brand img { width: 40px; height: 40px; }
  .brand strong { font-size: 1.38rem; }
  .install-button { padding-inline: 10px; }
  .experience { border-radius: 18px; }
  .stage { height: clamp(320px, 101vw, 415px); border-radius: 17px 17px 0 0; }
  .stage-top { inset: 11px 10px auto; }
  .ritual { grid-template-columns: 1fr; gap: 16px; padding: 18px 17px 19px; }
  .ritual-controls { min-width: 0; }
  .ritual-message { margin-top: 9px; }
  .footer { padding-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .stage[data-offering] .incense i { animation: none; }
  .stage[data-offering] .incense i:first-child { opacity: .7; transform: translateY(-8px); }
}
