:root {
  --ink: #2c2016;
  --cream: #f6efe3;
  --card: rgba(246, 239, 227, 0.92);
  --line: rgba(44, 32, 22, 0.14);
  --accent: #c8734a;
  --sage: #7f9b7a;
  --shadow: 0 12px 34px rgba(44, 32, 22, 0.18);
  --radius: 16px;
  --font: "Noto Sans TC", "PingFang TC", "Hiragino Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #ded3c2;
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene.grabbing { cursor: grabbing; }
#scene.pointing { cursor: pointer; }

/* ---------- loading ---------- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: #ded3c2;
  transition: opacity 0.6s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
#loading p { margin: 0; font-size: 14px; letter-spacing: 0.12em; opacity: 0.6; }
.spark {
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--accent);
  animation: bob 1.1s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(-6px) rotate(-8deg); }
  50% { transform: translateY(6px) rotate(8deg); }
}

/* ---------- chrome ---------- */
#titlebar {
  position: fixed;
  top: 22px; left: 24px;
  z-index: 10;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
#titlebar h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
#titlebar p {
  margin: 4px 0 0;
  font-size: 13px;
  opacity: 0.55;
}

#progress {
  position: fixed;
  top: 22px; right: 24px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  pointer-events: none;
}
#progress .count { font-size: 13px; opacity: 0.6; }
#progress .count b { font-size: 19px; color: var(--accent); }
#progress .label { font-size: 11px; letter-spacing: 0.08em; opacity: 0.45; }

#tooltip {
  position: fixed;
  z-index: 20;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--cream);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -150%) scale(0.95);
  transition: opacity 0.14s ease, transform 0.14s ease;
}
#tooltip.show { opacity: 1; transform: translate(-50%, -160%) scale(1); }

#panel {
  position: fixed;
  right: 24px; bottom: 76px;
  z-index: 15;
  width: min(290px, calc(100vw - 48px));
  padding: 18px 20px 20px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  transition: opacity 0.26s ease, transform 0.26s ease;
}
#panel.hidden { opacity: 0; transform: translateY(12px) scale(0.98); pointer-events: none; }
#panel h2 { margin: 0 0 8px; font-size: 17px; }
#panel-state {
  margin: 0 0 8px;
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(127, 155, 122, 0.18);
  color: #4f6b4a;
  font-size: 12px;
  letter-spacing: 0.04em;
}
#panel-desc { margin: 0; font-size: 13px; line-height: 1.65; opacity: 0.7; }
#panel-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 26px; height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  opacity: 0.4;
  cursor: pointer;
}
#panel-close:hover { opacity: 0.9; background: var(--line); }

#hint {
  position: fixed;
  left: 50%; bottom: 20px;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 16px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 12px;
  opacity: 0.85;
  pointer-events: none;
  white-space: nowrap;
}
#hint kbd {
  font-family: inherit;
  font-size: 11px;
  padding: 2px 6px;
  margin-right: 4px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
}

@media (max-width: 720px) {
  #titlebar { top: 16px; left: 16px; }
  #titlebar h1 { font-size: 18px; }
  #progress { top: 16px; right: 16px; padding: 8px 11px; }
  #panel { right: 16px; left: 16px; bottom: 68px; width: auto; }
  #hint { gap: 10px; font-size: 11px; padding: 8px 12px; bottom: 14px; }
  #hint span:last-child { display: none; }
}
