@import url('./vendor/fonts/fonts.css');

/* ===== Token: sơn mài nâu trầm + vàng kim, kính mờ ấm ===== */
:root {
  --bg-0: #0f0905;
  --bg-1: #1a120b;
  --bg-2: #2d2016;
  --surface: rgba(36, 25, 15, 0.7);
  --surface-sunk: rgba(12, 8, 4, 0.42);
  --line: rgba(224, 178, 92, 0.16);
  --line-strong: rgba(224, 178, 92, 0.42);
  --cream: #f5ead9;
  --milk: #b9a68e;
  --milk-2: #92806a;
  --gold: #e0b25c;
  --gold-hi: #f3c973;
  --gold-deep: #9c7535;
  --vermilion: #b8372d;
  --jade: #5fb59a;
  --lotus: #eba9bb;
  --glass-fill: linear-gradient(180deg, rgba(255, 240, 215, 0.075), rgba(255, 240, 215, 0.015) 60%),
    var(--surface);
  --sheet-fill: radial-gradient(ellipse 80% 30% at 50% 0%, rgba(243, 201, 115, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(47, 34, 22, 0.98), rgba(28, 19, 12, 0.98));
  --selected-fill: linear-gradient(180deg, #5d4425, #3a2816);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.42), 0 2px 8px rgba(0, 0, 0, 0.28);
  --glow: inset 0 0 0 1px rgba(243, 201, 115, 0.55), 0 0 18px rgba(243, 201, 115, 0.18);
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 0.22s;
  --blur: 14px;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--cream);
  font-synthesis: none;
  background: var(--bg-1);
  color-scheme: dark;
  -webkit-tap-highlight-color: transparent;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-1);
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 0;
  background: none;
  padding: 0;
  transition:
    transform 0.14s var(--ease),
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    opacity var(--dur) var(--ease);
}
button:active:not(:disabled) {
  transform: scale(0.94);
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
:focus-visible {
  outline: 2px solid var(--gold-hi);
  outline-offset: 3px;
}
a {
  color: inherit;
  text-decoration: none;
}
[hidden] {
  display: none !important;
}
.ico {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.glass {
  background: var(--glass-fill);
  border: 1px solid var(--line);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 236, 205, 0.07);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(1.15);
  backdrop-filter: blur(var(--blur)) saturate(1.15);
}
.round-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: var(--gold);
  border: 1px solid var(--line);
  background: rgba(255, 240, 215, 0.035);
  position: relative;
}
.round-button.glass {
  background: var(--glass-fill);
}
.round-button:hover {
  color: var(--gold-hi);
  border-color: var(--line-strong);
  background: rgba(224, 178, 92, 0.1);
}
.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--milk-2);
  flex: none;
}
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 12px auto;
}
.ornament i {
  width: 48px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(224, 178, 92, 0.7));
}
.ornament i:last-child {
  background: linear-gradient(90deg, rgba(224, 178, 92, 0.7), transparent);
}
.ornament b {
  width: 6px;
  height: 6px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 10px rgba(243, 201, 115, 0.6);
}
.count-badge {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gold-hi);
  background: rgba(224, 178, 92, 0.12);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: 3px 10px;
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--milk);
  background: rgba(255, 240, 215, 0.06);
  border: 1px solid var(--line);
}

/* ===== Cảnh và lớp phủ điện ảnh ===== */
#scene {
  position: fixed;
  inset: 0;
}
#scene canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.cinematic {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(15, 9, 5, 0.86), rgba(20, 13, 8, 0.45) 34%, transparent 58%),
    linear-gradient(0deg, rgba(15, 9, 5, 0.5), transparent 26%, transparent 76%, rgba(15, 9, 5, 0.55));
}
body.playing .cinematic {
  background: linear-gradient(
    0deg,
    rgba(15, 9, 5, 0.42),
    transparent 22%,
    transparent 80%,
    rgba(15, 9, 5, 0.42)
  );
}

/* ===== Màn tải ===== */
#loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: radial-gradient(ellipse 70% 55% at 50% 42%, rgba(90, 60, 30, 0.55), transparent 70%),
    radial-gradient(ellipse at 50% 100%, #24170d, var(--bg-0) 70%);
  transition:
    opacity 0.7s var(--ease),
    visibility 0s linear 0.7s;
}
#loading.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 420px;
}
.loading-lotus {
  width: 136px;
  height: auto;
  overflow: visible;
}
.loading-lotus .petals path {
  fill: url(#petal-fill);
  stroke: var(--gold);
  stroke-width: 1.3;
  stroke-linejoin: round;
}
.loading-lotus .petals {
  transform-origin: 60px 70px;
  animation: lotus-breathe 4.8s var(--ease) infinite;
}
.loading-lotus .p3 {
  opacity: 0.75;
}
.loading-lotus .halo {
  animation: halo 4.8s ease-in-out infinite;
}
.loading-lotus .water {
  fill: none;
  stroke: rgba(224, 178, 92, 0.45);
  stroke-width: 1.2;
  stroke-linecap: round;
}
.loading-lotus .w2 {
  opacity: 0.5;
}
#loading h2 {
  margin: 18px 0 6px;
  font: 500 38px/1.1 var(--serif);
  color: var(--gold-hi);
  letter-spacing: 0.02em;
  text-shadow: 0 0 28px rgba(243, 201, 115, 0.25);
}
.loading-greeting {
  margin: 0 0 26px;
  font-size: 14px;
  color: var(--milk);
}
.loading-bar {
  position: relative;
  width: 200px;
  height: 2px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(224, 178, 92, 0.16);
}
.loading-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--gold-hi), transparent);
  animation: indeterminate 1.7s var(--ease) infinite;
}
.loading-status {
  margin: 14px 0 0;
  min-height: 1.4em;
  font-size: 12px;
  color: var(--milk-2);
  font-variant-numeric: tabular-nums;
}
.fatal h2 {
  font: 500 28px var(--serif);
  color: var(--gold-hi);
}
.fatal p {
  color: var(--milk);
  line-height: 1.6;
}

/* ===== Thanh trên: viên thương hiệu + dải công cụ ===== */
.topbar {
  position: fixed;
  z-index: 12;
  top: calc(16px + var(--safe-t));
  left: calc(20px + var(--safe-l));
  right: calc(20px + var(--safe-r));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.topbar > * {
  pointer-events: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 50px;
  padding: 0 16px 0 6px;
  border-radius: var(--r-pill);
}
.brand-mark {
  width: 38px;
  height: 38px;
  padding: 8px;
  border-radius: 50%;
  color: var(--gold-hi);
  background: radial-gradient(circle at 50% 35%, rgba(243, 201, 115, 0.22), rgba(224, 178, 92, 0.06));
  border: 1px solid var(--line-strong);
  stroke-width: 1.5;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-text b {
  font: 500 19px var(--serif);
  color: var(--gold-hi);
  white-space: nowrap;
}
.brand-text small {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--milk-2);
  white-space: nowrap;
}
.brand-sep {
  width: 1px;
  height: 26px;
  background: var(--line-strong);
  opacity: 0.6;
}
.brand-status {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 7px;
  line-height: 1.25;
  white-space: nowrap;
}
.brand-status .live-dot {
  grid-row: span 2;
}
.brand:has(.connection.connected) .live-dot,
.lobby-note .live-dot {
  background: var(--jade);
  box-shadow: 0 0 0 3px rgba(95, 181, 154, 0.18);
  animation: live 2.6s ease-in-out infinite;
}
#time-label {
  font-size: 12.5px;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}
#time-label b {
  font-weight: 600;
}
#time-label span {
  color: var(--milk);
}
.connection {
  font-size: 11px;
  color: var(--milk-2);
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: var(--r-pill);
}
.tool {
  height: 42px;
  min-width: 42px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--cream);
}
.tool:hover {
  color: var(--gold-hi);
  background: rgba(224, 178, 92, 0.12);
}
.tool[aria-pressed='true'],
.tool[aria-expanded='true'] {
  color: var(--gold-hi);
  background: rgba(224, 178, 92, 0.14);
}
.tool-count {
  padding: 0 12px 0 10px;
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
body:not(.playing) #people-button {
  display: none;
}

/* ===== Sảnh / thẻ tạo nhân vật ===== */
.lobby {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  padding: calc(84px + var(--safe-t)) 24px calc(20px + var(--safe-b)) max(calc(24px + var(--safe-l)), 4vw);
  pointer-events: none;
}
.lobby-card {
  pointer-events: auto;
  width: min(436px, 100%);
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 28px 30px 24px;
  border-radius: 28px;
  background: radial-gradient(ellipse 80% 40% at 50% 0%, rgba(243, 201, 115, 0.09), transparent 70%),
    var(--glass-fill);
  scrollbar-width: thin;
  scrollbar-color: rgba(224, 178, 92, 0.3) transparent;
  animation: rise 0.6s var(--ease) both;
}
.eyebrow {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--milk);
}
.lobby h1 {
  margin: 12px 0 0;
  text-align: center;
  font: 500 36px/1.14 var(--serif);
  color: var(--gold-hi);
  text-shadow: 0 0 30px rgba(243, 201, 115, 0.2);
}
.lobby h1 em {
  font-weight: 400;
  color: var(--cream);
}
.lobby-lead {
  margin: 0 auto 6px;
  max-width: 34ch;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--milk);
}
.field-label {
  display: block;
  padding: 0;
  margin: 18px 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--milk);
  letter-spacing: 0.01em;
}
fieldset {
  border: 0;
  margin: 18px 0 0;
  padding: 0;
  min-width: 0;
}
fieldset > .field-label {
  margin-top: 0;
}
.swatch-name {
  font-weight: 400;
  color: var(--milk-2);
}
.swatch-name::before {
  content: '· ';
}
.name-row {
  display: flex;
  gap: 10px;
}
.name-row input,
dialog textarea,
dialog select {
  background-color: var(--surface-sunk);
  border: 1px solid var(--line);
  color: var(--cream);
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.name-row input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  font-size: 15px;
}
.name-row input:focus,
dialog textarea:focus,
dialog select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(224, 178, 92, 0.18);
}
::placeholder {
  color: var(--milk-2);
  opacity: 1;
}
.name-row .round-button {
  width: 48px;
  height: 48px;
  flex: none;
}
.name-row .round-button .ico {
  width: 22px;
  height: 22px;
}
#random-name.rolling .ico {
  animation: roll 0.5s var(--ease);
}
.seg-track {
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  gap: 2px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
}
.seg-track label {
  position: relative;
  display: block;
}
.seg-track input,
.swatch-row input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.seg-track span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  color: var(--milk);
  transition:
    background-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.seg-track label:hover span {
  color: var(--cream);
}
.seg-track input:checked + span {
  background: var(--selected-fill);
  color: var(--gold-hi);
  box-shadow:
    var(--glow),
    0 4px 12px rgba(0, 0, 0, 0.35);
}
.seg-track input:focus-visible + span,
.swatch-row input:focus-visible + span {
  outline: 2px solid var(--gold-hi);
  outline-offset: 2px;
}
.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.swatch-row label {
  position: relative;
  width: 32px;
  height: 32px;
}
.swatch-row span {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  font-size: 0;
  color: transparent;
  background: var(--swatch);
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, 0.28),
    inset 0 2px 3px rgba(255, 255, 255, 0.2),
    0 0 0 1px rgba(0, 0, 0, 0.4);
  transition:
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.swatch-row label:hover span {
  transform: scale(1.08);
}
.swatch-row input:checked + span {
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, 0.28),
    0 0 0 2px var(--bg-1),
    0 0 0 3.5px var(--gold-hi),
    0 0 14px rgba(243, 201, 115, 0.45);
}
.swatch-row span::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 46%;
  width: 7px;
  height: 12px;
  border: solid #fff8ea;
  border-width: 0 2.2px 2.2px 0;
  transform: translate(-50%, -50%) rotate(45deg) scale(0.4);
  opacity: 0;
  filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.9));
  transition:
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.swatch-row input:checked + span::after {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(45deg) scale(1);
}
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  margin-top: 24px;
  padding: 0 24px;
  border-radius: var(--r-pill);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--gold-hi);
  background: linear-gradient(180deg, #614626, #3b2917);
  border: 1px solid rgba(243, 201, 115, 0.6);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 230, 180, 0.2),
    0 0 26px rgba(224, 178, 92, 0.14);
}
.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #6d5030, #44301b);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 230, 180, 0.24),
    0 0 32px rgba(243, 201, 115, 0.26);
}
.primary .ico {
  transition: transform var(--dur) var(--ease);
}
.primary:hover .ico {
  transform: translateX(3px);
}
.lobby-note {
  display: flex;
  gap: 9px;
  align-items: baseline;
  margin: 16px 2px 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--milk-2);
}

/* Dấu người làm: triện son nhỏ "hientn" (cùng kiểu với trang giới thiệu, ảnh chụp và bia đá). */
.maker-mark {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin: 26px 0 0;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: var(--milk-2);
}
.lobby-sign {
  justify-content: flex-start;
  margin: 12px 2px 0;
}
.seal-mini {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 5px;
  background: #b3261e;
  color: #fbe9d6;
  font: 500 9.5px/1 var(--serif);
  text-align: center;
  box-shadow: inset 0 0 0 1.5px rgba(251, 233, 214, 0.85);
  transform: rotate(-4deg);
}

.lobby-note a,
dialog .small a {
  color: var(--gold-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ===== HUD trong game (desktop) ===== */
.hud-left {
  position: fixed;
  z-index: 10;
  left: calc(20px + var(--safe-l));
  top: calc(78px + var(--safe-t));
  width: 284px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile {
  position: relative;
  display: block;
  width: 100%;
  padding: 11px 16px 13px;
  border-radius: var(--r-md);
  text-align: left;
}
.profile:hover {
  border-color: var(--line-strong);
}
.profile-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
#level-label {
  font: 500 16px var(--serif);
  color: var(--gold-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#xp-caption {
  font-size: 11.5px;
  color: var(--milk);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.xp-track,
.quest-track,
.activity-track {
  display: block;
  height: 4px;
  margin-top: 9px;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 240, 215, 0.08);
}
#xp-progress,
#quest-total,
#activity-progress {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-hi));
  box-shadow: 0 0 10px rgba(243, 201, 115, 0.5);
}
#xp-progress,
#quest-total {
  transition: width 0.8s var(--ease);
}
#activity-progress {
  transition: width 0.25s linear;
}
.profile.gain {
  animation: xp-glow 1.4s var(--ease);
}
.profile.gain::after {
  content: attr(data-gain);
  position: absolute;
  right: 14px;
  top: -8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-hi);
  text-shadow: 0 0 12px rgba(243, 201, 115, 0.6);
  animation: float-up 1.4s var(--ease) forwards;
  pointer-events: none;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px 0 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--cream);
}
.chip .ico {
  color: var(--gold);
}
.chip b {
  color: var(--gold-hi);
  font-variant-numeric: tabular-nums;
}
#quest-button,
.hud-right-tools {
  display: none;
}
.unread {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--lotus);
  box-shadow: 0 0 0 2px var(--bg-1);
}
.panel {
  border-radius: var(--r-lg);
}
.sheet-grip,
.sheet-close,
.panel-head.map-head {
  display: none;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.panel-head h2 {
  margin: 2px 0 0;
  font: 500 21px/1.15 var(--serif);
  color: var(--gold-hi);
}
.panel-caption {
  font-size: 10px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  text-transform: uppercase;
  color: var(--milk-2);
}
.panel-head .count-badge {
  margin-top: 4px;
}
.panel-head .sheet-close {
  width: 36px;
  height: 36px;
  flex: none;
}

/* Thời khóa */
.quest-panel {
  position: fixed;
  z-index: 10;
  left: calc(20px + var(--safe-l));
  top: calc(146px + var(--safe-t));
  width: 284px;
  max-height: calc(100dvh - 146px - 262px - var(--safe-t) - var(--safe-b));
  min-height: 160px;
  display: flex;
  flex-direction: column;
  padding: 16px 14px 10px 18px;
}
.quest-track {
  flex: none;
  margin: 12px 4px 6px 0;
}
#quest-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-right: -8px;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(224, 178, 92, 0.3) transparent;
}
.quest-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 7px 8px 7px 4px;
  border-radius: 12px;
  text-align: left;
}
.quest-item:hover {
  background: rgba(224, 178, 92, 0.08);
}
.quest-item:active:not(:disabled) {
  transform: scale(0.98);
}
.quest-symbol {
  width: 34px;
  height: 34px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--gold);
  border: 1px solid var(--line);
  background: rgba(255, 240, 215, 0.03);
  transition:
    background-color 0.4s var(--ease),
    color 0.4s var(--ease);
}
.quest-symbol .ico {
  width: 18px;
  height: 18px;
}
.quest-item > span:nth-child(2) {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.quest-item strong {
  font-size: 13px;
  font-weight: 500;
  color: var(--cream);
}
.quest-item small {
  font-size: 11px;
  color: var(--milk-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.quest-item > b {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--milk);
  font-variant-numeric: tabular-nums;
}
.quest-item.done .quest-symbol {
  color: #1b130b;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  border-color: transparent;
  box-shadow: 0 0 12px rgba(243, 201, 115, 0.35);
}
.quest-item.done strong {
  color: var(--milk);
}
.quest-item.done > b {
  color: var(--gold-hi);
}
.quest-foot {
  flex: none;
  margin: 8px 0 2px;
  font: italic 13px var(--serif);
  color: var(--milk-2);
  text-align: center;
}

/* Hiện diện: bảng nổi dưới dải công cụ */
.presence {
  position: fixed;
  z-index: 20;
  right: calc(20px + var(--safe-r));
  top: calc(78px + var(--safe-t));
  width: 290px;
  max-height: min(420px, calc(100dvh - 120px));
  display: flex;
  flex-direction: column;
  padding: 14px 14px 10px 16px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition:
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    visibility 0s linear var(--dur);
}
body[data-sheet='people'] .presence {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}
.presence .sheet-close {
  display: inline-grid;
}
.presence-title {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-top: 6px;
}
.presence-title .live-dot {
  background: var(--jade);
}
.presence-title strong {
  font: 500 18px var(--serif);
  color: var(--gold-hi);
}
#player-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 10px 0 6px;
}
.player-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  column-gap: 10px;
  align-items: center;
  padding: 6px 0;
}
.player-row i {
  grid-row: span 2;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-style: normal;
  font-weight: 600;
  font-size: 13px;
  color: #fff8ea;
  background: var(--robe);
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.3),
    0 0 0 1px var(--line-strong);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.player-row span {
  font-size: 13px;
  color: var(--cream);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-row small {
  font-size: 11px;
  color: var(--milk-2);
}
.text-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 4px;
  font-size: 12.5px;
  color: var(--gold);
  border-top: 1px solid var(--line);
}
.text-button .ico {
  width: 16px;
  height: 16px;
}
.text-button:hover {
  color: var(--gold-hi);
}

/* Vị trí hiện tại */
.location-badge {
  position: fixed;
  z-index: 9;
  top: calc(22px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px 0 12px;
  border-radius: var(--r-pill);
  background: rgba(26, 18, 11, 0.55);
  border: 1px solid var(--line);
  pointer-events: none;
  white-space: nowrap;
}
.location-badge .ico {
  width: 16px;
  height: 16px;
  color: var(--gold);
}
.location-badge small {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--milk-2);
}
.location-badge strong {
  font: 500 16px var(--serif);
  color: var(--cream);
}

/* Hoạt động đang làm + nút tương tác */
.activity {
  position: fixed;
  z-index: 11;
  left: 50%;
  bottom: calc(126px + var(--safe-b));
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 24px));
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px 12px 12px;
  border-radius: 22px;
  border-color: var(--line-strong);
  animation: pop-in 0.32s var(--ease) both;
}
.activity-symbol {
  width: 50px;
  height: 50px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--gold-hi);
  background: radial-gradient(circle, rgba(243, 201, 115, 0.2), rgba(224, 178, 92, 0.04) 70%);
  border: 1px solid var(--line-strong);
  animation: breathe 4s ease-in-out infinite;
}
.activity-symbol .ico {
  width: 26px;
  height: 26px;
}
.activity-body {
  flex: 1;
  min-width: 0;
}
#activity-name {
  font: 500 17px var(--serif);
  color: var(--gold-hi);
}
#activity-hint {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--milk);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#cancel-action {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--cream);
}
#cancel-action:hover {
  border-color: var(--line-strong);
  color: var(--gold-hi);
}
.interaction {
  position: fixed;
  z-index: 11;
  left: 50%;
  bottom: calc(130px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  max-width: calc(100vw - 24px);
  padding: 0 20px 0 8px;
  border-radius: var(--r-pill);
  font-size: 15px;
  font-weight: 500;
  color: var(--cream);
  background: linear-gradient(180deg, rgba(97, 70, 38, 0.94), rgba(52, 36, 21, 0.94));
  border: 1px solid rgba(243, 201, 115, 0.6);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(243, 201, 115, 0.2);
  animation:
    pop-in 0.3s var(--ease) both,
    halo-ring 2.6s ease-in-out 0.3s infinite;
}
.interaction:active:not(:disabled) {
  transform: translateX(-50%) scale(0.95);
}
.interaction kbd {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 13px;
  color: #1b130b;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  border: 0;
}
#interaction-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Trò chuyện */
.feed {
  position: fixed;
  z-index: 10;
  left: calc(20px + var(--safe-l));
  bottom: calc(20px + var(--safe-b));
  width: 300px;
  display: flex;
  flex-direction: column;
  padding: 10px 10px 10px 14px;
}
.feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.feed-header > span {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--milk);
}
.feed-header > span .ico {
  width: 16px;
  height: 16px;
  color: var(--gold);
}
#toggle-feed {
  width: 32px;
  height: 32px;
}
#toggle-feed .ico {
  width: 16px;
  height: 16px;
}
#feed-messages {
  height: 116px;
  overflow: auto;
  margin: 6px -4px 8px 0;
  padding-right: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
  scrollbar-color: rgba(224, 178, 92, 0.3) transparent;
}
#feed-messages > div {
  padding: 2px 0;
  animation: fade-in 0.3s var(--ease);
}
#feed-messages b {
  font-weight: 600;
  color: var(--gold-hi);
}
#feed-messages .system {
  color: var(--milk-2);
  font-style: italic;
}
.feed.collapsed #feed-messages {
  display: none;
}
.feed.collapsed .feed-header {
  margin-bottom: 8px;
}

/* Thanh hành động */
.actionbar {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(44px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  padding: 5px;
  border-radius: 34px;
}
#task-buttons {
  display: flex;
}
.actionbar button {
  position: relative;
  width: 70px;
  height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 26px;
  color: var(--cream);
}
.actionbar button .ico {
  width: 22px;
  height: 22px;
  color: var(--gold);
  transition: color var(--dur) var(--ease);
}
.actionbar small {
  max-width: 100%;
  padding: 0 2px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.actionbar kbd {
  position: absolute;
  top: 4px;
  right: 7px;
  min-width: 0;
  height: auto;
  padding: 0;
  font-size: 9.5px;
  font-weight: 500;
  border: 0;
  background: none;
  color: var(--milk-2);
}
.actionbar button:hover {
  background: rgba(224, 178, 92, 0.1);
}
.actionbar button:hover .ico,
.actionbar button.active .ico {
  color: var(--gold-hi);
}
.actionbar button.active {
  background: var(--selected-fill);
  box-shadow: var(--glow);
  color: var(--gold-hi);
}
.actionbar-sep {
  width: 1px;
  height: 34px;
  margin: 0 6px;
  background: var(--line-strong);
  opacity: 0.6;
}
#more-actions,
.more-sheet {
  display: none;
}

/* Bản đồ nhỏ */
.right-bottom {
  position: fixed;
  z-index: 10;
  right: calc(20px + var(--safe-r));
  bottom: calc(20px + var(--safe-b));
  width: 210px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.minimap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}
#map {
  display: block;
  width: 100%;
  height: 100%;
}
.north {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font: 600 10px var(--sans);
  color: #1b130b;
  background: var(--gold);
}
/* Bộ chọn góc nhìn: desktop nằm trên bản đồ nhỏ */
.view-mode {
  position: fixed;
  z-index: 10;
  right: calc(20px + var(--safe-r));
  bottom: calc(240px + var(--safe-b));
  width: 210px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 4px;
  border-radius: var(--r-pill);
}
.view-mode button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 46px;
  border-radius: 22px;
  color: var(--milk);
}
.view-mode .ico {
  width: 18px;
  height: 18px;
  color: var(--gold);
}
.view-mode small {
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}
.view-mode button:hover {
  color: var(--cream);
  background: rgba(224, 178, 92, 0.1);
}
.view-mode button[aria-pressed='true'] {
  color: var(--gold-hi);
  background: var(--selected-fill);
  box-shadow: var(--glow);
}
.view-mode button[aria-pressed='true'] .ico {
  color: var(--gold-hi);
}
.view-mode button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* Góc nhìn thứ nhất: tâm ngắm chấm vàng mảnh, ẩn bảng tên của chính mình */
#crosshair {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 1px solid rgba(243, 201, 115, 0.35);
  pointer-events: none;
  display: none;
}
#crosshair::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgba(243, 201, 115, 0.75);
  box-shadow: 0 0 6px rgba(243, 201, 115, 0.6);
}
body.playing[data-view='first'] #crosshair {
  display: block;
}
body[data-view='first'] .nameplate.self {
  visibility: hidden;
}
.movement-hint {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--milk);
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}
.movement-hint span {
  margin: 0 5px 0 2px;
}
.hint-sep {
  color: var(--milk-2);
}
#touch-controls {
  display: none;
}
#sheet-dismiss {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: block;
  background: transparent;
  cursor: default;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s var(--ease),
    visibility 0s linear 0.3s;
}
body[data-sheet='people'] #sheet-dismiss {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}
#sheet-dismiss:active {
  transform: none;
}

/* ===== Bảng tên, bong bóng, mốc hoạt động trên cảnh ===== */
.nameplate {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.nameplate > span {
  padding: 3px 11px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--cream);
  background: rgba(26, 18, 11, 0.78);
  border: 1px solid rgba(224, 178, 92, 0.28);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
.nameplate.self > span {
  color: var(--gold-hi);
  border-color: rgba(243, 201, 115, 0.6);
}
.world-marker {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.94;
}
.world-marker:active:not(:disabled) {
  transform: none;
}
.world-marker span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font: 16px var(--serif);
  color: var(--gold-hi);
  background: rgba(30, 21, 13, 0.82);
  border: 1px solid rgba(224, 178, 92, 0.5);
  box-shadow:
    0 0 0 5px rgba(243, 201, 115, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.35);
  transition:
    scale var(--dur) var(--ease),
    background-color var(--dur) var(--ease);
}
.world-marker span .ico {
  width: 18px;
  height: 18px;
}
.world-marker:hover span {
  scale: 1.12;
  background: rgba(70, 50, 28, 0.92);
}
.world-marker small {
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--cream);
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.9),
    0 0 8px rgba(0, 0, 0, 0.6);
}
/* Toàn cảnh: các mốc nằm sát nhau trên màn hình nên chỉ giữ icon, tên hiện khi rê chuột/focus. */
body[data-view='overview'] .world-marker small {
  display: none;
}
body[data-view='overview'] .world-marker:is(:hover, :focus-visible) small {
  display: block;
}

/* ===== Toast + hộp thoại ===== */
#toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  top: calc(76px + var(--safe-t));
  width: max-content;
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 20px;
  border-radius: 22px;
  font-size: 13.5px;
  line-height: 1.45;
  text-align: center;
  color: var(--cream);
  background: linear-gradient(180deg, rgba(64, 46, 26, 0.97), rgba(36, 25, 15, 0.97));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition:
    opacity 0.28s var(--ease),
    transform 0.34s var(--ease);
}
#toast:empty {
  display: none;
}
#toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
dialog {
  border: 1px solid var(--line-strong);
  border-radius: 26px;
  color: var(--cream);
  padding: 30px 30px 26px;
  background: radial-gradient(ellipse 80% 35% at 50% 0%, rgba(243, 201, 115, 0.1), transparent 70%),
    linear-gradient(180deg, #2f2216, #1c140c);
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 236, 205, 0.08);
  max-height: 86dvh;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(224, 178, 92, 0.3) transparent;
}
dialog[open] {
  position: fixed;
  inset: 50dvh auto auto 50vw;
  transform: translate(-50%, -50%);
  margin: 0;
  width: min(480px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  animation: dialog-in 0.3s var(--ease);
}
dialog::backdrop {
  background: rgba(10, 6, 3, 0.62);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
dialog h2 {
  margin: 0 44px 14px 0;
  font: 500 27px/1.2 var(--serif);
  color: var(--gold-hi);
}
dialog p,
dialog li {
  font-size: 14px;
  line-height: 1.7;
  color: #e3d5c0;
}
dialog ul {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}
dialog li {
  position: relative;
  padding: 3px 0 3px 20px;
}
dialog li::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 0.95em;
  width: 5px;
  height: 5px;
  background: var(--gold);
  transform: rotate(45deg);
}
dialog .small {
  display: block;
  font-size: 12px;
  line-height: 1.6;
  color: var(--milk);
}
dialog .setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 6px 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
dialog .setting-row label {
  font-weight: 500;
}
dialog select {
  min-height: 44px;
  max-width: 64%;
  padding: 0 36px 0 14px;
  border-radius: var(--r-pill);
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--gold) 50%),
    linear-gradient(135deg, var(--gold) 50%, transparent 50%);
  background-position:
    calc(100% - 19px) 50%,
    calc(100% - 14px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
dialog select option {
  background: var(--bg-2);
  color: var(--cream);
}
dialog textarea {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}
dialog .primary {
  margin-top: 16px;
}
dialog .close {
  position: absolute;
  right: 16px;
  top: 16px;
}
dialog .ornament {
  justify-content: flex-start;
  margin: -4px 0 6px;
}
dialog .teaching {
  margin: 6px 0;
  font: 500 22px/1.35 var(--serif);
  color: var(--gold-hi);
}
dialog .teaching-body {
  font: italic 16px/1.6 var(--serif);
}
dialog .level-summary {
  font: 500 18px/1.5 var(--serif);
  color: var(--gold-hi);
}
.rewards {
  margin: 14px 0;
  padding: 6px 16px;
  border-radius: var(--r-md);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
}
dialog .reward {
  position: relative;
  margin: 6px 0;
  padding-left: 28px;
}
.reward::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--milk-2);
  transform: translateY(-50%);
}
.reward.done::before {
  border-color: var(--gold-hi);
  background: var(--gold-hi);
}
.reward.done::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 50%;
  width: 4px;
  height: 8px;
  border: solid #1b130b;
  border-width: 0 1.8px 1.8px 0;
  transform: translateY(-62%) rotate(45deg);
}

/* ===== Khung hình ===== */
@keyframes lotus-breathe {
  50% {
    transform: scale(1.045);
  }
}
@keyframes halo {
  50% {
    opacity: 0.55;
  }
}
@keyframes indeterminate {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(260%);
  }
}
@keyframes live {
  50% {
    box-shadow: 0 0 0 5px rgba(95, 181, 154, 0.06);
  }
}
@keyframes rise {
  from {
    opacity: 0;
    translate: 0 14px;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    translate: 0 8px;
  }
}
@keyframes breathe {
  50% {
    box-shadow: 0 0 0 7px rgba(243, 201, 115, 0.07);
  }
}
@keyframes halo-ring {
  50% {
    box-shadow:
      0 12px 30px rgba(0, 0, 0, 0.45),
      0 0 34px rgba(243, 201, 115, 0.36);
  }
}
@keyframes xp-glow {
  30% {
    border-color: rgba(243, 201, 115, 0.7);
    box-shadow:
      var(--shadow),
      0 0 26px rgba(243, 201, 115, 0.35);
  }
}
@keyframes float-up {
  from {
    opacity: 0;
    translate: 0 10px;
  }
  25% {
    opacity: 1;
    translate: 0 0;
  }
  to {
    opacity: 0;
    translate: 0 -16px;
  }
}
@keyframes roll {
  50% {
    transform: rotate(180deg) scale(0.85);
  }
  to {
    transform: rotate(360deg);
  }
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translate(-50%, -46%) scale(0.97);
  }
}

/* ===== Desktop vừa: thanh hành động chỉ icon + số phím ===== */
@media (max-width: 1599px) {
  .actionbar button {
    width: 46px;
    height: 50px;
  }
  .actionbar small {
    display: none;
  }
  .actionbar kbd {
    top: 3px;
    right: 5px;
  }
  .feed {
    width: 232px;
  }
  .hud-left,
  .quest-panel {
    width: 252px;
  }
}
@media (max-height: 760px) and (min-width: 1024px) {
  .movement-hint {
    display: none;
  }
  .actionbar {
    bottom: calc(20px + var(--safe-b));
  }
  .activity {
    bottom: calc(100px + var(--safe-b));
  }
  .interaction {
    bottom: calc(104px + var(--safe-b));
  }
  #feed-messages {
    height: 84px;
  }
  .quest-panel {
    max-height: calc(100dvh - 146px - 230px - var(--safe-t) - var(--safe-b));
  }
}

/* ===== Bố cục gọn: điện thoại, máy tính bảng, cửa sổ hẹp, điện thoại ngang ===== */
@media (max-width: 1023px), (max-height: 560px) {
  :root {
    --surface: rgba(30, 21, 13, 0.88);
  }
  /* Bỏ blur nền trên màn gọn để khung 3D không giật */
  .glass {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .topbar {
    top: calc(10px + var(--safe-t));
    left: calc(12px + var(--safe-l));
    right: calc(12px + var(--safe-r));
    gap: 8px;
  }
  .brand {
    height: 46px;
    padding-right: 14px;
    gap: 8px;
  }
  .brand-mark {
    width: 34px;
    height: 34px;
    padding: 7px;
  }
  .brand-text small,
  .connection,
  .location-badge,
  .movement-hint {
    display: none;
  }
  .toolbar {
    padding: 3px;
  }
  .tool {
    height: 40px;
    min-width: 40px;
  }
  .tool-count {
    padding: 0 10px 0 8px;
  }
  /* Hàng thứ hai: cấp độ + thời khóa bên trái, trò chuyện + bản đồ bên phải */
  .hud-left {
    top: calc(64px + var(--safe-t));
    left: calc(12px + var(--safe-l));
    width: auto;
    flex-direction: row;
    gap: 8px;
  }
  .profile {
    width: 158px;
    height: 44px;
    padding: 6px 14px 0;
    border-radius: var(--r-pill);
  }
  #level-label {
    font-size: 14px;
  }
  #xp-caption {
    font-size: 10.5px;
  }
  .xp-track {
    margin-top: 5px;
    height: 3px;
  }
  #quest-button {
    display: inline-flex;
    height: 44px;
  }
  .hud-right-tools {
    position: fixed;
    z-index: 10;
    top: calc(64px + var(--safe-t));
    right: calc(12px + var(--safe-r));
    display: flex;
    gap: 8px;
  }
  .hud-right-tools .round-button {
    width: 44px;
    height: 44px;
  }
  /* Thanh hành động: 4 việc + Thêm */
  .actionbar {
    left: calc(12px + var(--safe-l));
    right: calc(12px + var(--safe-r));
    bottom: calc(10px + var(--safe-b));
    transform: none;
    max-width: 460px;
    margin: 0 auto;
    padding: 4px;
    border-radius: 30px;
  }
  #task-buttons {
    display: contents;
  }
  #task-buttons > :nth-child(n + 5),
  .actionbar #greet,
  .actionbar-sep {
    display: none;
  }
  .actionbar button,
  #more-actions {
    display: flex;
    flex: 1;
    min-width: 0;
    width: auto;
    height: 56px;
  }
  .actionbar small {
    display: block;
  }
  .actionbar kbd {
    display: none;
  }
  .actionbar #more-actions[aria-expanded='true'] {
    background: var(--selected-fill);
    box-shadow: var(--glow);
  }
  .activity,
  .interaction {
    bottom: calc(80px + var(--safe-b));
  }
  #activity-hint {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
  }
  /* Bộ chọn góc nhìn: viên dọc bên phải, trên nút Đi nhanh, không đụng cần điều khiển bên trái */
  .view-mode {
    right: calc(12px + var(--safe-r));
    bottom: calc(184px + var(--safe-b));
    width: auto;
    grid-template-columns: none;
    grid-auto-rows: 44px;
    padding: 3px;
    border-radius: 26px;
  }
  .view-mode button {
    width: 44px;
    min-height: 44px;
  }
  .view-mode small {
    display: none;
  }
  .view-mode .ico {
    width: 20px;
    height: 20px;
  }
  body[data-sheet]:not([data-sheet='']) .view-mode {
    visibility: hidden;
  }
  /* Bảng dạng sheet trượt từ dưới lên */
  .quest-panel,
  .presence,
  .feed,
  .right-bottom,
  .more-sheet {
    position: fixed;
    z-index: 20;
    left: calc(8px + var(--safe-l));
    right: calc(8px + var(--safe-r));
    top: auto;
    bottom: calc(8px + var(--safe-b));
    width: auto;
    max-width: 560px;
    min-height: 0;
    max-height: min(74dvh, 600px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 8px 16px 14px;
    border-radius: 26px;
    background: var(--sheet-fill);
    border-color: var(--line-strong);
    opacity: 0;
    visibility: hidden;
    transform: translateY(calc(100% + 24px));
    transition:
      transform 0.34s var(--ease),
      opacity 0.24s var(--ease),
      visibility 0s linear 0.34s;
  }
  body[data-sheet='quests'] .quest-panel,
  body[data-sheet='people'] .presence,
  body[data-sheet='feed'] .feed,
  body[data-sheet='map'] .right-bottom,
  body[data-sheet='more'] .more-sheet {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }
  .sheet-grip {
    display: block;
    flex: none;
    width: 40px;
    height: 4px;
    margin: 0 auto 10px;
    border-radius: 4px;
    background: rgba(224, 178, 92, 0.35);
  }
  .sheet-close {
    display: inline-grid;
  }
  .panel-head.map-head {
    display: flex;
  }
  .panel-head {
    flex: none;
    align-items: center;
    padding: 2px 0 6px;
  }
  .panel-head .sheet-close {
    width: 44px;
    height: 44px;
  }
  .quest-panel .panel-head .count-badge {
    margin: 0 0 0 auto;
  }
  .quest-item {
    padding: 9px 8px 9px 4px;
  }
  .feed {
    min-height: min(52dvh, 420px);
  }
  .feed.collapsed #feed-messages,
  #feed-messages {
    display: block;
    flex: 1;
    height: auto;
    min-height: 100px;
  }
  .feed-header {
    margin-bottom: 4px;
  }
  #toggle-feed {
    width: 44px;
    height: 44px;
  }
  .right-bottom {
    gap: 12px;
    align-items: center;
  }
  .map-head {
    width: 100%;
    align-items: center;
    justify-content: space-between;
  }
  .minimap {
    width: min(300px, 72vw, 44dvh);
  }
  .more-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    overflow: auto;
    padding: 4px 0 2px;
  }
  .more-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 88px;
    padding: 10px 6px;
    border-radius: 18px;
    text-align: center;
    background: rgba(255, 240, 215, 0.035);
    border: 1px solid var(--line);
  }
  .more-tile .ico {
    width: 26px;
    height: 26px;
    color: var(--gold);
  }
  .more-tile strong {
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.2;
  }
  .more-tile small {
    font-size: 11px;
    color: var(--milk-2);
  }
  .more-tile:hover,
  .more-tile.active {
    background: var(--selected-fill);
    box-shadow: var(--glow);
  }
  .greet-tile {
    border-color: rgba(235, 169, 187, 0.35);
  }
  .greet-tile .ico {
    color: var(--lotus);
  }
  #sheet-dismiss {
    background: rgba(10, 6, 3, 0.45);
  }
  body[data-sheet]:not([data-sheet='']) #sheet-dismiss {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
  }
  body[data-sheet]:not([data-sheet='']) #touch-controls,
  body[data-sheet]:not([data-sheet='']) .interaction,
  body[data-sheet]:not([data-sheet='']) .activity {
    visibility: hidden;
  }
  #toast {
    top: calc(118px + var(--safe-t));
  }
  dialog {
    padding: 24px 20px 20px;
  }
  dialog[open] {
    width: min(480px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }
  dialog h2 {
    font-size: 24px;
  }
  dialog .close {
    right: 12px;
    top: 12px;
    width: 44px;
    height: 44px;
  }
}
/* Màn gọn rộng hơn (sheet nổi nhưng còn chỗ): bảng hiện diện vẫn là sheet */
@media (min-width: 641px) and (max-width: 1023px) and (min-height: 561px) {
  .quest-panel,
  .presence,
  .feed,
  .right-bottom,
  .more-sheet {
    max-width: 480px;
  }
}

/* Cần điều khiển cảm ứng (chỉ khi không có chuột hoặc màn rất hẹp) */
@media (max-width: 1023px) and (hover: none), (max-height: 560px) and (hover: none), (max-width: 760px) {
  #touch-controls {
    display: block;
  }
  #joystick {
    position: fixed;
    z-index: 9;
    left: calc(18px + var(--safe-l));
    bottom: calc(92px + var(--safe-b));
    width: 112px;
    height: 112px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    touch-action: none;
    background: radial-gradient(circle, rgba(36, 25, 15, 0.3), rgba(36, 25, 15, 0.62));
    border: 1px solid var(--line-strong);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
  }
  #joystick-thumb {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 35%, rgba(243, 201, 115, 0.6), rgba(156, 117, 53, 0.6));
    border: 1px solid rgba(243, 201, 115, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
  }
  #joystick small {
    position: absolute;
    bottom: -19px;
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--milk);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    white-space: nowrap;
  }
  #run-toggle {
    position: fixed;
    z-index: 9;
    right: calc(18px + var(--safe-r));
    bottom: calc(104px + var(--safe-b));
    width: 64px;
    height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--cream);
    border-color: var(--line-strong);
  }
  #run-toggle .ico {
    color: var(--gold);
    transform: rotate(-90deg);
  }
  #run-toggle small {
    font-size: 10px;
  }
  #run-toggle[aria-pressed='true'] {
    background: var(--selected-fill);
    box-shadow: var(--glow);
    color: var(--gold-hi);
  }
  #activity:not([hidden]) ~ #touch-controls {
    visibility: hidden;
  }
  .interaction {
    bottom: calc(222px + var(--safe-b));
  }
}

/* Màn hẹp dọc: thương hiệu xếp hai dòng (tên + giờ) */
@media (max-width: 480px) {
  .brand {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-rows: auto auto;
    align-content: center;
    column-gap: 8px;
    row-gap: 1px;
  }
  .brand-mark {
    grid-row: span 2;
  }
  .brand-sep,
  .brand-status .live-dot,
  #time-label span {
    display: none;
  }
  .brand-text b {
    font-size: 16px;
  }
  .brand-status {
    display: block;
    line-height: 1.1;
  }
  #time-label {
    font-size: 11px;
    color: var(--milk);
  }
  .profile {
    width: 132px;
  }
  #xp-caption,
  #quest-button span {
    display: none;
  }
  #quest-button {
    padding: 0 12px;
  }
}
/* Điện thoại hẹp: bỏ nút toàn màn hình (và nút lịch — lịch mở từ ô "Lịch chùa" trong bảng Thêm) để dải
   công cụ không đè thương hiệu, giữ nút 44px */
@media (max-width: 400px) {
  #fullscreen,
  #calendar-button {
    display: none !important;
  }
  .toolbar {
    padding: 1px;
  }
  .tool {
    height: 44px;
    min-width: 44px;
  }
  .brand {
    height: 48px;
  }
  .actionbar small {
    font-size: 10.5px;
    letter-spacing: -0.01em;
  }
}
@media (max-width: 359px) {
  .profile {
    width: 116px;
  }
}

/* Sảnh trên điện thoại dọc: thẻ là sheet cuộn được, chừa phần trên cho nhân vật 3D */
@media (max-width: 640px) and (min-height: 561px) {
  .cinematic {
    background: linear-gradient(0deg, rgba(15, 9, 5, 0.75), rgba(15, 9, 5, 0.15) 45%, transparent 62%),
      linear-gradient(180deg, rgba(15, 9, 5, 0.55), transparent 16%);
  }
  .lobby {
    display: block;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    pointer-events: auto;
    top: calc(64px + var(--safe-t));
    padding: calc(46dvh - 64px) calc(10px + var(--safe-r)) calc(14px + var(--safe-b))
      calc(10px + var(--safe-l));
  }
  .lobby-card {
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 12px 18px 20px;
    background: radial-gradient(ellipse 80% 30% at 50% 0%, rgba(243, 201, 115, 0.1), transparent 70%),
      linear-gradient(180deg, rgba(47, 34, 22, 0.97), rgba(28, 19, 12, 0.98));
  }
  .lobby-card::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto 14px;
    border-radius: 4px;
    background: rgba(224, 178, 92, 0.35);
  }
  .lobby h1 {
    font-size: 30px;
  }
  .lobby-lead {
    font-size: 13px;
  }
  .seg-track span {
    height: 40px;
  }
  .swatch-row {
    gap: 10px;
  }
  .swatch-row label {
    width: 36px;
    height: 36px;
  }
  .swatch-row label::before {
    content: '';
    position: absolute;
    inset: -4px;
  }
}

/* Điện thoại ngang / cửa sổ thấp */
@media (max-height: 560px) {
  .lobby {
    padding-top: calc(64px + var(--safe-t));
    padding-bottom: calc(10px + var(--safe-b));
    padding-left: calc(12px + var(--safe-l));
  }
  .lobby-card {
    width: min(400px, 56vw);
    padding: 18px 22px;
  }
  .lobby h1 {
    font-size: 26px;
    margin-top: 6px;
  }
  .lobby-lead {
    display: none;
  }
  .ornament {
    margin: 8px auto;
  }
  .field-label {
    margin: 12px 0 6px;
  }
  fieldset {
    margin-top: 12px;
  }
  fieldset > .field-label {
    margin-top: 0;
  }
  .primary {
    margin-top: 16px;
    min-height: 48px;
  }
  .quest-panel,
  .presence,
  .feed,
  .right-bottom,
  .more-sheet {
    left: auto;
    top: calc(8px + var(--safe-t));
    bottom: calc(8px + var(--safe-b));
    right: calc(8px + var(--safe-r));
    width: min(400px, 56vw);
    max-height: none;
    margin: 0;
    transform: translateX(calc(100% + 24px));
  }
  .feed {
    min-height: 0;
  }
  .minimap {
    width: min(240px, 50dvh);
  }
  .more-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .more-tile {
    min-height: 74px;
  }
  .actionbar button,
  #more-actions {
    height: 50px;
  }
  .activity {
    bottom: calc(70px + var(--safe-b));
  }
  .interaction {
    bottom: calc(72px + var(--safe-b));
  }
  #joystick {
    bottom: calc(14px + var(--safe-b));
    width: 100px;
    height: 100px;
  }
  #joystick small {
    display: none;
  }
  #run-toggle {
    bottom: calc(20px + var(--safe-b));
  }
  .view-mode {
    bottom: calc(96px + var(--safe-b));
    grid-auto-rows: 40px;
  }
  .view-mode button {
    width: 40px;
    min-height: 40px;
  }
  .hud-left .profile {
    width: 210px;
  }
}
@media (max-height: 560px) and (max-width: 1100px) {
  .actionbar {
    left: calc(136px + var(--safe-l));
    right: calc(96px + var(--safe-r));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .loading-bar i {
    width: 100%;
    opacity: 0.5;
  }
}
@media (min-width: 1024px) and (min-height: 561px) {
  .quest-panel .panel-head {
    position: relative;
    display: block;
  }
  .quest-panel .panel-head h2 {
    padding-right: 58px;
  }
  .quest-panel #quest-count {
    position: absolute;
    right: 4px;
    bottom: 1px;
  }
}

/* ---- Thời tiết, âm lịch, lễ cạnh đồng hồ ---------------------------------------------------------- */
#time-label .weather-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 6px;
  font-style: normal;
  color: var(--cream);
  vertical-align: -2px;
}
#time-label .weather-chip[hidden],
#time-label .festival-chip[hidden] {
  display: none;
}
#time-label .weather-chip .ico {
  width: 15px;
  height: 15px;
  stroke-width: 1.6;
  color: var(--gold-hi);
}
#time-label .weather-chip i {
  font-style: normal;
}
#time-label .festival-chip {
  display: block;
  font-weight: 500;
  font-size: 11px;
  color: var(--gold-hi);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 230px;
}
.brand-status:has(.festival-chip:not([hidden])) .connection {
  display: none;
}

/* ---- Hộp thoại rộng: hướng dẫn và sổ tay ---------------------------------------------------------- */
dialog[open][data-kind='guide'],
dialog[open][data-kind='journal'] {
  width: min(760px, calc(100vw - 32px));
}
dialog[data-kind='guide'] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: min(86dvh, 760px);
  padding-bottom: 18px;
}
dialog[data-kind='guide'] #modal-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
dialog .guide-lead {
  margin: -6px 0 12px;
  color: var(--milk);
  font-size: 13.5px;
}
.guide-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}
.guide-tabs::-webkit-scrollbar {
  display: none;
}
.guide-tabs button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--milk);
  font-size: 13px;
  white-space: nowrap;
}
.guide-tabs button .ico {
  width: 17px;
  height: 17px;
}
.guide-tabs button[aria-selected='true'] {
  color: #2a1a0c;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  border-color: transparent;
}
.guide-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 4px 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(224, 178, 92, 0.3) transparent;
}
.guide-panel h3 {
  margin: 0 0 8px;
  font: 500 21px/1.25 var(--serif);
  color: var(--gold-hi);
}
.guide-panel h4 {
  margin: 12px 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--cream);
}
.guide-tasks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.guide-task {
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(255, 240, 215, 0.03);
}
.guide-task-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 9px;
}
.guide-task-head .ico {
  grid-row: span 2;
  width: 26px;
  height: 26px;
  padding: 4px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--gold-hi);
}
.guide-task-head strong {
  font-size: 14px;
  color: var(--cream);
}
.guide-task-head small {
  font-size: 11.5px;
  color: var(--gold);
}
dialog .guide-task p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.55;
}
.guide-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--gold-hi);
}
.guide-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.guide-foot .primary {
  width: auto;
  min-width: 220px;
  min-height: 48px;
  margin: 0;
}
.guide-skip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--milk);
  cursor: pointer;
  min-height: 44px;
}
.guide-skip input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

/* ---- Sổ tay hành trình ------------------------------------------------------------------------------ */
.journal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 10px 0 6px;
}
.journal-stats div {
  padding: 12px 8px;
  text-align: center;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-sunk, rgba(0, 0, 0, 0.18));
}
.journal-stats b {
  display: block;
  font: 500 32px/1.1 var(--serif);
  color: var(--gold-hi);
}
.journal-stats small {
  font-size: 11.5px;
  color: var(--milk);
}
.journal-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  margin: 10px 0;
}
.journal-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--milk);
}
.journal-row .ico {
  width: 18px;
  height: 18px;
}
.journal-row.done {
  color: var(--cream);
}
.journal-row.done .ico,
.journal-row.done b {
  color: var(--gold-hi);
}
.journal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.journal-actions .primary,
.card-preview .primary {
  width: auto;
  min-height: 48px;
  margin: 0;
}
.ghost-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--milk);
  font-size: 13px;
}
.ghost-button:hover {
  color: var(--cream);
  border-color: var(--line-strong);
}
.card-preview {
  margin-top: 14px;
  display: grid;
  gap: 10px;
  justify-items: start;
}
.card-preview[hidden] {
  display: none;
}
.card-preview img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
}
a.primary {
  text-decoration: none;
}

@media (max-width: 560px) {
  dialog[data-kind='guide'] {
    padding: 22px 16px 14px;
  }
  .guide-foot {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .guide-foot .primary {
    width: 100%;
  }
  .journal-stats b {
    font-size: 26px;
  }
}
/* Màn hẹp: nút Giới thiệu vẫn có trong Cài đặt và Hướng dẫn; nhường chỗ cho Sổ tay. */
@media (max-width: 480px) {
  #about {
    display: none;
  }
  #time-label .festival-chip {
    max-width: 150px;
  }
}
.guide-schedule {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}
.guide-slot {
  display: grid;
  grid-template-columns: 112px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 13.5px;
}
.guide-slot b {
  color: var(--gold-hi);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.guide-slot small {
  color: var(--milk);
  font-size: 12px;
}
dialog[data-kind='guide'] .guide-tabs,
dialog[data-kind='guide'] .guide-foot,
dialog[data-kind='guide'] h2,
dialog[data-kind='guide'] .guide-lead {
  flex: none;
}
/* Điện thoại ngang / màn thấp: bỏ dòng dẫn, nén lề để phần nội dung còn chỗ cuộn. */
@media (max-height: 560px) {
  dialog[data-kind='guide'] {
    padding: 16px 20px 12px;
    max-height: calc(100dvh - 16px);
  }
  dialog[data-kind='guide'] h2 {
    margin-bottom: 8px;
    font-size: 22px;
  }
  dialog[data-kind='guide'] .guide-lead {
    display: none;
  }
  .guide-tabs button {
    min-height: 36px;
  }
  .guide-foot {
    padding-top: 8px;
  }
}

/* ===== Đợt 3 client: túi đồ / giữ nhân vật, ngắm cảnh, thiền có hướng dẫn, ngoại tuyến ===== */
body:not(.playing) .tool-extra {
  display: none;
}
.tool .badge {
  display: none;
}
.has-new .badge,
#more-actions.has-new::after,
.more-tile.wardrobe-tile.has-new::after {
  content: '';
  display: block;
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--vermilion);
  box-shadow: 0 0 0 2px var(--bg-1);
}
#wardrobe-button,
#more-actions,
.more-tile.wardrobe-tile {
  position: relative;
}
/* Dưới 1440px: "Hôm nay ở chùa" và "Giữ nhân vật" chỉ ở bảng Thêm để thanh công cụ không đè nhãn khu vực. */
@media (max-width: 1439px) {
  #community-button,
  #account-button {
    display: none !important;
  }
}
/* Màn hẹp: túi đồ, giữ nhân vật, ngắm cảnh mở từ bảng Thêm để thanh công cụ không đè thương hiệu. */
@media (max-width: 1023px), (max-height: 560px) {
  .tool-extra {
    display: none !important;
  }
}
.lobby-recover {
  margin: 14px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--milk);
}
.link-button {
  color: var(--gold-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
  font: inherit;
  padding: 2px 0;
}

/* Nút thiền có hướng dẫn (đặt bằng JS ngay trên nút tương tác) */
.guided-pill {
  position: fixed;
  z-index: 11;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px 0 12px;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  color: var(--gold-hi);
  border: 1px solid var(--line-strong);
  animation: pop-in 0.3s var(--ease) both;
}
.guided-pill .ico {
  width: 20px;
  height: 20px;
}
body[data-sheet]:not([data-sheet='']) .guided-pill {
  display: none;
}

/* Ngắm cảnh: ẩn toàn bộ HUD, chỉ còn thanh nút nhỏ mờ dần */
body.scenic-mode .topbar,
body.scenic-mode #game-ui,
body.scenic-mode #nameplates,
body.scenic-mode #world-markers,
body.scenic-mode .cinematic,
body.meditating #game-ui,
body.meditating #world-markers,
body.meditating .topbar,
body.meditating #nameplates {
  display: none !important;
}
.scenic {
  position: fixed;
  inset: 0;
  z-index: 20;
  cursor: pointer;
}
.scenic[hidden] {
  display: none;
}
.scenic-hint {
  position: absolute;
  left: 50%;
  top: calc(22px + var(--safe-t));
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--cream);
  background: rgba(20, 13, 8, 0.6);
  opacity: 0;
  transition: opacity 0.8s var(--ease);
  pointer-events: none;
  white-space: nowrap;
}
.scenic.hint-on .scenic-hint {
  opacity: 1;
}
.scenic-bar {
  position: absolute;
  left: 50%;
  bottom: calc(22px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: var(--r-pill);
  cursor: default;
  transition: opacity 0.8s var(--ease);
}
.scenic.idle .scenic-bar {
  opacity: 0.28;
}
.scenic-bar button {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 18px 0 14px;
  border-radius: var(--r-pill);
  color: var(--cream);
  font-size: 14px;
}
.scenic-bar button:first-child {
  color: var(--bg-0);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  font-weight: 600;
}
.scenic-bar button:hover:not(:first-child) {
  background: rgba(224, 178, 92, 0.14);
}
.scenic-bar .ico {
  width: 20px;
  height: 20px;
}
.scenic.flash::before {
  content: '';
  position: absolute;
  inset: 0;
  background: #fff8e8;
  animation: shot-flash 0.5s ease-out both;
  pointer-events: none;
}
@keyframes shot-flash {
  from {
    opacity: 0.75;
  }
  to {
    opacity: 0;
  }
}

/* Thiền có hướng dẫn: vòng thở vàng — hít vào 4 s nở ra, thở ra 6 s thu lại */
.meditation-picks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.meditation-picks button {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 16px 8px;
  border-radius: 18px;
  border: 1px solid var(--line-strong);
  color: var(--cream);
  background: var(--surface-sunk);
}
.meditation-picks button:hover,
.meditation-picks button:focus-visible {
  background: var(--selected-fill);
  box-shadow: var(--glow);
}
.meditation-picks b {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  color: var(--gold-hi);
  line-height: 1;
}
.meditation-picks small {
  color: var(--milk);
}
.breath {
  position: fixed;
  inset: 0;
  z-index: 19;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  padding: 24px 16px calc(24px + var(--safe-b));
  text-align: center;
  background: radial-gradient(circle at 50% 45%, rgba(15, 9, 5, 0.15), rgba(15, 9, 5, 0.6) 70%);
}
.breath[hidden] {
  display: none;
}
.breath-stage {
  position: relative;
  width: min(56vw, 46vh, 300px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}
.breath-ring,
.breath-core {
  position: absolute;
  border-radius: 50%;
}
.breath-ring {
  inset: 0;
  border: 2px solid rgba(243, 201, 115, 0.85);
  box-shadow:
    0 0 40px rgba(243, 201, 115, 0.35),
    inset 0 0 30px rgba(243, 201, 115, 0.2);
  transform: scale(0.55);
}
.breath-core {
  inset: 18%;
  background: radial-gradient(circle, rgba(243, 201, 115, 0.45), rgba(224, 178, 92, 0.05) 70%);
  transform: scale(0.55);
}
.breath.run .breath-ring,
.breath.run .breath-core {
  animation: breathe 10s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
@keyframes breathe {
  0% {
    transform: scale(0.55);
    opacity: 0.75;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.55);
    opacity: 0.75;
  }
}
.breath-cue {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 6vw, 40px);
  color: var(--gold-hi);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.6);
}
.breath-time {
  margin: 0;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--cream);
  letter-spacing: 0.08em;
}
.breath-line {
  max-width: 420px;
  min-height: 2.8em;
  margin: 6px 0 14px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--cream);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
}
.breath-stop {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  color: var(--cream);
  font-size: 14px;
}
@media (hover: none) {
  .breath-stop kbd {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .breath.run .breath-ring,
  .breath.run .breath-core {
    animation-duration: 10s;
  }
}
.install-row span {
  font-size: 14px;
}
.install-row .ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.install-row .ghost-button .ico {
  width: 18px;
  height: 18px;
}
body.offline .live-dot {
  background: var(--milk-2);
  box-shadow: none;
}
.study-picks {
  grid-template-columns: repeat(2, 1fr);
}
.study-picks b {
  font-size: 19px;
}
.study-picks .ico {
  width: 28px;
  height: 28px;
  color: var(--gold);
  margin-bottom: 4px;
}
