:root {
  --ink: #2a1a14;
  --paper: rgba(252, 240, 222, 0.86);
  --cinnabar: #b8322a;
  --jade: #2e8b57;
  --gold: #d9a441;
  --font: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2c2458; font-family: var(--font); color: var(--ink); }
#app, #app canvas { position: fixed; inset: 0; display: block; width: 100%; height: 100%; }
body.hide-ui .ui { opacity: 0; pointer-events: none; }
.ui { transition: opacity 0.4s; }

.title {
  position: fixed; top: 20px; left: 24px; display: flex; gap: 14px; align-items: center;
  color: #fff6e6; text-shadow: 0 2px 10px rgba(60, 20, 30, 0.55); pointer-events: none;
}
.title h1 { margin: 0; font-size: 34px; letter-spacing: 12px; font-weight: 900; }
.title p { margin: 4px 0 0; font-size: 14px; letter-spacing: 4px; opacity: 0.92; }
.seal {
  width: 46px; height: 46px; background: var(--cinnabar); color: #fff1e0; font-size: 15px; line-height: 18px;
  display: flex; align-items: center; justify-content: center; text-align: center; border-radius: 4px;
  box-shadow: inset 0 0 0 2px rgba(255, 230, 200, 0.6), 0 2px 8px rgba(0, 0, 0, 0.25); font-weight: 900; text-shadow: none;
}

.hud {
  position: fixed; top: 20px; right: 20px; display: flex; gap: 6px; padding: 8px 10px;
  background: rgba(20, 12, 30, 0.35); border: 1px solid rgba(255, 220, 180, 0.25); border-radius: 10px;
  color: #ffeedd; backdrop-filter: blur(6px); font-size: 11px;
}
.hud div { display: flex; flex-direction: column; align-items: center; min-width: 46px; }
.hud b { font-size: 15px; font-family: ui-monospace, Menlo, monospace; }
.hud span { opacity: 0.7; letter-spacing: 2px; }

.panel {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
}
.group {
  display: flex; gap: 4px; padding: 5px; background: var(--paper); border-radius: 12px;
  box-shadow: 0 6px 20px rgba(40, 10, 20, 0.28); border: 1px solid rgba(184, 50, 42, 0.25);
}
.panel button {
  font-family: var(--font); font-size: 15px; font-weight: 700; color: var(--ink); background: transparent;
  border: 0; border-radius: 8px; min-width: 38px; height: 34px; padding: 0 10px; cursor: pointer; transition: background 0.2s, color 0.2s;
}
.panel button.wide { padding: 0 14px; }
.panel button:hover { background: rgba(184, 50, 42, 0.12); }
.panel button.active { background: var(--cinnabar); color: #fff4e6; }

.hint {
  position: fixed; left: 24px; bottom: 26px; color: #fff3e0; font-size: 12px; letter-spacing: 2px; opacity: 0.9;
  text-shadow: 0 1px 2px rgba(40, 10, 20, 0.8), 0 0 8px rgba(40, 10, 20, 0.5); pointer-events: none;
}

#caption {
  position: fixed; top: 16%; left: 50%; transform: translateX(-50%); padding: 10px 26px; font-size: 20px; letter-spacing: 6px;
  color: #fff6e8; background: linear-gradient(90deg, transparent, rgba(30, 14, 30, 0.55) 15%, rgba(30, 14, 30, 0.55) 85%, transparent);
  opacity: 0; pointer-events: none; white-space: nowrap; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
#caption.show { animation: cap 5.8s ease forwards; }
@keyframes cap { 0% { opacity: 0; } 12% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0.0; } }

#labels { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.5s; }
#labels.show { opacity: 1; }
.floor-label { position: absolute; left: 0; top: 0; display: flex; align-items: center; white-space: nowrap; }
.floor-label span {
  font-size: 13px; font-weight: 700; letter-spacing: 2px; padding: 3px 10px; border-radius: 4px 0 0 4px;
  background: var(--cinnabar); color: #fff3e3; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.floor-label.dark span { background: #3b3350; }
.floor-label::after { content: ""; width: 26px; height: 2px; background: rgba(255, 240, 220, 0.8); }

#info {
  position: fixed; right: 20px; top: 84px; width: min(380px, calc(100vw - 40px)); max-height: calc(100vh - 190px); overflow: auto;
  background: var(--paper); border-radius: 12px; padding: 16px 20px; box-shadow: 0 10px 30px rgba(40, 10, 20, 0.35);
  border: 1px solid rgba(184, 50, 42, 0.3); transform: translateX(20px); opacity: 0; pointer-events: none; transition: all 0.35s;
}
#info.show { transform: none; opacity: 1; pointer-events: auto; }
#info h3 { margin: 0 0 6px; font-size: 20px; letter-spacing: 4px; color: var(--cinnabar); }
#info p { margin: 8px 0; font-size: 14px; line-height: 1.9; text-align: justify; }
#info .author { color: #7a5a4a; margin-top: 0; }
#info em { font-style: normal; color: var(--cinnabar); font-weight: 700; }
#info .poem { text-align: center; color: #4a2a20; }
#info-close { position: absolute; right: 10px; top: 8px; border: 0; background: none; font-size: 22px; cursor: pointer; color: #7a4a3a; }

#loading {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: linear-gradient(#2c2458, #8e3f6e 55%, #e8734a 85%, #ffc877); color: #fff3e0; letter-spacing: 3px; z-index: 10;
  transition: opacity 0.8s;
}
#loading.done { opacity: 0; pointer-events: none; }
.spinner { display: flex; gap: 6px; }
.spinner i { width: 14px; height: 14px; background: var(--jade); animation: hop 0.9s infinite ease-in-out; }
.spinner i:nth-child(2) { background: var(--cinnabar); animation-delay: 0.15s; }
.spinner i:nth-child(3) { background: var(--gold); animation-delay: 0.3s; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

@media (max-width: 720px) {
  .title h1 { font-size: 24px; letter-spacing: 6px; }
  .title p { font-size: 11px; letter-spacing: 1px; }
  .hud { display: none; }
  .hint { display: none; }
  .panel button { font-size: 13px; height: 30px; }
}
