:root {
  color-scheme: dark;
  --bg: #101917;
  --panel: rgba(7, 18, 26, 0.76);
  --panel-strong: rgba(8, 23, 34, 0.92);
  --line: rgba(215, 178, 112, 0.25);
  --cyan: #d7b270;
  --cyan-strong: #e8c990;
  --green: #8bc9b9;
  --orange: #ffb45c;
  --text: #f4eee1;
  --muted: #9dab9f;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 40%, rgba(20, 73, 94, 0.24), transparent 44%),
    radial-gradient(circle at 20% 80%, rgba(87, 42, 18, 0.18), transparent 38%),
    var(--bg);
  color: var(--text);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(2, 7, 10, 0.52), transparent 18%, transparent 78%, rgba(2, 6, 9, 0.55)),
    radial-gradient(circle at 50% 50%, transparent 52%, rgba(0, 0, 0, 0.42) 100%);
  z-index: 1;
}

canvas#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

.hidden {
  display: none !important;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 38%, rgba(39, 121, 145, 0.18), transparent 42%),
    rgba(3, 7, 11, 0.84);
  backdrop-filter: blur(14px);
}

.loading-card,
.error-card {
  width: min(560px, 92vw);
  padding: 42px 44px 38px;
  border: 1px solid rgba(94, 220, 255, 0.24);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(14, 35, 47, 0.92), rgba(5, 12, 18, 0.94)),
    var(--panel);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.eyebrow {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.loading-card h1,
.error-card h1 {
  margin: 12px 0 26px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.loading-card > p,
.error-card > p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.loading-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(94, 220, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(94, 220, 255, 0.12);
}

.loading-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f9ec2, var(--cyan), var(--green));
  box-shadow: 0 0 18px rgba(94, 220, 255, 0.55);
  transition: width 180ms ease;
}

.loading-detail {
  margin-top: 12px;
  color: var(--cyan-strong);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.loading-hint {
  margin: 22px 0 0 !important;
  color: rgba(137, 167, 181, 0.68) !important;
  font-size: 12px;
}

#hud {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.topbar {
  position: absolute;
  inset: 24px 26px auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px 15px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(9, 24, 34, 0.82), rgba(7, 13, 20, 0.62));
  box-shadow: var(--shadow);
  backdrop-filter: blur(13px);
}

.brand-mark {
  position: relative;
  width: 13px;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--cyan), rgba(94, 220, 255, 0.05));
  box-shadow: 0 0 24px rgba(94, 220, 255, 0.62);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 9px 4px auto;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 18px rgba(125, 255, 207, 0.82);
}

.brand h1 {
  margin: 4px 0 0;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 9px;
  padding-right: 60px;
  pointer-events: auto;
}

.ghost-button {
  appearance: none;
  border: 1px solid rgba(110, 181, 203, 0.24);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(8, 18, 26, 0.72);
  color: rgba(227, 246, 255, 0.86);
  font: 600 12px/1 "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition:
    border-color 160ms ease,
    color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.ghost-button:hover {
  border-color: rgba(94, 220, 255, 0.64);
  background: rgba(15, 39, 52, 0.8);
  color: #fff;
  transform: translateY(-1px);
}

.ghost-button.muted {
  color: rgba(255, 180, 92, 0.84);
  border-color: rgba(255, 180, 92, 0.28);
}

#ar-slot {
  display: flex;
  align-items: center;
  min-height: 36px;
}

#ar-slot:empty {
  display: none;
}

#ARButton {
  appearance: none;
  border: 1px solid rgba(125, 255, 207, 0.36);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(8, 32, 28, 0.72);
  color: var(--green);
  font: 600 12px/1 "Segoe UI", "Microsoft YaHei", sans-serif;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

#ARButton:hover {
  border-color: rgba(125, 255, 207, 0.8);
  background: rgba(13, 46, 40, 0.88);
}

.status-card,
.hint-card,
.help-panel {
  position: absolute;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(8, 22, 31, 0.84), rgba(5, 11, 17, 0.66));
  box-shadow: var(--shadow);
  backdrop-filter: blur(15px);
}

.status-card {
  left: 26px;
  bottom: 26px;
  width: min(340px, calc(100vw - 52px));
  padding: 18px 19px 17px;
  border-radius: 20px;
}

.status-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.status-head strong {
  color: var(--text);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.progress-track {
  height: 6px;
  margin: 11px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(94, 220, 255, 0.1);
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2f9ec2, var(--cyan), var(--green));
  box-shadow: 0 0 16px rgba(94, 220, 255, 0.5);
  transition: width 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.progress-note {
  color: rgba(137, 167, 181, 0.76);
  font-size: 11px;
}

.mode-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(94, 220, 255, 0.11);
  color: rgba(161, 218, 236, 0.78);
  font-size: 11px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(125, 255, 207, 0.9);
}

.status-line {
  min-height: 17px;
  margin-top: 8px;
  color: rgba(234, 248, 255, 0.9);
  font-size: 12px;
  line-height: 1.45;
}

.hint-card {
  right: 26px;
  bottom: 26px;
  width: min(360px, calc(100vw - 52px));
  padding: 16px 18px 15px;
  border-radius: 20px;
}

.hint-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px 14px;
  margin-top: 12px;
  color: rgba(194, 220, 231, 0.82);
  font-size: 11px;
}

.hint-card p {
  margin: 13px 0 0;
  color: rgba(137, 167, 181, 0.72);
  font-size: 11px;
  line-height: 1.55;
}

kbd {
  display: inline-block;
  min-width: 37px;
  margin-right: 3px;
  padding: 4px 5px;
  border: 1px solid rgba(94, 220, 255, 0.2);
  border-radius: 6px;
  background: rgba(94, 220, 255, 0.06);
  color: rgba(163, 232, 249, 0.92);
  font: 600 10px/1 "Segoe UI", sans-serif;
  text-align: center;
}

.help-panel {
  left: 50%;
  bottom: 26px;
  width: min(720px, calc(100vw - 52px));
  padding: 22px 24px 20px;
  border-radius: 22px;
  transform: translateX(-50%);
  pointer-events: auto;
  z-index: 8;
}

.help-title {
  color: var(--cyan);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.help-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 14px;
}

.help-columns h2 {
  margin: 0 0 7px;
  font-size: 13px;
  color: rgba(234, 248, 255, 0.94);
}

.help-columns p,
.help-foot {
  margin: 0;
  color: rgba(173, 201, 213, 0.78);
  font-size: 12px;
  line-height: 1.6;
}

.help-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(94, 220, 255, 0.12);
  color: rgba(137, 167, 181, 0.7);
}

.complete-badge {
  position: absolute;
  top: 106px;
  left: 50%;
  padding: 12px 20px;
  border: 1px solid rgba(125, 255, 207, 0.42);
  border-radius: 999px;
  background: rgba(8, 32, 28, 0.78);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition:
    opacity 300ms ease,
    transform 300ms ease;
  box-shadow: 0 0 34px rgba(125, 255, 207, 0.14);
}

.complete-badge.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.complete canvas#scene {
  filter: none;
}

body.sandbox {
  background: #eee8dc;
  color: #1b1712;
}

body.sandbox::after {
  display: none;
}

body.sandbox .topbar,
body.sandbox .status-card,
body.sandbox .hint-card,
body.sandbox .help-panel,
body.sandbox .complete-badge {
  display: none !important;
}

body.sandbox #sandbox-bar {
  display: flex;
}

#sandbox-bar {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 8;
  display: none;
  align-items: center;
  gap: 14px;
  max-width: min(920px, calc(100vw - 36px));
  padding: 13px 17px;
  border: 1px solid rgba(217, 194, 152, 0.26);
  border-radius: 999px;
  background: rgba(20, 17, 13, 0.9);
  box-shadow: 0 18px 48px rgba(51, 37, 21, 0.2);
  color: #f7f0e4;
  pointer-events: auto;
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
}

.sandbox-title {
  color: rgba(247, 240, 228, 0.56);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

#sandbox-count {
  color: #e5c17f;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#sandbox-status {
  overflow: hidden;
  color: rgba(247, 240, 228, 0.82);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.error-card {
  border-color: rgba(255, 180, 92, 0.3);
}

.error-card h1 {
  color: var(--orange);
}

@media (max-width: 900px) {
  .topbar {
    inset: 14px 14px auto;
  }

  .brand {
    padding: 11px 13px;
  }

  .brand h1 {
    font-size: 17px;
  }

  .brand-mark {
    height: 34px;
  }

  .ghost-button {
    padding: 8px 10px;
    font-size: 10px;
  }

  .status-card {
    left: 14px;
    bottom: 14px;
    width: min(310px, calc(100vw - 28px));
  }

  .hint-card {
    display: none;
  }

  .help-panel {
    bottom: 14px;
    width: calc(100vw - 28px);
    padding: 17px 18px;
  }

  .help-columns {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .complete-badge {
    top: 82px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Quiet museum palette. Keep the artifact and the next action dominant. */
.brand, .status-card, .help-panel, .loading-card {
  background: rgba(19, 30, 26, 0.93);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.brand { border: 0; background: transparent; box-shadow: none; backdrop-filter: none; }
.brand-mark { width: 3px; height: 44px; border-radius: 0; box-shadow: none; background: #d7b270; }
.brand-mark::after { display: none; }
.brand h1 { font-family: "Noto Serif SC", "Songti SC", SimSun, serif; font-weight: 500; letter-spacing: 0.06em; }
.ghost-button { background: rgba(20, 33, 28, 0.86); border-color: rgba(215, 178, 112, 0.28); color: #e8e4d7; }
.ghost-button:hover { background: #314b40; border-color: #d7b270; }
.ghost-button:disabled { opacity: 0.38; cursor: default; transform: none; }
.ghost-button:focus-visible { outline: 2px solid #e8c990; outline-offset: 4px; }
.hint-card { display: none; }
.progress-track i, .loading-track i { background: linear-gradient(90deg, #8a9874, #d7b270); box-shadow: none; }
.status-dot { box-shadow: none; }
.mode-row { border-color: var(--line); color: #9dab9f; }
.complete-badge { background: #172e25; border-color: #d7b270; color: #ecd7ae; box-shadow: none; }
.entry-guide { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); text-align: center; width: max-content; max-width: calc(100vw - 32px); padding: 17px 26px; background: rgba(19, 30, 26, 0.92); border: 1px solid var(--line); border-radius: 12px; transition: opacity 350ms ease; }
.entry-guide p { margin: 9px 0 6px; font-size: 17px; letter-spacing: 0.05em; color: #fff5e4; }
.entry-guide p span { padding: 0 9px; color: #d7b270; }
.entry-guide small { color: #b6c6b9; font-size: 12px; }
body.repair-started .entry-guide { display: none; }
body.spatial-guidance .entry-guide { display: none; }
/* The spatial exhibit plaque carries completion. Keep the live status for AT. */
.complete-badge, .complete-badge.visible { width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); }
body.sandbox .entry-guide { bottom: 90px; }
body.sandbox .topbar { display: flex !important; }
body.sandbox .brand h1 { color: #302c22; }
body.sandbox .brand .eyebrow { color: #806a42; }
body.sandbox #ar-slot { display: none; }
body.sandbox .help-panel:not(.hidden) { display: block !important; color: #f4eee1; bottom: 88px; }
body.xr-active #hud, body.xr-active #sandbox-bar { display: none !important; }
@media (max-width: 1150px) {
  .entry-guide { left: auto; right: 26px; transform: none; padding: 16px; }
  .entry-guide p { font-size: 14px; }
  .entry-guide p span { padding: 0 4px; }
}
@media (max-width: 720px) {
  .topbar { flex-direction: column; gap: 6px; }
  .brand { padding: 8px 0; }
  .top-actions { justify-content: flex-start; gap: 6px; }
  .entry-guide { left: 14px; right: 14px; bottom: 205px; width: auto; }
  body.sandbox .entry-guide { bottom: 104px; }
  #sandbox-bar { border-radius: 12px; flex-wrap: wrap; gap: 8px; width: calc(100vw - 28px); }
  #sandbox-status { width: 100%; order: 3; white-space: normal; }
}
