:root {
  --bg: #2e3a2e;
  --gold: #e3b45a;
  --gold-2: #f5d48a;
  --ink: #fdf6e3;
  --muted: #cfc6ad;
  --panel: rgba(28, 32, 24, .62);
  --red: #8e1b16;
  --font: "Be Vietnam Pro", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; outline: none; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Sảnh ---------- */
#lobby {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; overflow-y: auto; padding: 24px 14px;
  background:
    radial-gradient(ellipse at 50% 10%, rgba(245, 212, 138, .35), transparent 60%),
    linear-gradient(180deg, #3d4a35 0%, #263022 100%);
}
.lobby-card {
  width: min(440px, 100%); text-align: center; padding: 28px 24px 18px;
  background: rgba(20, 24, 18, .55); border: 1px solid rgba(227, 180, 90, .35); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); backdrop-filter: blur(6px);
}
.lotus { font-size: 54px; line-height: 1; filter: drop-shadow(0 0 18px rgba(245,212,138,.7)); }
.lotus.spin { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); opacity: .8 } 50% { transform: scale(1.12); opacity: 1 } }
h1 { margin: 8px 0 4px; font-size: 30px; color: var(--gold-2); letter-spacing: .5px; font-weight: 700; }
.quote { margin: 0 0 18px; color: var(--muted); font-style: italic; min-height: 1.4em; }
.field { display: block; text-align: left; margin: 12px 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field small { color: var(--gold); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: rgba(0,0,0,.3);
  border: 1px solid rgba(227,180,90,.35); border-radius: 10px; padding: 11px 12px; outline: none;
}
select option { background: #26301f; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; padding: 0; }
.colors button.on { border-color: var(--gold-2); box-shadow: 0 0 0 2px rgba(0,0,0,.4) inset; }
.primary {
  background: linear-gradient(180deg, #e9bf68, #c48f32); color: #2a1d08; border: 0; border-radius: 12px;
  padding: 13px 22px; font-weight: 700; font-size: 16px; box-shadow: 0 6px 18px rgba(196,143,50,.35);
}
#enter { width: 100%; margin-top: 10px; font-size: 18px; }
.primary:hover { filter: brightness(1.07); }
.primary:disabled { opacity: .6; cursor: wait; }
.ghost { background: transparent; color: var(--gold-2); border: 1px solid rgba(227,180,90,.45); border-radius: 10px; padding: 10px 12px; white-space: nowrap; }
.msg { color: #ffb4a0; min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
.lobby-stats { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 10px 0; }
.recent { text-align: left; font-size: 13px; color: var(--muted); }
.recent summary { cursor: pointer; color: var(--gold); margin-bottom: 6px; }
.recent ul { list-style: none; margin: 0; padding: 0; max-height: 160px; overflow: auto; }
.recent li { padding: 5px 0; border-bottom: 1px dashed rgba(255,255,255,.08); }
.foot { font-size: 12px; color: #9aa38c; margin: 14px 0 0; }

#loading { position: fixed; inset: 0; z-index: 19; display: grid; place-content: center; text-align: center; background: var(--bg); color: var(--muted); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud > * { pointer-events: auto; }
.panel { background: var(--panel); border: 1px solid rgba(227,180,90,.25); border-radius: 12px; padding: 8px 12px; backdrop-filter: blur(4px); }
.top-left { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; display: flex; flex-direction: column; font-size: 13px; }
.top-left b { color: var(--gold-2); }
.top-right { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.stats { font-size: 13px; display: flex; gap: 10px; }
.btn-row { display: flex; gap: 6px; }
.icon { width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(227,180,90,.3); background: var(--panel); font-size: 18px; color: var(--ink); }
.icon.off { opacity: .45; }

#chatlog {
  position: absolute; left: 10px; bottom: 150px; width: min(340px, 60vw); max-height: 30vh; overflow-y: auto;
  font-size: 13px; line-height: 1.45; display: none; pointer-events: none;
}
#chatlog.has { display: block; }
#chatlog div b { color: var(--gold-2); }
#chatlog .pr { color: #ffe3a6; }
#chatlog .sys { color: var(--muted); font-style: italic; }

.bottom { position: absolute; left: 0; right: 0; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 8px; }
#chat-form { width: min(520px, 96vw); }
#chat-input { background: var(--panel); padding: 9px 12px; font-size: 14px; }
.actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.actions button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 78px; padding: 8px 8px 6px; border-radius: 12px; color: var(--ink);
  background: linear-gradient(180deg, rgba(60,46,22,.82), rgba(34,26,12,.82)); border: 1px solid rgba(227,180,90,.45);
  transition: transform .08s;
}
.actions button i { font-style: normal; font-size: 22px; }
.actions button span { font-size: 12px; }
.actions button kbd { position: absolute; top: 3px; right: 6px; font-size: 10px; color: var(--muted); font-family: inherit; }
.actions button:active, .actions button.pulse { transform: scale(.93); }
.actions button.cool { opacity: .5; }
#toast {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px;
  background: rgba(20,20,14,.75); color: var(--gold-2); font-size: 15px; opacity: 0; transition: opacity .3s; pointer-events: none; text-align: center;
}
#toast.show { opacity: 1; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(520px, 100%); max-height: 86vh; overflow: auto; background: #2a2f22; border: 1px solid rgba(227,180,90,.4); border-radius: 16px; padding: 20px; }
.modal-card h2 { margin: 0 0 10px; color: var(--gold-2); font-size: 20px; }
.modal-card ul { padding-left: 18px; line-height: 1.7; font-size: 14px; }
.modal-card textarea { resize: vertical; margin: 6px 0 12px; }
.muted { color: var(--muted); font-size: 13px; }
.prayer-list { list-style: none; padding: 0 !important; }
.prayer-list li { padding: 8px 0; border-bottom: 1px dashed rgba(255,255,255,.1); }
.prayer-list li b { color: var(--gold-2); }
.prayer-list li small { color: #9aa38c; margin-left: 6px; }

@media (max-width: 600px) {
  .actions button { min-width: 60px; padding: 6px 4px 5px; }
  .actions button span { font-size: 10.5px; }
  .actions button kbd { display: none; }
  .stats { font-size: 11.5px; gap: 7px; }
  .icon { width: 34px; height: 34px; font-size: 16px; }
  #chatlog { bottom: 130px; font-size: 12px; }
}
