:root {
  --bg-dark: rgba(26, 18, 12, 0.88);
  --bg-card: rgba(32, 22, 15, 0.94);
  --bg-glass: rgba(34, 24, 16, 0.82);
  --gold-primary: #d4af37;
  --gold-bright: #f7d66a;
  --gold-soft: rgba(212, 175, 55, 0.35);
  --lotus-pink: #f08ca7;
  --text-main: #f8f1e5;
  --text-muted: #cbb89d;
  --accent-red: #a63424;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-deep: 0 14px 38px rgba(0, 0, 0, 0.65);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: #0b162c;
  color: var(--text-main);
}

#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  /* Cử chỉ chạm (kéo, chụm 2 ngón) do cảnh 3D tự xử lý, không để trình duyệt cuộn / phóng trang */
  touch-action: none;
}

#canvas-container canvas {
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* =========================================================
   TOOLTIP TRÊN KHÔNG GIAN 3D & THÔNG BÁO DẤU MỐC TINH TẤN
   ========================================================= */
.scene-tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  transform: translate(-50%, -100%);
  background: var(--bg-dark);
  color: var(--gold-bright);
  border: 1px solid var(--gold-primary);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.dharma-toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(28, 20, 14, 0.94);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(212, 175, 55, 0.55);
  border-radius: 16px;
  padding: 12px 18px;
  max-width: 90vw;
  width: max-content;
  box-shadow: var(--shadow-deep);
  animation: fadeSlideDown 0.3s ease;
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translate(-50%, -12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.dharma-toast-icon {
  font-size: 1.7rem;
}

.dharma-toast-title {
  color: #fff6df;
  font-weight: 700;
  font-size: 0.94rem;
  margin-bottom: 2px;
}

.dharma-toast-text {
  color: var(--text-muted);
  font-size: 0.83rem;
  line-height: 1.35;
}

.toast-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
}

.toast-close-btn:hover {
  color: #fff;
}

/* =========================================================
   TOP HUD BAR (GIỐNG BỐ CỤC HÌNH 3)
   ========================================================= */
.top-hud {
  position: fixed;
  top: 12px;
  left: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  flex-wrap: wrap;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--gold-soft);
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.brand-badge:hover {
  border-color: var(--gold-bright);
}

.brand-lotus {
  font-size: 1.2rem;
}

.brand-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff5df;
}

.room-label {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.pill-divider {
  opacity: 0.35;
}

.hud-btn, .hud-profile-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--gold-soft);
  color: var(--text-main);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-gold-pill {
  background: linear-gradient(135deg, #e5be5c 0%, #c99a32 100%);
  color: #241608;
  border-color: #f7da82;
  font-weight: 700;
}

.btn-gold-pill:hover {
  filter: brightness(1.08);
  color: #1a0f04 !important;
}

.hud-btn:hover, .hud-profile-btn:hover, .hud-btn.active {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.avatar-color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1e62b8;
  border: 1.5px solid var(--gold-bright);
}

/* BẢNG ÂM THANH (mở từ nút loa): cố định góc phải dưới thanh trên cùng — thanh nút trên điện thoại cuộn ngang nên bảng
   không nằm trong thanh, không thì bị cắt */
.sound-panel {
  position: fixed;
  top: 60px;
  right: 14px;
  /* trên thông báo (.dharma-toast 45): đang mở bảng là đang thao tác trên bảng */
  z-index: 46;
  width: min(280px, calc(100vw - 28px));
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(30, 21, 14, 0.98);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}
.sound-panel[hidden] {
  display: none;
}
.sound-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}
.sound-row-master {
  border-color: var(--gold-soft);
}
.sound-row:focus-visible,
.sound-volume input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}
.sound-row-icon {
  width: 22px;
  text-align: center;
}
.sound-row-label {
  flex: 1;
  min-width: 0;
}
.sound-switch {
  min-width: 52px;
  padding: 5px 10px;
  border-radius: 999px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}
.sound-switch::after {
  content: 'Tắt';
}
.sound-row[aria-checked='true'] .sound-switch {
  background: linear-gradient(90deg, #e0a938, #f7d66a);
  color: #2a1a0c;
}
.sound-row[aria-checked='true'] .sound-switch::after {
  content: 'Bật';
}
.sound-volume {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 10px 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.sound-volume input {
  width: 100%;
  min-height: 32px;
  accent-color: var(--gold-bright);
}
/* Âm thanh tổng đang tắt: các mục con mờ đi (vẫn bấm được, bật lại tổng là theo lựa chọn đó) */
.sound-panel.is-muted .sound-row:not(.sound-row-master),
.sound-panel.is-muted .sound-volume {
  opacity: 0.45;
}

/* =========================================================
   BẢNG CẤP ĐỘ TU TẬP & NHIỆM VỤ TINH TẤN GÓC TRÁI TRÊN (HÌNH 3)
   ========================================================= */
.progression-card {
  position: fixed;
  top: 60px;
  left: 14px;
  z-index: 20;
  width: 256px;
  background: rgba(30, 21, 14, 0.86);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 16px;
  padding: 12px 13px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}

.prog-header {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.prog-bead-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.16);
  border: 1px solid rgba(212, 175, 55, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.prog-info {
  flex: 1;
}

.prog-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.86rem;
  color: #fff6e0;
  margin-bottom: 5px;
}

.prog-streak {
  font-size: 0.78rem;
  color: #ff9f43;
  font-weight: 700;
}

.prog-bar-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}

.prog-bar-Track {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.prog-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #e0a938, #f7d66a);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.prog-exp-text {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.prog-chevron {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.progression-card.collapsed .prog-tasks-body {
  display: none;
}

.progression-card.collapsed .prog-chevron {
  transform: rotate(180deg);
}

.prog-tasks-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prog-task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.task-icon {
  font-size: 1rem;
  width: 22px;
  text-align: center;
}

.task-meta {
  flex: 1;
  line-height: 1.25;
}

.task-meta strong {
  display: block;
  color: #f3ead8;
  font-weight: 600;
  font-size: 0.8rem;
}

.task-meta small {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.task-reward {
  color: var(--gold-bright);
  font-size: 0.76rem;
  font-weight: 700;
}

.task-action-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: #f5ead6;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.task-action-btn:hover {
  background: rgba(212, 175, 55, 0.22);
  border-color: var(--gold-bright);
}

.task-action-btn.done {
  background: rgba(76, 217, 100, 0.18);
  border-color: rgba(76, 217, 100, 0.5);
  color: #7ef092;
}

.prog-footer {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.prog-footer strong {
  color: var(--gold-bright);
}

/* =========================================================
   NÚT NGỮ CẢNH "Thắp hương [F]" PHÍA TRÊN DOCK (GIỐNG HÌNH 3)
   ========================================================= */
.context-action-pill {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(32, 23, 15, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(212, 175, 55, 0.5);
  color: #fff6e0;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  transition: transform 0.15s, border-color 0.2s;
}

.context-action-pill:hover {
  border-color: var(--gold-bright);
  transform: translateX(-50%) translateY(-2px);
}

.key-badge {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: var(--gold-bright);
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-family: inherit;
  font-weight: 700;
}

/* =========================================================
   BOTTOM RITUAL DOCK (BO TRÒN SANG TRỌNG NHƯ HÌNH 3)
   ========================================================= */
.ritual-dock {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(28, 20, 14, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(212, 175, 55, 0.42);
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow-deep);
  max-width: calc(100vw - 16px);
  overflow-x: auto;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 64px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 18px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.18s;
  flex-shrink: 0;
}

.dock-item:hover, .dock-item.active {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.45);
  transform: translateY(-2px);
}

.dock-icon {
  font-size: 1.32rem;
}

.dock-label {
  font-size: 0.73rem;
  font-weight: 600;
  color: #f3e6cf;
  white-space: nowrap;
}

/* =========================================================
   FLOATING PANELS (KHU VỰC, CHÀO HỎI, MENU THÊM)
   ========================================================= */
.floating-panel {
  position: fixed;
  z-index: 35;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1.5px solid var(--gold-primary);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-deep);
  width: 370px;
  max-width: calc(100vw - 24px);
}

.zones-panel {
  top: 58px;
  left: 14px;
}

.greetings-panel, .more-panel {
  bottom: 128px;
  left: 50%;
  transform: translateX(-50%);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.panel-header h3 {
  font-size: 1rem;
  color: var(--gold-bright);
}

.panel-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Menu "Thêm": lưới ô lớn theo nhóm (ô cao ≥ 72px, 3 cột; màn hẹp vẫn 3 cột nhưng chữ xuống dòng) */
.more-panel {
  max-height: calc(100vh - 150px);
  max-height: calc(100dvh - 150px);
  overflow-y: auto;
}

.more-group-title {
  margin: 10px 2px 6px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.more-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.more-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 76px;
  padding: 10px 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: var(--radius-md);
  color: var(--text-main);
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
}

.more-tile:hover, .more-tile:focus-visible {
  background: rgba(212, 175, 55, 0.16);
  border-color: var(--gold-bright);
}

.more-tile-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.more-tile-label {
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--gold-bright);
}

.zones-grid, .greetings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  max-height: 52vh;
  overflow-y: auto;
}

.zone-item, .greeting-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: all 0.18s;
}

.zone-item:hover, .greeting-item:hover {
  background: rgba(212, 175, 55, 0.16);
  border-color: var(--gold-bright);
}

.zone-icon, .greet-icon {
  font-size: 1.35rem;
}

.zone-text strong {
  display: block;
  font-size: 0.88rem;
  color: var(--gold-bright);
}

.zone-text small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* =========================================================
   JOYSTICK
   ========================================================= */
.movement-controls {
  position: fixed;
  bottom: 84px;
  left: 18px;
  z-index: 18;
  pointer-events: none;
}

.joystick-zone {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(45, 28, 18, 0.45), rgba(20, 12, 8, 0.68));
  border: 1.5px solid var(--gold-soft);
  position: relative;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.joystick-knob {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--gold-bright), #9e7818);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* =========================================================
   MODALS CHUNG
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(8, 5, 3, 0.76);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: linear-gradient(165deg, #281810 0%, #170e09 100%);
  border: 1.5px solid var(--gold-primary);
  border-radius: 22px;
  padding: 24px 26px;
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-deep);
  color: var(--text-main);
}

.modal-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.22);
}

.modal-top-bar h2 {
  font-size: 1.22rem;
  color: var(--gold-bright);
}

.modal-subtitle {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.close-x {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--text-main);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.close-x:hover {
  background: var(--accent-red);
  border-color: var(--gold-bright);
}

.character-modal {
  text-align: center;
  max-width: 540px;
}

/* Bảng chọn nhân vật: phần chọn cuộn được, nút "Bước vào" cố định ở đáy bảng (người mới không phải vuốt tìm).
   Chiều cao theo dvh: 90vh trên Safari iPhone tính cả phần bị thanh công cụ che → đáy bảng lọt dưới thanh */
.modal-card.character-modal {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  max-height: 90vh;
  max-height: 90dvh;
}

.character-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px 26px 6px;
}

.character-modal .modal-actions {
  flex-shrink: 0;
  padding: 12px 26px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(212, 175, 55, 0.22);
  background: rgba(23, 14, 9, 0.96);
}

.char-modal-head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-close-x {
  position: absolute;
  right: 0;
  top: 0;
  width: 44px;
  height: 44px;
}

.modal-lotus-header {
  font-size: 2.8rem;
  margin-bottom: 6px;
}

.character-modal h2 {
  color: var(--gold-bright);
  font-size: 1.38rem;
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 0.87rem;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.45;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 16px;
  background: rgba(12, 7, 4, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: var(--radius-md);
  padding: 4px;
}

.auth-tab {
  min-height: 44px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-md) - 3px);
  padding: 6px 6px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.25;
  transition: all 0.16s;
}

.auth-tab.active {
  background: rgba(212, 175, 55, 0.22);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.auth-logged-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.38);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 16px;
  text-align: left;
}

.auth-logged-info {
  min-width: 0;
  flex: 1;
}

.auth-user-badge {
  display: block;
  font-size: 0.88rem;
  color: var(--text-main);
  word-break: break-word;
}

.auth-user-badge strong {
  color: var(--gold-bright);
}

.auth-sync-note {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-auth-logout {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.auth-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: var(--radius-md);
  padding: 14px 14px 4px;
  margin-bottom: 14px;
}

.auth-pass-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 420px) {
  .auth-pass-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .auth-tab {
    font-size: 0.74rem;
    padding: 5px 3px;
  }
}

.auth-hint {
  font-size: 0.79rem;
  color: var(--text-muted);
  text-align: left;
  margin: 0 0 10px;
  line-height: 1.4;
}

.auth-status {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: rgba(212, 175, 55, 0.14);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: var(--gold-bright);
  text-align: left;
  font-size: 0.84rem;
}

.auth-status.is-error {
  background: rgba(180, 48, 36, 0.22);
  border-color: rgba(235, 95, 80, 0.55);
  color: #ffb8ae;
}

.form-group {
  text-align: left;
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-bright);
  margin-bottom: 7px;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

input[type="text"], input[type="password"], textarea, .sutra-select {
  width: 100%;
  background: rgba(12, 7, 4, 0.8);
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  user-select: text;
}

input[type="text"]:focus, input[type="password"]:focus, textarea:focus, .sutra-select:focus {
  border-color: var(--gold-bright);
}

.hair-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hair-option {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: var(--radius-md);
  padding: 9px 8px;
  color: var(--text-main);
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
}

.hair-option.active {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

/* Chỉ máy có chuột mới có hover: trên iPhone :hover dính lại sau khi chạm → trông như chọn 2 ô cùng lúc */
@media (hover: hover) {
  .hair-option:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold-bright);
    color: var(--gold-bright);
  }
  .robe-card:hover {
    background: rgba(212, 175, 55, 0.16);
    border-color: var(--gold-bright);
  }
}

.robe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.robe-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(212, 175, 55, 0.22);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  cursor: pointer;
  text-align: left;
}

.robe-card.active {
  background: rgba(212, 175, 55, 0.16);
  border-color: var(--gold-bright);
}

.robe-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--gold-bright);
  flex-shrink: 0;
}

.robe-meta strong {
  display: block;
  font-size: 0.84rem;
  color: var(--text-main);
}

.robe-meta small {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.25;
}

.btn-primary {
  background: linear-gradient(135deg, #e0b63e 0%, #b38418 100%);
  color: #1c1008;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 20px;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--gold-soft);
  color: var(--gold-bright);
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 9px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-large {
  width: 100%;
  padding: 13px 22px;
  font-size: 1.02rem;
}

/* MODAL TỤNG KINH, CHUỖI 108, THIỀN ĐỊNH, CẦU NGUYỆN */
.sutra-modal {
  max-width: 680px;
}

/* Tụng kinh — màn danh sách: thanh tụng tiếp + thẻ bài chia nhóm */
.chant-resume {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid var(--gold-primary);
  border-radius: 14px;
  background: rgba(212, 175, 55, 0.1);
  color: var(--text-main);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}
.chant-resume strong { color: var(--gold-bright); }
.chant-resume .chant-resume-go { margin-left: auto; color: var(--gold-bright); white-space: nowrap; }
.chant-group-title {
  margin: 16px 0 8px;
  font-size: 1rem;
  color: var(--gold-bright);
}
.chant-group-title:first-child { margin-top: 0; }
.chant-card {
  margin-bottom: 10px;
  padding: 14px 16px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}
.chant-card.is-featured {
  border-color: var(--gold-primary);
  background: rgba(212, 175, 55, 0.08);
}
.chant-card h4 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 6px;
  font-size: 1.02rem;
  color: #fff3d6;
}
.chant-badge {
  padding: 2px 8px;
  border: 1px solid var(--gold-primary);
  border-radius: 999px;
  font-size: 0.72rem;
  color: var(--gold-bright);
}
.chant-card p {
  margin: 0 0 10px;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-muted);
}
.chant-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chant-meta { font-size: 0.8rem; color: var(--text-muted); }
.chant-start {
  flex-shrink: 0;
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--gold-primary);
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.12);
  color: var(--gold-bright);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

/* Tụng kinh — màn đọc: chữ đã tụng vàng, chữ đang tụng gạch chân, dòng đang tụng to và sáng */
.chant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chant-back {
  min-height: 44px;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: var(--gold-bright);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.chant-percent { font-size: 0.8rem; color: var(--text-muted); }
.chant-title {
  margin: 2px 0 8px;
  font-size: 1.1rem;
  color: var(--gold-bright);
  text-align: center;
}
.chant-reader {
  position: relative;
  max-height: 38vh;
  max-height: 38dvh;
  overflow-y: auto;
  padding: 14px 16px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: var(--radius-md);
  background: rgba(14, 9, 6, 0.82);
  text-align: center;
}
.chant-line {
  margin: 0 0 10px;
  font-size: 1.02rem;
  line-height: 1.7;
  color: rgba(239, 229, 212, 0.45);
  transition: font-size 0.2s, color 0.2s;
}
.chant-line.is-current {
  font-size: 1.22rem;
  color: #fff8e6;
}
.chant-line.is-past { color: rgba(247, 214, 106, 0.55); }
.chant-syl {
  cursor: pointer;
  border-radius: 4px;
}
.chant-syl.is-done { color: var(--gold-bright); }
.chant-syl.is-cur {
  text-decoration: underline;
  text-decoration-color: var(--gold-bright);
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}
.chant-note-inline { font-size: 0.8em; font-style: italic; opacity: 0.7; }
.chant-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--gold-primary);
  border-radius: 14px;
  background: rgba(212, 175, 55, 0.1);
  text-align: center;
}
.chant-done[hidden] { display: none; }
.chant-done strong { color: var(--gold-bright); }
.chant-done span { font-size: 0.84rem; color: var(--text-muted); }
.chant-done-actions { display: flex; gap: 10px; margin-top: 4px; }
.chant-note {
  margin: 10px 0 4px;
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
}
.chant-instruments {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
}
.chant-mo {
  width: 120px;
  height: 120px;
  padding: 14px;
  border: 2px solid var(--gold-primary);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(212, 175, 55, 0.18), rgba(30, 21, 14, 0.9));
  cursor: pointer;
  transition: transform 0.08s;
  touch-action: manipulation;
}
.chant-mo svg { width: 100%; height: 100%; }
.chant-mo.pulse { transform: scale(0.93); }
.chant-bell {
  justify-self: end;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  min-height: 56px;
  padding: 6px;
  border: 1px solid var(--gold-soft);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 1.3rem;
  cursor: pointer;
  touch-action: manipulation;
}
.chant-bell small { font-size: 0.7rem; color: var(--text-muted); }
.chant-bell.pulse { transform: scale(0.93); }
.chant-auto {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.chant-auto .btn-secondary { min-height: 44px; min-width: 180px; }
.chant-bpm {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: min(100%, 280px);
  font-size: 0.82rem;
  color: var(--text-muted);
}
.chant-bpm input { width: 100%; min-height: 32px; accent-color: var(--gold-bright); }

.beads-Select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.beads-Select-row label {
  font-size: 0.86rem;
  color: var(--gold-bright);
  white-space: nowrap;
}

.mala-interactive-area {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 8px auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mala-svg {
  width: 100%;
  height: 100%;
}

.mala-center-info {
  position: absolute;
  inset: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.mala-chant-text {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 6px;
}

.mala-count-big {
  font-size: 2.3rem;
  font-weight: 800;
  color: #ffffff;
}

.mala-count-big small {
  font-size: 1rem;
  color: var(--text-muted);
}

.mala-rounds-badge {
  margin-top: 6px;
  font-size: 0.8rem;
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid var(--gold-soft);
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--gold-bright);
}

.beads-action-row {
  display: flex;
  gap: 10px;
}

.meditate-duration-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.dur-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--gold-soft);
  color: var(--text-main);
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.dur-pill.active, .dur-pill:hover {
  background: var(--gold-primary);
  color: #1c1008;
  border-color: var(--gold-bright);
}

.breathing-circle-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0 18px;
}

.breathing-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.28) 0%, rgba(44, 24, 14, 0.65) 100%);
  border: 2px solid var(--gold-bright);
  box-shadow: 0 0 36px rgba(212, 175, 55, 0.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 3.8s ease-in-out, box-shadow 3.8s ease-in-out;
}

.breathing-circle.inhale {
  transform: scale(1.16);
  box-shadow: 0 0 55px rgba(247, 214, 106, 0.65);
}

.breathing-circle.exhale {
  transform: scale(0.92);
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.25);
}

.breathing-lotus {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.breathing-phase {
  font-size: 0.92rem;
  color: var(--gold-bright);
  font-weight: 600;
}

.meditate-timer-display {
  font-size: 2rem;
  font-weight: 800;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.zen-quote-box {
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--gold-primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  text-align: center;
}

.wish-type-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.wish-tab {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--gold-soft);
  color: var(--text-main);
  padding: 9px 8px;
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
}

.wish-tab.active {
  background: rgba(212, 175, 55, 0.22);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}

.wish-compose-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 16px;
}

.wish-compose-box label {
  display: block;
  font-size: 0.82rem;
  color: var(--gold-bright);
  margin-bottom: 6px;
}

.wish-templates-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0;
  margin-bottom: 8px;
}

.wish-chip {
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--text-muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
}

.community-wishes-section h3 {
  font-size: 0.95rem;
  color: var(--gold-bright);
  margin-bottom: 10px;
}

.wishes-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 210px;
  overflow-y: auto;
}

.wish-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 10px;
  padding: 9px 12px;
}

.wish-card-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--gold-bright);
  margin-bottom: 4px;
}

.wish-card-body {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.4;
}

/* BỘ ĐẾM FPS MÉP PHẢI (CHỈ HIỆN KHI MỞ VỚI ?fps) */
.fps-counter {
  position: fixed;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  z-index: 60;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.62);
  color: #7dff9a;
  font: 600 12px/1.45 ui-monospace, Consolas, monospace;
  white-space: pre;
  pointer-events: none;
}

.fps-counter.mid {
  color: #ffd966;
}

.fps-counter.low {
  color: #ff7b6b;
}

@media (max-width: 768px) {
  .btn-label {
    display: none;
  }
  /* Thanh trên cùng giữ 1 dòng để không đè lên bảng Cấp độ & nút Nghe niệm Phật */
  .top-hud {
    gap: 6px;
  }
  /* Logo 🪷 và nút 🧭 cùng mở menu Khu vực → màn hẹp chỉ giữ 🧭 */
  .hud-left {
    display: none;
  }
  .top-hud {
    justify-content: flex-end;
  }
  .hud-right {
    flex-wrap: nowrap;
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .hud-right::-webkit-scrollbar {
    display: none;
  }
  #hud-phap-danh {
    display: none;
  }
  .hud-btn, .hud-profile-btn {
    flex-shrink: 0;
    padding: 7px 10px;
  }
  .progression-card {
    width: 215px;
    padding: 9px 10px;
  }
  /* Thu gọn trên điện thoại: một dòng cao 44px (cấp, thanh điểm) để chừa cảnh; bấm mở ra mới thấy lịch âm + nhiệm vụ */
  .progression-card.collapsed {
    width: 178px;
    padding: 0;
    border-radius: 12px;
  }
  .progression-card.collapsed .prog-header {
    min-height: 44px;
    padding: 4px 9px;
    gap: 7px;
  }
  .progression-card.collapsed .prog-bead-icon {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
  }
  .progression-card.collapsed .prog-title-row {
    font-size: 0.74rem;
    margin-bottom: 3px;
  }
  .progression-card.collapsed .prog-exp-text {
    font-size: 0.64rem;
  }
  .progression-card.collapsed .ui1-calendar-entry {
    display: none;
  }
  .prog-info {
    min-width: 0;
  }
  #prog-level-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .robe-grid {
    grid-template-columns: 1fr;
  }
  .dock-item {
    min-width: 56px;
    padding: 5px 4px;
  }
  /* 5 nút dock vừa khít màn 375px, không phải cuộn ngang */
  .ritual-dock {
    gap: 2px;
    padding: 6px 8px;
  }
}

/* 6 nút dock (có Quét lá) vừa khít màn điện thoại, không cuộn ngang; vùng chạm vẫn ≥ 44px */
@media (max-width: 400px) {
  .dock-item {
    min-width: 48px;
    padding: 5px 2px;
  }
  .ritual-dock {
    gap: 1px;
    padding: 6px 6px;
  }
  .dock-label {
    font-size: 0.68rem;
  }
}

@media (max-width: 340px) {
  .dock-item {
    min-width: 44px;
    padding: 4px 1px;
  }
  .ritual-dock {
    gap: 0;
    padding: 5px 4px;
  }
  .dock-icon {
    font-size: 1.2rem;
  }
  .dock-label {
    font-size: 0.58rem;
    letter-spacing: -0.2px;
  }
}

/* =========================================================
   GIAO DIỆN ĐỢT 1 (UI1): LỊCH ÂM, TRÀNG HẠT, THIỀN, THỜI KHÓA, LỜI NGUYỆN RIÊNG
   Theo thiết kế trong thiet_ke_dot1_chatgpt.md (mục 6) — chỉ áp dụng cho class ui1-* và 5 modal liên quan
   ========================================================= */
.ui1-overlay {
  padding: 12px;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.ui1-card {
  padding: 18px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.ui1-card:focus { outline: none; }
.ui1-card [hidden] { display: none !important; }
.ui1-card .modal-top-bar { gap: 8px; margin-bottom: 12px; padding-bottom: 10px; }
.ui1-card .modal-top-bar > div { min-width: 0; }
.ui1-card .modal-top-bar h2 { font-size: 1.2rem; line-height: 1.35; }
.ui1-card .modal-subtitle { line-height: 1.4; }
.ui1-card .close-x { width: 44px; height: 44px; }
.ui1-card button,
.ui1-card select { min-height: 44px; }
.ui1-card select,
.ui1-card textarea { font-size: 16px; }
.ui1-card input[type="range"] { min-height: 44px; }
.ui1-card :is(button, select, textarea, input):focus-visible,
.ui1-calendar-entry:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}
.ui1-card :is(button, select):disabled { opacity: 0.6; cursor: default; }
.ui1-help { color: var(--text-muted); font-size: 0.82rem; line-height: 1.45; }
.ui1-status { padding: 10px 0; color: var(--text-muted); line-height: 1.45; }
.ui1-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  color: var(--text-main);
  line-height: 1.4;
}
.ui1-toggle input {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  accent-color: var(--gold-primary);
}
.ui1-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

/* A. Lịch âm */
.ui1-calendar-entry {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; width: 100%; min-height: 44px;
  padding: 7px 9px; margin-top: 7px;
  border: 1px solid var(--gold-soft); border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04); color: var(--text-main);
  text-align: left; font: inherit; font-size: 0.8rem; cursor: pointer;
}
#lunar-today-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui1-calendar-entry.is-special { border-color: var(--gold-primary); color: var(--gold-bright); }
.ui1-today { padding: 14px; border: 1px solid var(--gold-soft); border-radius: var(--radius-md); }
.ui1-calendar h3 { font-size: 1rem; margin-bottom: 8px; color: var(--gold-bright); }
.ui1-lunar-date { color: var(--gold-bright); font-weight: 700; line-height: 1.45; margin: 6px 0; }
.ui1-upcoming { margin-top: 18px; }
.ui1-cal-list { list-style: none; padding: 0; margin: 0 0 12px; }
.ui1-cal-event {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--gold-soft); align-items: center;
}
.ui1-cal-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 0.78rem; }
.ui1-cal-badge {
  padding: 3px 8px; border: 1px solid var(--gold-soft);
  border-radius: 999px; color: var(--text-muted);
}
.ui1-cal-event[data-kind="holiday"] .ui1-cal-badge { color: var(--gold-bright); border-color: var(--gold-primary); }
.ui1-cal-countdown { color: var(--text-muted); }
.ui1-cal-name { margin: 7px 0 3px; font-size: 0.95rem; line-height: 1.4; }
.ui1-cal-suggestion { margin-top: 4px; }

/* B. Tràng hạt */
#modal-beads .ui1-bead-body { display: grid; gap: 10px; }
#modal-beads .beads-Select-row { display: block; margin: 0; }
#modal-beads label[for] { display: block; margin-bottom: 4px; font-size: 0.85rem; }
#modal-beads .mala-interactive-area { width: 280px; height: 280px; margin: 0 auto; flex-shrink: 0; }
.ui1-bead-today { text-align: center; font-size: 0.88rem; color: var(--text-muted); line-height: 1.4; }
.ui1-bead-today strong { color: var(--text-main); font-variant-numeric: tabular-nums; }
.ui1-bead-preferences { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.ui1-bead-preferences > div { min-width: 0; }
.ui1-bead-preferences .sutra-select { width: 100%; }
#modal-beads .beads-action-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
#modal-beads .btn-large { padding: 10px 12px; font-size: 1rem; }

/* C. Thiền định */
#modal-meditate #meditate-duration-pills {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px; margin-bottom: 8px;
}
#modal-meditate .dur-pill { padding: 8px 4px; min-width: 0; }
#modal-meditate .dur-pill:disabled:not(.active) { opacity: 0.45; }
#modal-meditate .dur-pill.active:disabled { opacity: 1; }
#modal-meditate .ui1-interval-bell { margin-bottom: 8px; font-size: 0.9rem; }
.ui1-mode-note { text-align: center; color: var(--text-muted); font-size: 0.85rem; }
#modal-meditate .breathing-circle-wrap { height: 232px; margin: 0; align-items: center; }
#modal-meditate #breathing-circle { transform: scale(0.92); transition: none; box-shadow: none; }
#modal-meditate #breathing-circle.inhale { transform: scale(1.08); transition: transform 4s linear; }
#modal-meditate #breathing-circle.hold { transform: scale(1.08); transition: none; }
#modal-meditate #breathing-circle.exhale { transform: scale(0.92); transition: transform 6s linear; }
#modal-meditate .ui1-breath-guide { text-align: center; margin: 0 0 10px; }
#modal-meditate #meditate-free-note { text-align: center; margin-bottom: 10px; }
#modal-meditate .zen-quote-box { margin-bottom: 12px; padding: 10px; line-height: 1.4; }
#modal-meditate #meditate-session-status { text-align: center; margin-top: 8px; }

/* D. Thời khóa & bài tụng */
.ui1-sutra-progress {
  margin: 0 0 10px; padding: 9px 11px;
  border-left: 3px solid var(--gold-primary); border-radius: 8px;
  background: rgba(212, 175, 55, 0.1); color: var(--gold-bright);
  font-size: 0.88rem; line-height: 1.4;
}
#modal-sutra .sutra-heading {
  margin: 18px 0 10px; padding-top: 12px;
  border-top: 1px solid var(--gold-soft); font-size: 1rem;
  line-height: 1.45; color: var(--gold-bright); cursor: default;
}
#modal-sutra .sutra-heading:first-child { margin-top: 0; border-top: 0; padding-top: 0; }

/* E. Lời nguyện "Chỉ mình tôi" */
.ui1-wish-privacy {
  margin: 6px 0 12px; padding: 10px 12px;
  border: 1px solid var(--gold-soft); border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
}
.wish-compose-box .ui1-wish-privacy .ui1-toggle {
  display: flex; margin: 0; color: var(--text-main); font-size: 0.94rem;
}
.ui1-wish-privacy .ui1-help { margin-top: 2px; overflow-wrap: anywhere; }
.wish-private-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border: 1px solid var(--gold-soft); border-radius: 999px;
  color: var(--text-main); background: rgba(212, 175, 55, 0.08);
  font-size: 0.75rem; line-height: 1.4; white-space: nowrap;
}
#modal-wishes .wish-card-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#modal-wishes #btn-submit-wish { width: 100%; }
#modal-wishes #wish-submit-status:not([hidden]) { margin-bottom: 8px; }
#modal-wishes #wish-submit-status.is-error { color: #ffb4a8; }

@media (max-width: 768px) {
  .ui1-card { padding: 14px; }
  .ui1-card .modal-top-bar h2 { font-size: 1.12rem; }
  .ui1-cal-event { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .ui1-cal-event > button { justify-self: start; }
  #modal-beads .ui1-keyboard-hint { display: none; }
  #modal-beads .modal-top-bar { margin-bottom: 10px; padding-bottom: 8px; }
  #modal-meditate #meditate-duration-pills { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #modal-meditate .ui1-free-duration { grid-column: span 2; }
  #modal-wishes .wish-compose-box { padding: 12px; }
  #modal-wishes .wish-type-tabs { gap: 5px; }
  #modal-wishes .wish-tab { min-width: 0; min-height: 44px; padding: 8px 4px; }
  #modal-wishes #wish-textarea { min-height: 100px; line-height: 1.45; }
}
@media (max-width: 360px) {
  .ui1-overlay { padding-left: 0; padding-right: 0; }
  .ui1-card { padding-left: 10px; padding-right: 10px; scrollbar-gutter: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .ui1-card *, .ui1-card *::before, .ui1-card *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  #modal-meditate #breathing-circle,
  #modal-meditate #breathing-circle.inhale,
  #modal-meditate #breathing-circle.hold,
  #modal-meditate #breathing-circle.exhale { transform: none; }
}

/* Bảng chọn nhân vật trên điện thoại: gọn để gần vừa một màn — màu áo 2 cột (ẩn câu mô tả), chữ đầu bảng nhỏ lại */
@media (max-width: 480px) {
  .character-scroll { padding: 16px 16px 4px; }
  .character-modal .modal-actions { padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
  .character-modal .modal-lotus-header { font-size: 2rem; margin-bottom: 2px; }
  .character-modal h2 { font-size: 1.15rem; }
  .character-modal .modal-desc { font-size: 0.8rem; margin-bottom: 12px; }
  .character-modal .form-group { margin-bottom: 12px; }
  .character-modal .robe-grid { grid-template-columns: repeat(2, 1fr); gap: 7px; }
  .character-modal .robe-card { min-height: 48px; padding: 7px 9px; gap: 8px; }
  .character-modal .robe-swatch { width: 24px; height: 24px; }
  .character-modal .robe-meta small { display: none; }
}
@media (max-height: 640px) {
  .character-modal .modal-lotus-header { display: none; }
}
@media (max-width: 360px) {
  .character-modal .hair-option { font-size: 0.74rem; padding: 7px 4px; }
}

/* Góp ý / Báo lỗi */
.feedback-modal { max-width: 520px; }
/* Bảng xếp hạng: 3 tab kiểu nút gạt, hàng hạng (1–3 có huy hiệu), dòng của mình nổi bật, hạng của mình ở đáy */
.leaderboard-modal { max-width: 520px; }
.lb-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}
.lb-tab {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
.lb-tab.active {
  background: rgba(212, 175, 55, 0.2);
  color: var(--gold-bright);
  box-shadow: inset 0 0 0 1px var(--gold-primary);
}
.lb-tab:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.lb-note {
  margin: 10px 0 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}
.lb-status { margin: 14px 0; text-align: center; color: var(--text-muted); font-size: 0.9rem; }
.lb-status[hidden], .lb-retry[hidden] { display: none; }
.lb-retry { display: block; margin: 0 auto 10px; min-height: 44px; }
.lb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 50vh;
  max-height: 50dvh;
  overflow-y: auto;
}
.lb-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.lb-row.is-me {
  border-radius: 12px;
  background: rgba(212, 175, 55, 0.12);
}
.lb-rank {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  color: var(--text-muted);
}
.lb-rank.top1 { border: 1.5px solid #e7c55a; color: #f7d66a; background: rgba(231, 197, 90, 0.15); }
.lb-rank.top2 { border: 1.5px solid #b9bcc4; color: #e3e5ea; background: rgba(185, 188, 196, 0.12); }
.lb-rank.top3 { border: 1.5px solid #b87a4b; color: #e0a374; background: rgba(184, 122, 75, 0.14); }
.lb-who { display: flex; flex-direction: column; min-width: 0; }
.lb-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff3d6; }
.lb-who small { font-size: 0.76rem; color: var(--text-muted); }
.lb-value { font-weight: 700; color: #fff3d6; white-space: nowrap; font-size: 0.9rem; }
.lb-me {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--gold-soft);
  font-size: 0.85rem;
  color: var(--gold-bright);
  text-align: center;
}
.lb-me:empty { display: none; }
.prog-rank-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 6px;
  border: 1px solid var(--gold-soft);
  border-radius: 12px;
  background: rgba(212, 175, 55, 0.08);
  color: var(--gold-bright);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}
.feedback-kind {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.feedback-kind-btn {
  min-height: 44px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.feedback-kind-btn.active {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
}
.feedback-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold-bright);
  margin-bottom: 6px;
}
#feedback-text { resize: vertical; min-height: 110px; font-family: inherit; }
.feedback-shot { margin: 10px 0 4px; min-height: 44px; }
#feedback-status { margin: 6px 0; }
#feedback-status.is-error { color: #ffb4a8; }
#btn-submit-feedback { margin-top: 8px; }

/* Máy không mở được 3D: bảng hướng dẫn phủ toàn màn hình */
.no3d-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 30%, #2a1a10 0%, #0b0705 75%);
  color: var(--text-main);
}
.no3d-overlay[hidden] { display: none; }
.no3d-card {
  width: 100%;
  max-width: 460px;
  max-height: 90dvh;
  overflow-y: auto;
  background: linear-gradient(165deg, #281810 0%, #170e09 100%);
  border: 1.5px solid var(--gold-primary);
  border-radius: 22px;
  padding: 24px 22px;
  text-align: center;
}
.no3d-icon { font-size: 2.6rem; margin-bottom: 6px; }
.no3d-card h2 { color: var(--gold-bright); font-size: 1.25rem; margin-bottom: 10px; }
.no3d-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 8px; }
.no3d-card ul { text-align: left; margin: 0 0 16px 18px; color: var(--text-main); font-size: 0.88rem; line-height: 1.5; }
.no3d-card li { margin-bottom: 6px; }

/* Màn thấp (điện thoại Android ~700 px, 320×568): khung chữ và mõ nhỏ lại để mõ + nút tự động + nhịp vẫn trong màn */
@media (max-height: 760px) {
  .chant-reader { max-height: 26vh; max-height: 26dvh; padding: 10px 12px; }
  .chant-mo { width: 88px; height: 88px; padding: 10px; }
  .chant-note { display: none; }
  .chant-title { margin-bottom: 4px; font-size: 1rem; }
  .chant-instruments { margin: 4px 0; }
  .chant-bpm input { min-height: 24px; }
  #modal-sutra .modal-subtitle { display: none; }
  #modal-sutra .modal-top-bar { margin-bottom: 6px; padding-bottom: 6px; }
}

/* =========================================================
   CHAT ALL & THỈNH LỄ VẬT (NHANG ĐÈN, VÀNG MÃ, THỨC ĂN CÁ)
   ========================================================= */
.hud-offerings-counts {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff3d6;
  background: rgba(0, 0, 0, 0.28);
  padding: 2px 7px;
  border-radius: 999px;
}

@media (max-width: 768px) {
  .hud-offerings-counts {
    display: inline-block;
    font-size: 0.72rem;
    padding: 1px 6px;
  }
  #btn-hud-offerings .btn-label,
  #btn-hud-chat .btn-label {
    display: inline;
    font-size: 0.76rem;
  }
  .chat-all-panel {
    left: 10px;
    right: 10px;
    bottom: 138px;
    width: auto;
    max-height: 240px;
  }
  .chat-all-panel .chat-messages-list {
    min-height: 58px;
    max-height: 86px;
    padding: 6px 10px;
  }
  .chat-all-panel .chat-all-header {
    padding: 7px 12px;
  }
}

.chat-unread-badge {
  background: #d94330;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chat-unread-badge[hidden] {
  display: none;
}

.chat-all-panel {
  position: fixed;
  right: 16px;
  bottom: 92px;
  z-index: 32;
  width: min(360px, calc(100vw - 32px));
  max-height: min(430px, 62dvh);
  display: flex;
  flex-direction: column;
  background: rgba(24, 15, 10, 0.92);
  backdrop-filter: blur(12px);
  border: 1.5px solid var(--gold-primary);
  border-radius: 18px;
  box-shadow: var(--shadow-deep);
  overflow: hidden;
  color: var(--text-main);
}

.chat-all-panel.hidden {
  display: none;
}

.chat-all-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
  background: rgba(42, 25, 16, 0.85);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-collapse-btn {
  font-weight: 700;
}

.chat-all-panel.is-collapsed .chat-messages-list {
  display: none;
}

.chat-all-title span {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--gold-bright);
}

.chat-all-title small {
  display: block;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.chat-messages-list {
  flex: 1 1 auto;
  min-height: 140px;
  max-height: 230px;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-mute-banner {
  margin: 6px 10px 4px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(180, 38, 28, 0.28);
  border: 1px solid #ff7b6b;
  color: #ffd3cc;
  font-size: 0.79rem;
  line-height: 1.4;
}

.chat-mute-banner[hidden] {
  display: none;
}

.greet-chat-box {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.32);
}

.greet-chat-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 6px;
}

.greet-chat-form {
  padding: 0;
  border-top: none;
  background: transparent;
}

.greet-chat-hint {
  margin: 6px 0 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.greet-chat-hint.is-error {
  color: #ffb8ae;
}

.chat-msg-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.18);
  border-radius: 11px;
  padding: 7px 10px;
  font-size: 0.84rem;
  line-height: 1.38;
  word-break: break-word;
}

.chat-msg-item.is-mine {
  background: rgba(212, 175, 55, 0.14);
  border-color: rgba(212, 175, 55, 0.42);
}

.chat-msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
  font-size: 0.76rem;
}

.chat-msg-author {
  font-weight: 700;
  color: var(--gold-bright);
}

.chat-msg-user {
  color: var(--text-muted);
  font-weight: 400;
}

.chat-status {
  margin: 0 12px 6px;
  font-size: 0.78rem;
  color: #ffb8ae;
}

.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(212, 175, 55, 0.2);
  background: rgba(15, 9, 6, 0.9);
}

.chat-input-row[hidden] {
  display: none;
}

.chat-input-row input {
  min-height: 44px;
  font-size: 0.86rem;
  padding: 8px 11px;
}

.btn-send-chat {
  min-height: 44px;
  padding: 0 14px;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.chat-guest-lock {
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(212, 175, 55, 0.22);
  background: rgba(18, 11, 7, 0.95);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.79rem;
  color: var(--text-muted);
}

.chat-guest-lock[hidden] {
  display: none;
}

.btn-chat-login {
  min-height: 44px;
  width: 100%;
  font-size: 0.82rem;
}

/* Modal Mua Lễ Vật & QR Donate */
.offerings-modal {
  max-width: 620px;
}

.offerings-alert-banner {
  background: rgba(212, 175, 55, 0.16);
  border: 1px solid var(--gold-bright);
  color: #fff3d6;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  margin-bottom: 14px;
  line-height: 1.4;
}

.offerings-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.offering-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 175, 55, 0.28);
  border-radius: var(--radius-md);
  padding: 11px 13px;
}

.offering-item-icon {
  font-size: 1.9rem;
  flex-shrink: 0;
}

.offering-item-info {
  flex: 1;
  min-width: 0;
}

.offering-item-info strong {
  display: block;
  color: var(--gold-bright);
  font-size: 0.95rem;
}

.offering-item-info small {
  display: block;
  color: var(--text-muted);
  font-size: 0.77rem;
  margin: 2px 0 5px;
}

.offering-count-pill {
  display: inline-block;
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: #fff3d6;
  font-size: 0.78rem;
  padding: 2px 9px;
  border-radius: 999px;
  transition: transform 0.25s ease, background 0.25s ease;
}

@keyframes offeringCountBump {
  0% {
    transform: scale(1);
    background: rgba(68, 196, 108, 0.45);
    border-color: #7dff9a;
  }
  45% {
    transform: scale(1.16);
    background: rgba(68, 196, 108, 0.55);
    border-color: #7dff9a;
  }
  100% {
    transform: scale(1);
    background: rgba(212, 175, 55, 0.18);
    border-color: rgba(212, 175, 55, 0.4);
  }
}

.offering-count-pill.is-bumped {
  animation: offeringCountBump 0.65s ease;
}

.offering-count-pill.is-bumped::after {
  content: ' (+10)';
  color: #7dff9a;
  font-weight: 700;
}

.offering-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.offering-item-actions button {
  min-height: 44px;
  padding: 6px 11px;
  font-size: 0.8rem;
}

@media (max-width: 520px) {
  .offering-item-card {
    flex-wrap: wrap;
  }
  .offering-item-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .offering-item-actions button {
    flex: 1;
  }
}

.offerings-storage-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(180, 110, 30, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: 0.81rem;
  line-height: 1.4;
}

.offerings-storage-note.is-logged {
  background: rgba(45, 125, 70, 0.16);
  border-color: rgba(100, 200, 130, 0.4);
}

.offerings-storage-note button {
  min-height: 44px;
  padding: 6px 12px;
  font-size: 0.79rem;
  flex-shrink: 0;
}

.offerings-qr-section {
  background: rgba(12, 7, 4, 0.75);
  border: 1.5px solid var(--gold-primary);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
}

.offerings-qr-section h3 {
  color: var(--gold-bright);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.offerings-qr-desc {
  color: var(--text-muted);
  font-size: 0.83rem;
  line-height: 1.45;
  margin-bottom: 12px;
}

.offerings-qr-frame {
  display: inline-block;
  background: #fff;
  padding: 10px;
  border-radius: 14px;
  border: 3px solid var(--gold-bright);
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.offerings-qr-img {
  display: block;
  width: min(230px, 62vw);
  height: auto;
  border-radius: 6px;
}
