:root {
  --gold: #d9a441;
  --panel: rgba(28, 20, 14, 0.72);
  --panel-solid: #241a12;
  --text: #f5ead6;
  --muted: #c7b79b;
  --line: rgba(217, 164, 65, 0.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a120c; color: var(--text);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* Màn hình chờ */
#loading { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #4a2a14 0%, #1a100a 70%); transition: opacity .8s; }
#loading.done { opacity: 0; pointer-events: none; }
.loading-inner { text-align: center; padding: 24px; max-width: 420px; }
.lotus { font-size: 54px; color: var(--gold); animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.08); opacity: .8; } }
.ten-chua { font-family: 'Lora', serif; font-weight: 600; font-size: 34px; margin: 8px 0 4px; color: var(--gold); }
.loading-text { color: var(--muted); margin: 0 0 18px; }
.bar { height: 4px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }
.quote { font-family: 'Lora', serif; font-style: italic; color: var(--muted); margin-top: 22px; }

/* Thanh trên */
#topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: linear-gradient(rgba(20,12,6,.8), rgba(20,12,6,0)); flex-wrap: wrap; }
.brand { font-family: 'Lora', serif; font-weight: 600; color: var(--gold); font-size: 18px; margin-right: 6px; }
.brand .sep { margin: 0 6px; color: var(--muted); }
.brand #khu-vuc { color: var(--text); font-family: 'Be Vietnam Pro'; font-weight: 500; font-size: 14px; }
.pill { background: var(--panel); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; font-size: 13px; }
#online-pill { color: #9fdc8a; }
#online-pill b { color: var(--text); }
.spacer { flex: 1; }
.icon-btn { background: var(--panel); border: 1px solid var(--line); color: var(--text); width: 34px; height: 34px; border-radius: 50%; }
#notice { position: fixed; top: 58px; left: 50%; transform: translateX(-50%); z-index: 9; background: var(--panel);
  border: 1px solid var(--line); padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--muted);
  max-width: calc(100% - 32px); text-align: center; }

/* Thắp hương */
#btn-huong { position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 12; background: var(--gold);
  color: #2a1a0a; border: 0; padding: 12px 22px; border-radius: 999px; font-weight: 600; font-size: 16px;
  box-shadow: 0 6px 24px rgba(217,164,65,.45); animation: glow 2s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 6px 34px rgba(255,190,80,.8); } }

/* Chat */
#chat { position: fixed; left: 14px; bottom: 14px; z-index: 11; width: min(380px, calc(100% - 28px)); }
#chat-log { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px;
  font-size: 14px; text-shadow: 0 1px 3px #000; mask-image: linear-gradient(transparent, #000 25%); }
#chat-log .line b { color: var(--gold); font-weight: 600; }
#chat-log .sys { color: #9fdc8a; font-style: italic; }
#chat-form { display: flex; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
#chat-input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text); padding: 6px 10px; font: inherit; font-size: 16px; }
#chat-form button { background: transparent; border: 0; color: var(--text); padding: 0 8px; }
#chat-form button[type=submit] { background: var(--gold); color: #2a1a0a; border-radius: 999px; padding: 6px 14px; font-weight: 600; }

/* Nhãn tên + bong bóng chat */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.label { position: absolute; transform: translate(-50%, -100%); text-align: center; white-space: nowrap; will-change: transform; }
.label .nm { font-size: 12px; font-weight: 600; color: #fff; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
.label.me .nm { color: var(--gold); }
.label .bubble { display: inline-block; max-width: 220px; white-space: normal; background: rgba(255,250,240,.95); color: #2a1a0a;
  font-size: 13px; padding: 5px 10px; border-radius: 12px; margin-bottom: 4px; }

/* Hướng dẫn */
#tutorial { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(0,0,0,.25); }
#tutorial .card { width: min(340px, calc(100% - 32px)); background: var(--panel-solid); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px 20px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.step-no { color: var(--muted); font-size: 13px; }
#tutorial h3 { font-family: 'Lora', serif; color: var(--gold); margin: 6px 0; }
#tutorial p { margin: 0 0 14px; line-height: 1.5; }
.dots { display: flex; gap: 6px; margin-bottom: 14px; }
.dots span { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.25); }
.dots span.on { width: 18px; background: var(--gold); }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.actions button { border: 0; border-radius: 999px; padding: 8px 16px; background: var(--gold); color: #2a1a0a; font-weight: 600; }
.actions .ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }

@media (max-width: 600px) {
  .brand { font-size: 16px; }
  #room-pill { display: none; }
  #chat-log { max-height: 120px; font-size: 13px; }
  #btn-huong { bottom: 120px; }
}
