:root {
  color-scheme: dark;
  --bg: #050607;
  --text: #eef1ea;
  --muted: #a5afa7;
  --quiet: #7f8a83;
  --accent: #cfe3b4;
  --ice: #cfe0f1;
  --hair: rgb(222 238 214 / 10%);
  --glass: rgb(13 17 19 / 62%);
  --heading: "Space Grotesk", "DM Sans", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --body: "DM Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Noto Sans SC", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  min-width: 300px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #0d1114, var(--bg) 70%);
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  opacity: 0;
  transition: opacity 1.2s var(--ease);
}

.is-ready #scene {
  opacity: 1;
}

#scene.is-dragging {
  cursor: grabbing;
}

#scene:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgb(207 227 180 / 55%);
}

/* ---------- Top bar: the site's <tipo-bar> (/tipo/tipo.css), over the room ---------- */
tipo-bar {
  --reserve: top;
  position: fixed;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  max-width: none;
  padding: max(14px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 14px max(24px, env(safe-area-inset-left));
  background: linear-gradient(rgb(5 6 7 / 55%), transparent);
  pointer-events: none;
}

tipo-bar > * {
  pointer-events: auto;
}

.top-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgb(222 238 214 / 14%);
  border-radius: 12px;
  background: rgb(255 255 255 / 4%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.icon-btn:hover {
  border-color: rgb(222 238 214 / 26%);
  background: rgb(255 255 255 / 9%);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.i-speaker {
  fill: currentColor;
}

.i-dot {
  stroke-width: 2.4;
}

.i-mute,
.i-off,
#soundBtn[aria-pressed="false"] .i-wave {
  display: none;
}

#soundBtn[aria-pressed="false"] .i-mute,
#spinBtn[aria-pressed="false"] .i-off {
  display: inline;
}

#soundBtn[aria-pressed="false"],
#spinBtn[aria-pressed="false"] {
  color: var(--quiet);
}

/* ---------- Museum placard ---------- */
.placard {
  --reserve: none;
  position: fixed;
  z-index: 1;
  bottom: max(32px, env(safe-area-inset-bottom));
  left: max(32px, env(safe-area-inset-left));
  width: min(320px, 30vw);
  pointer-events: none;
  animation: rise 1.2s var(--ease) 0.2s backwards;
}

.eyebrow {
  display: block;
  margin: 0;
  color: var(--quiet);
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.placard h1 {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 14px 0 0;
  font-weight: 400;
}

.placard h1 [lang="zh"] {
  width: fit-content;
  background: linear-gradient(180deg, #f8faf4 30%, #b8c4b3);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font: 600 34px/1.2 var(--body);
  letter-spacing: 0.14em;
}

.placard h1 em {
  width: fit-content;
  padding: 0 0.1em 0.12em 0;
  background: linear-gradient(100deg, #eef6ff 10%, #b8cee3 55%, #d9cdee 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font: italic 400 30px/1.05 var(--serif);
  letter-spacing: -0.01em;
}

.caption {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.story-link {
  margin-top: 12px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--ice);
  font-size: 13.5px;
  letter-spacing: 0.04em;
  pointer-events: auto;
}

.story-link:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* The museum label's small print. */
.specs {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 16px;
  margin: 16px 0 0;
  padding: 13px 0 0;
  border-top: 1px solid var(--hair);
}

.specs div {
  display: contents;
}

.specs dt {
  color: var(--quiet);
  font: 500 11px/1.75 var(--mono);
  letter-spacing: 0.14em;
}

.specs dd {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
  letter-spacing: 0.05em;
}

/* ---------- Dock ---------- */
.dock {
  --reserve: bottom;
  position: fixed;
  z-index: 2;
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 62px);
  left: 50%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 8px 7px 16px;
  border: 1px solid var(--hair);
  border-radius: 999px;
  background: var(--glass);
  box-shadow: 0 24px 50px -24px rgb(0 0 0 / 80%), inset 0 1px rgb(255 255 255 / 4%);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  translate: -50% 0;
  animation: rise 1s var(--ease) 0.35s backwards;
}

.dock-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dock-label {
  color: var(--quiet);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.dock-rule {
  width: 1px;
  height: 22px;
  background: var(--hair);
}

.seg {
  display: flex;
  gap: 2px;
}

.seg button {
  flex-shrink: 0;
  min-width: 52px;
  min-height: 36px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
}

.seg button:hover {
  color: var(--text);
}

.seg button[aria-checked="true"] {
  border-color: rgb(214 230 245 / 22%);
  background: rgb(214 230 245 / 13%);
  color: #fff;
}

/* ---------- Hint, loading, fallback ---------- */
.hint {
  position: fixed;
  z-index: 1;
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 128px);
  left: 50%;
  margin: 0;
  color: rgb(222 230 236 / 62%);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  white-space: nowrap;
  translate: -50% 0;
  pointer-events: none;
  transition: opacity 1s var(--ease), translate 1s var(--ease);
  animation: rise 1s var(--ease) 1.4s backwards;
}

.hint.is-gone {
  opacity: 0;
  translate: -50% 6px;
}

.hint-touch {
  display: none;
}

@media (pointer: coarse) {
  .hint-fine {
    display: none;
  }

  .hint-touch {
    display: inline;
  }
}

/* A line about the light or stone just chosen, where the hint was. */
.caption-line {
  position: fixed;
  z-index: 1;
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 128px);
  left: 50%;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 7px 16px;
  overflow: hidden;
  border: 1px solid var(--hair);
  border-radius: 999px;
  background: rgb(10 13 15 / 55%);
  color: #dfe6ec;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  translate: -50% 8px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  pointer-events: none;
  transition: opacity 0.5s var(--ease), translate 0.5s var(--ease);
}

.caption-line.is-on {
  opacity: 1;
  translate: -50% 0;
}

/* The easter egg's title card. */
.wake {
  position: fixed;
  z-index: 1;
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 180px);
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
  text-align: center;
  white-space: nowrap;
  opacity: 0;
  translate: -50% 0;
  pointer-events: none;
}

.wake.is-on {
  animation: wake 5.4s var(--ease) forwards;
}

.wake [lang="zh"] {
  padding-left: 0.6em;
  color: #ffe1d3;
  font: 600 30px/1.2 var(--body);
  letter-spacing: 0.6em;
  text-shadow: 0 0 18px rgb(255 90 40 / 65%), 0 0 46px rgb(255 50 20 / 40%);
}

.wake em {
  color: #ffb49c;
  font: italic 400 24px/1 var(--serif);
  letter-spacing: 0.04em;
  text-shadow: 0 0 16px rgb(255 80 40 / 55%);
}

/* Opacity and transform only: an animated blur filter starves the canvas of frames on slow GPUs. */
@keyframes wake {
  0% {
    opacity: 0;
    transform: scale(0.94);
  }

  14% {
    opacity: 1;
    transform: none;
  }

  72% {
    opacity: 1;
    transform: none;
  }

  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* A small instrument readout: which way the skull faces, and the zoom. */
.dial {
  position: fixed;
  z-index: 1;
  right: max(32px, env(safe-area-inset-right));
  bottom: max(32px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--quiet);
  pointer-events: none;
  animation: rise 1.2s var(--ease) 0.5s backwards;
}

.dial svg {
  width: 40px;
  height: 40px;
  fill: none;
  stroke-linecap: round;
}

.dial-ring {
  stroke: rgb(222 238 214 / 20%);
  stroke-width: 1.2;
}

.dial-ticks {
  stroke: rgb(222 238 214 / 38%);
  stroke-width: 1.2;
}

.dial-needle {
  stroke: var(--ice);
  stroke-width: 1.8;
}

.dial-hub {
  fill: var(--ice);
}

.dial-read {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font: 500 11px/1.2 var(--mono);
  letter-spacing: 0.12em;
}

.dial-read b {
  color: var(--muted);
  font-weight: 500;
}

.loading {
  position: fixed;
  z-index: 1;
  top: 50%;
  left: 50%;
  margin: 0;
  color: var(--quiet);
  font: 12px var(--mono);
  letter-spacing: 0.2em;
  translate: -50% -50%;
  animation: breathe 1.8s ease-in-out infinite;
}

.fallback {
  position: fixed;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: min(420px, calc(100% - 40px));
  padding: 26px 26px 20px;
  border: 1px solid var(--hair);
  border-radius: 22px;
  background: var(--glass);
  color: var(--muted);
  line-height: 1.7;
  translate: -50% -50%;
}

.fallback p {
  margin: 0 0 12px;
}

.no-3d .dock,
.no-3d .hint,
.no-3d .dial,
.no-3d #spinBtn {
  display: none;
}

/* ---------- Story ---------- */
.about {
  width: min(580px, calc(100% - 32px));
  max-height: min(84vh, 720px);
  padding: 0;
  overflow: auto;
  border: 1px solid rgb(222 238 214 / 14%);
  border-radius: 24px;
  background: rgb(12 15 17 / 92%);
  color: var(--text);
  box-shadow: 0 40px 90px -30px rgb(0 0 0 / 90%);
}

.about::backdrop {
  background: rgb(2 3 4 / 55%);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.about[open] {
  animation: rise 0.6s var(--ease);
}

.about-card {
  padding: 30px 32px 26px;
}

.about h2 {
  margin: 12px 0 16px;
  font: 600 24px/1.3 var(--body);
  letter-spacing: 0.06em;
}

/* The heading takes the focus when the story opens, so it starts at its top. */
.about h2:focus {
  outline: none;
}

.about p {
  margin: 0 0 14px;
  color: #c9d1cb;
  font-size: 14.5px;
  line-height: 1.85;
}

.about .about-note {
  margin-top: 4px;
  color: var(--quiet);
  font-size: 12.5px;
}

.btn {
  min-height: 42px;
  margin-top: 6px;
  padding: 10px 22px;
  border: 1px solid rgb(214 230 245 / 26%);
  border-radius: 999px;
  background: rgb(214 230 245 / 12%);
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.08em;
  transition: background 0.2s;
}

.btn:hover {
  background: rgb(214 230 245 / 20%);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes breathe {
  50% {
    opacity: 0.35;
  }
}

/* ---------- The treasures' frame, laid over the skull's room (hall-frame.mjs) ---------- */
.hall-frame {
  position: fixed;
  z-index: 10;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s var(--ease);
}

.hall-frame.is-on {
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Small screens ---------- */
/* Narrower windows: the placard moves up to the top left, clear of the dock, without its small print. */
@media (max-width: 1240px) {
  .placard {
    top: calc(max(14px, env(safe-area-inset-top)) + 72px);
    bottom: auto;
  }

  .specs {
    display: none;
  }
}

/* The readout needs room beside the dock. */
@media (max-width: 1000px), (max-height: 520px) {
  .dial {
    display: none;
  }
}

/* Tablets and phones held upright: the placard becomes a compact title line under the top bar. */
@media (max-width: 1000px) and (min-height: 521px) {
  .placard {
    --reserve: top;
    top: calc(max(14px, env(safe-area-inset-top)) + 58px);
    right: 24px;
    bottom: auto;
    left: max(24px, env(safe-area-inset-left));
    width: auto;
  }

  .placard .eyebrow,
  .caption {
    display: none;
  }

  .placard h1 {
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
    margin: 0;
  }

  .placard h1 [lang="zh"] {
    font-size: 26px;
  }

  .placard h1 em {
    font-size: 25px;
  }

  .story-link {
    margin-top: 2px;
  }
}

@media (max-width: 640px) {
  tipo-bar {
    padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
  }

  .placard {
    --reserve: top;
    top: calc(max(10px, env(safe-area-inset-top)) + 54px);
    right: 16px;
    bottom: auto;
    left: 16px;
    width: auto;
  }

  .placard .eyebrow,
  .caption {
    display: none;
  }

  .placard h1 {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
    margin: 0;
  }

  .placard h1 [lang="zh"] {
    font-size: 22px;
    letter-spacing: 0.12em;
  }

  .placard h1 em {
    font-size: 21px;
  }

  .story-link {
    margin-top: 2px;
    font-size: 13px;
  }

  .dock {
    right: 12px;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 70px);
    left: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 6px;
    border-radius: 22px;
    translate: none;
  }

  .dock-group {
    gap: 6px;
    padding-left: 8px;
  }

  .dock-rule {
    display: none;
  }

  .seg {
    flex: 1;
  }

  .seg button {
    flex: 1;
    min-width: 0;
    padding: 7px 4px;
  }

  .hint {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 170px);
    font-size: 12px;
  }

  .caption-line {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 170px);
    padding: 7px 14px;
    border-radius: 16px;
    font-size: 12.5px;
    text-align: center;
    white-space: normal;
  }

  .wake {
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 216px);
  }

  .wake [lang="zh"] {
    font-size: 24px;
  }

  .wake em {
    font-size: 20px;
  }

  .about-card {
    padding: 24px 22px 20px;
  }
}

/* Phones on their side: little height, so the placard stays a small corner label. */
@media (max-height: 520px) and (min-width: 641px) {
  .placard .caption,
  .placard .eyebrow,
  .specs {
    display: none;
  }

  .placard h1 [lang="zh"] {
    font-size: 22px;
  }

  .placard h1 em {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }

  /* No fade, but the title card still shows while the skull is awake. */
  .wake.is-on {
    opacity: 1;
  }
}

/* ---------- English and 中EN ---------- */
/* A sentence in English runs wider than its Chinese: the caption line takes two lines rather than cut it short. */
html[lang='en'] .caption-line {
  width: max-content;
  max-width: min(560px, calc(100% - 32px));
  border-radius: 18px;
  letter-spacing: 0.02em;
  line-height: 1.45;
  text-align: center;
  white-space: normal;
  text-wrap: balance;
}

html[lang='en'] .about h2 {
  letter-spacing: 0.01em;
}

/* Letter-spacing that suits a few Chinese characters is too wide for English words. */
html[lang='en'] .dock-label,
html[lang='en'] .loading {
  letter-spacing: 0.04em;
}

html[lang='en'] .seg button,
html[lang='en'] .hint,
html[lang='en'] .btn,
html[lang='en'] .action,
html[lang='en'] .specs dd {
  letter-spacing: 0.01em;
}

/* 中EN: the English under the Chinese, a little smaller and quieter; the story paragraph by paragraph. */
html[data-lang='both'] .caption .en,
html[data-lang='both'] .specs .en,
html[data-lang='both'] .about h2 .en,
html[data-lang='both'] .fallback p .en {
  display: block;
  margin-top: 2px;
  color: var(--quiet);
  font-size: 0.9em;
  letter-spacing: 0.01em;
}

html[data-lang='both'] .story-link .en {
  margin-left: 0.5em;
  opacity: 0.7;
}

html[data-lang='both'] .about p.zh {
  margin-bottom: 6px;
}

html[data-lang='both'] .about p.en {
  color: var(--quiet);
  font-size: 13.5px;
  line-height: 1.7;
}
