:root {
  --bg: #120c08;
  --glass: rgba(24, 16, 10, .82);
  --glass-2: rgba(36, 24, 14, .9);
  --line: rgba(255, 220, 160, .14);
  --text: #f6ead6;
  --muted: #c4ad8e;
  --gold: #e8b65a;
  --gold-2: #ffd98a;
  --red: #a8321f;
  --serif: 'Noto Serif', Georgia, serif;
  --sans: 'Be Vietnam Pro', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { font-family: var(--serif); margin: 0 0 .6rem; color: var(--gold-2); }
h3 { font-size: 1rem; margin-top: 1.1rem; }
h3 small { font: 500 .75rem var(--sans); color: var(--muted); }
.muted { color: var(--muted); font-size: .86rem; margin: 0 0 .8rem; }
.small { font-size: .76rem; }
.center { text-align: center; }
kbd { font: 600 .72rem var(--sans); padding: 0 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; margin-right: 4px; }

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; touch-action: none; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--gold-2); font: 600 1.1rem var(--serif); z-index: 100; transition: opacity .6s; }
.loading.done { opacity: 0; pointer-events: none; }

/* top bar */
.topbar { position: fixed; top: 0; left: 0; right: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 8px max(14px, env(safe-area-inset-left)); background: linear-gradient(#0a0604cc, #0a060400); pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--gold); font: 700 1.2rem var(--serif); text-shadow: 0 1px 6px #000; }
.brand svg { width: 28px; height: 28px; }
.lunar { flex: 1; text-align: center; font-size: .82rem; color: var(--text); text-shadow: 0 1px 4px #000; }
.lunar b { color: var(--gold-2); }
.top-actions { display: flex; align-items: center; gap: 6px; }
.online { font-size: .8rem; padding: 4px 10px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); white-space: nowrap; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; min-width: 34px; padding: 0 8px; justify-content: center; border-radius: 10px; border: 1px solid var(--line); background: var(--glass); font-size: .8rem; }
.icon-btn[hidden] { display: none; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--gold-2); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#sound-btn .cross, #sound-btn.muted .wave { display: none; }
#sound-btn.muted .cross { display: inline; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff4d3d; box-shadow: 0 0 0 3px #ff4d3d44; }
.notice { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 19; padding: 6px 14px; border-radius: 999px; background: var(--glass); border: 1px solid #e8b65a55; color: var(--gold-2); font-size: .85rem; max-width: calc(100% - 32px); text-align: center; }

/* floating labels over halls */
.labels { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.room-label { position: absolute; transform: translate(-50%, -100%); pointer-events: auto; padding: 5px 12px 6px; border-radius: 10px; border: 1px solid #e8b65a66; background: rgba(90, 20, 10, .78); color: var(--gold-2); text-align: center; line-height: 1.2; white-space: nowrap; box-shadow: 0 6px 16px #0007; transition: transform .15s, background .15s; }
.room-label b { display: block; font: 700 .9rem var(--serif); }
.room-label small { font-size: .7rem; color: #f3dcb4; }
.room-label:hover, .room-label.hot { background: rgba(140, 36, 18, .92); transform: translate(-50%, -100%) scale(1.06); }
.room-label.here { border-color: var(--gold-2); box-shadow: 0 0 0 2px #ffd98a55, 0 6px 16px #0007; }

/* gate */
.gate, .modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at center, #0000 30%, #000a 100%); }
.gate[hidden], .modal[hidden] { display: none; }
.gate-card { width: min(400px, 100%); padding: 22px; border-radius: 18px; background: var(--glass-2); border: 1px solid var(--line); box-shadow: 0 30px 80px #000c; backdrop-filter: blur(10px); }
.gate-card h1 { font-size: 1.6rem; text-align: center; }
.gate-card label, .field { display: block; margin-bottom: 12px; font-size: .82rem; color: var(--muted); }
.field > span { display: block; margin-bottom: 6px; }
.gate-card input:not([type=radio]) { display: block; width: 100%; margin-top: 4px; padding: .7rem .85rem; border-radius: 11px; border: 1px solid var(--line); background: #0e0805; color: var(--text); font: 600 1rem var(--sans); }
input:focus, textarea:focus { outline: 2px solid #e8b65a66; border-color: var(--gold); }
.seg { display: flex; gap: 6px; }
.seg label { flex: 1; margin: 0; }
.seg input, .kinds input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 8px; border-radius: 10px; border: 1px solid var(--line); color: var(--text); font-size: .9rem; cursor: pointer; }
.seg input:checked + span { background: var(--gold); color: #2a1606; font-weight: 600; border-color: var(--gold); }
.seg input:focus-visible + span, .kinds input:focus-visible + span { outline: 2px solid var(--gold-2); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid #0006; box-shadow: inset 0 -4px 8px #0003; }
.swatches button.on { outline: 2px solid var(--gold-2); outline-offset: 2px; }
.btn-gold { padding: .65rem 1.1rem; border-radius: 11px; border: 0; background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #2a1606; font-weight: 600; }
.btn-gold.big { width: 100%; padding: .85rem; font-size: 1rem; margin-top: 4px; }
.btn-gold:disabled { opacity: .6; }
.btn-ghost { padding: .4rem .8rem; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-size: .82rem; }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-2); }
.form-msg { min-height: 1.3em; margin: .5rem 0 0; font-size: .85rem; color: var(--gold-2); }
.form-msg.err { color: #ff9b84; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* board */
.board-card { position: fixed; top: 54px; left: 12px; z-index: 15; width: 250px; border-radius: 14px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); overflow: hidden; }
.board-head { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 10px 12px; border: 0; background: none; text-align: left; }
.board-head > b { font: 700 .95rem var(--serif); color: var(--gold-2); }
.board-head span { font-size: .75rem; color: var(--muted); }
.board-head span b { color: var(--gold-2); }
.board-card.collapsed .board-body { display: none; }
.board-body { padding: 0 10px 10px; }
.tabs { display: flex; gap: 4px; padding: 3px; border-radius: 9px; background: #0006; margin-bottom: 6px; }
.tabs button { flex: 1; padding: 4px; border: 0; border-radius: 7px; background: none; font-size: .76rem; color: var(--muted); }
.tabs button.on { background: #ffffff14; color: var(--text); }
.board { list-style: none; margin: 0; padding: 0; max-height: 40vh; overflow-y: auto; counter-reset: r; }
.board li { display: grid; grid-template-columns: 20px 1fr auto; gap: 6px; align-items: center; padding: 5px 2px; border-bottom: 1px dashed var(--line); counter-increment: r; }
.board li::before { content: counter(r); font: 600 .75rem var(--serif); color: var(--muted); text-align: center; }
.board li:nth-child(1)::before { color: #ffd34d; }
.board li:nth-child(2)::before { color: #ddd; }
.board li:nth-child(3)::before { color: #d08a4a; }
.board .n { min-width: 0; }
.board .n b { display: block; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board .n small { font-size: .68rem; color: var(--muted); }
.board .m { font: 700 .9rem var(--serif); color: var(--gold-2); }
.board li.me { background: #e8b65a1c; border-radius: 6px; }
.board .empty { display: block; text-align: center; color: var(--muted); font-size: .8rem; }
.board .empty::before { content: none; }
.rules { margin: 8px 0 0; font-size: .68rem; color: var(--muted); }

/* activity panel */
.panel { position: fixed; top: 54px; right: 12px; bottom: 96px; z-index: 15; width: 360px; display: flex; flex-direction: column; border-radius: 16px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); animation: slideIn .35s ease-out; }
.panel[hidden] { display: none; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-head b { display: block; font: 700 1.1rem var(--serif); color: var(--gold-2); }
.panel-head small { font-size: .76rem; color: var(--muted); }
.panel-body { padding: 14px; overflow-y: auto; flex: 1; }
.room { display: none; }
.room.on { display: block; }

.act { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 6px; border-radius: 12px; border: 1px solid var(--line); background: #ffffff0a; font-size: 1.3rem; line-height: 1.1; transition: transform .1s, background .2s; }
.act b { font: 600 .76rem var(--sans); }
.act small { font-size: .68rem; color: var(--muted); }
.act:hover { background: #ffffff16; border-color: #e8b65a66; }
.act:active { transform: scale(.95); }
.act.cooling { opacity: .45; pointer-events: none; }
.act .ico { width: 24px; height: 24px; fill: none; stroke: var(--gold-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.offer-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

textarea { width: 100%; padding: .6rem .75rem; border-radius: 11px; border: 1px solid var(--line); background: #0e0805; color: var(--text); font: inherit; resize: vertical; margin-bottom: 8px; }
.kinds { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.kinds span { display: inline-block; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line); font-size: .8rem; cursor: pointer; }
.kinds input:checked + span { background: var(--gold); color: #2a1606; border-color: var(--gold); font-weight: 600; }
.count { color: var(--muted); font-size: .75rem; }
.wall { list-style: none; margin: 0; padding: 0; }
.wall li { padding: .6rem .75rem; margin-bottom: 6px; border-radius: 10px; background: #0005; border-left: 3px solid var(--gold); }
.wall li.new { animation: wishIn .8s ease-out; }
@keyframes wishIn { from { background: #4a2e10; transform: translateY(-6px); opacity: 0; } }
.wall li[data-kind="cau-sieu"] { border-left-color: #8fa3c9; }
.wall li[data-kind="sam-hoi"] { border-left-color: #b98ad6; }
.wall li[data-kind="tri-an"] { border-left-color: #7fc49a; }
.wall .meta { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }
.wall .meta b { color: var(--gold-2); }
.wall p { margin: 2px 0 0; font-family: var(--serif); font-size: .92rem; overflow-wrap: anywhere; }
.wall .empty { border: 0; background: none; text-align: center; color: var(--muted); }

.med-clock { text-align: center; padding: 18px 0 10px; }
.med-clock span { display: block; font: 700 3rem var(--serif); color: var(--gold-2); font-variant-numeric: tabular-nums; }
.med-clock small { color: var(--muted); }

.niem { position: relative; display: grid; place-items: center; width: 210px; height: 210px; margin: 6px auto; border: 0; background: none; border-radius: 50%; -webkit-tap-highlight-color: transparent; }
.beads { position: absolute; inset: 0; width: 100%; height: 100%; }
.beads circle { fill: #5a3818; transition: fill .2s; }
.beads circle.lit { fill: var(--gold); }
.beads circle.cur { fill: #fff2c9; }
.niem-text { font: 600 1.15rem/1.35 var(--serif); color: var(--gold-2); }
.niem:active .niem-text { transform: scale(.95); }
.stats2 { display: flex; justify-content: center; gap: 2rem; margin: 8px 0; text-align: center; }
.stats2 b { display: block; font: 700 1.5rem var(--serif); color: var(--gold-2); }
.stats2 small { font-size: .74rem; color: var(--muted); }

.kinh-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.kinh-head b { font-family: var(--serif); font-size: .9rem; }
.kinh { font: .98rem/1.85 var(--serif); }
.kinh p { margin: 0 0 .6rem; }
.kinh .w.on { color: var(--gold-2); text-shadow: 0 0 10px #e8b65a99; }
.kinh .w.done { color: #d9c4a2; }

.lay-btn { display: block; width: 180px; height: 180px; margin: 10px auto; border-radius: 50%; border: 2px solid #e8b65a88; background: radial-gradient(circle at 40% 35%, #c9452b, #6a160b); box-shadow: 0 10px 30px #0008, inset 0 -8px 20px #0006; text-align: center; }
.lay-btn span { display: block; font: 700 2rem var(--serif); color: var(--gold-2); }
.lay-btn small { font-size: .7rem; color: #f3dcb4; }
.lay-btn:active { transform: scale(.96); }
.lay-btn.cooling { opacity: .6; pointer-events: none; }
.progress { height: 6px; border-radius: 3px; background: #0006; overflow: hidden; margin: 6px 0 10px; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-2)); transition: width .3s; }

.qa-item { padding: .7rem .8rem; margin-bottom: 8px; border-radius: 10px; background: #0005; }
.qa-item .q { font-weight: 600; font-size: .88rem; }
.qa-item .q small { display: block; font-weight: 400; color: var(--muted); font-size: .72rem; }
.qa-item .a { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); font-family: var(--serif); font-size: .9rem; white-space: pre-wrap; }
.qa-item .pending { color: var(--muted); font-size: .78rem; font-style: italic; margin-top: 4px; }

/* bottom room bar */
.roombar { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 16; display: flex; gap: 10px; align-items: stretch; padding: 8px; border-radius: 18px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); max-width: calc(100% - 24px); }
.roombar[hidden] { display: none; }
.rooms, .quick { display: flex; gap: 6px; }
.quick { padding-left: 10px; border-left: 1px solid var(--line); }
.room-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 78px; padding: 6px 8px; border-radius: 12px; border: 1px solid transparent; background: none; line-height: 1.15; }
.room-btn b { font: 600 .78rem var(--sans); }
.room-btn small { font-size: .66rem; color: var(--muted); }
.room-btn:hover { background: #ffffff10; }
.room-btn.on { border-color: var(--gold); background: #e8b65a1f; }
.room-btn .ic { font-size: 1.2rem; }
.act.small { padding: 6px 8px; font-size: 1.1rem; min-width: 56px; }
.hint { position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 14; margin: 0; padding: 4px 12px; border-radius: 999px; background: #0008; font-size: .76rem; color: #f3e6d0cc; pointer-events: none; white-space: nowrap; }

.toasts { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 30; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { padding: 6px 14px; border-radius: 999px; background: #000c; border: 1px solid #e8b65a44; font-size: .82rem; animation: toast 4.5s forwards; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
@keyframes toast { 0% { opacity: 0; transform: translateY(-8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

.pop { position: fixed; top: 54px; right: 12px; z-index: 25; width: 300px; padding: 12px; border-radius: 14px; background: var(--glass-2); border: 1px solid var(--line); backdrop-filter: blur(8px); }
.pop[hidden] { display: none; }
.pop > b { display: block; font: 700 1rem var(--serif); color: var(--gold-2); margin-bottom: 4px; }
.lich-row { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.lich-row:last-child { border: 0; }
.lich-row .d { width: 46px; height: 46px; flex: none; border-radius: 10px; background: #0006; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.lich-row .d b { display: block; font: 700 1.05rem var(--serif); color: var(--gold-2); }
.lich-row .d small, .lich-row .t small { font-size: .68rem; color: var(--muted); }
.lich-row .t b { display: block; font-size: .85rem; font-weight: 600; }

.live-card { width: min(900px, 100%); border-radius: 16px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.live-card header { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--glass-2); }
.live-frame { aspect-ratio: 16 / 9; }
.live-frame iframe, .live-frame video { width: 100%; height: 100%; border: 0; display: block; }

@media (max-width: 860px) {
  .lunar { display: none; }
  .topbar { justify-content: space-between; }
  .online { display: none; }
  .board-card { width: 200px; }
  .board-card:not(.touched) { }
  .panel { top: auto; left: 8px; right: 8px; bottom: 88px; width: auto; max-height: 52vh; animation: slideUp .35s ease-out; }
  @keyframes slideUp { from { transform: translateY(30px); opacity: 0; } }
  .roombar { left: 8px; right: 8px; transform: none; max-width: none; overflow-x: auto; padding: 6px; gap: 6px; }
  .room-btn { min-width: 64px; padding: 4px; }
  .room-btn small { display: none; }
  .quick { padding-left: 6px; }
  .act.small b { display: none; }
  .act.small { min-width: 40px; }
  .hint { display: none; }
  .pop { right: 8px; left: 8px; width: auto; }
}
