/* ============================================================================
   TIỂU TRẤN NGÔN NGỮ 1.0 (LANGUAGE LIVING WORLD) — WARM CHIBI STORYBOOK UI
   Style Direction: Cozy Warm Wood / Parchment / Lantern Gold / Soft Shadow
   Mobile-First RPG UX:
     - Minimal Single-Row Top Status Bar on Mobile
     - Compact Quest Tracker (mini) + Progressive-Disclosure Bottom Sheet (half / full)
     - Layered Learning Info (中文 / Pinyin / Nghĩa Việt on demand)
     - Thumb-Zone Floating Action Cluster (>= 44x44px touch targets)
     - Slim Centered RPG Icon Dock (labels revealed on active/selected slot or expand)
   ============================================================================ */

:root {
  --parchment-bg: rgba(254, 249, 238, 0.96);
  --parchment-card: #fffaf0;
  --wood-dark: #4a2e1b;
  --wood-mid: #784b2a;
  --wood-border: #8b5a2b;
  --gold-accent: #f59e0b;
  --gold-bright: #fbbf24;
  --jade-green: #16a34a;
  --jade-light: #dcfce7;
  --lantern-red: #dc2626;
  --lantern-warm: #ea580c;
  --text-ink: #2c1810;
  --text-muted: #6b4c35;
  --shadow-soft: 0 6px 20px rgba(44, 24, 16, 0.22);
  --shadow-btn: 0 3px 0 #5c381e;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #87ceeb;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  color: var(--text-ink);
}

#viewport-canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

/* ============================================================================
   1. FLOATING 3D WORLD LABELS (NPCs, Quest Target & Interactive Objects)
   ============================================================================ */
#world-labels-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.world-label-pill {
  position: absolute;
  transform: translate(-50%, -100%);
  background: rgba(254, 249, 238, 0.93);
  border: 2px solid var(--wood-border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-ink);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.world-label-pill:hover {
  transform: translate(-50%, -106%) scale(1.05);
  border-color: var(--gold-accent);
  background: #ffffff;
}

.world-label-pill.npc-pill {
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
  border-color: #d97706;
}

.world-label-pill.target-pill {
  background: linear-gradient(180deg, #fef08a 0%, #fde047 100%);
  border: 2.5px solid #ca8a04;
  color: #422006;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.85), 0 3px 8px rgba(0, 0, 0, 0.28);
  animation: pulseTargetPill 1.35s infinite ease-in-out;
}

.world-label-pill .zh {
  font-size: 13px;
  font-weight: 900;
  color: #9a3412;
  margin-right: 4px;
}

.world-label-pill .pinyin {
  font-size: 10.5px;
  font-weight: 600;
  color: #78350f;
  margin-right: 4px;
}

.world-label-pill .vi {
  font-size: 10.5px;
  font-weight: 700;
  color: #44403c;
}

@keyframes pulseTargetPill {
  0%,
  100% {
    transform: translate(-50%, -100%) scale(1);
  }
  50% {
    transform: translate(-50%, -108%) scale(1.06);
  }
}

/* ============================================================================
   2. TOP HUD BAR (Compact Zone Compass + Time-of-Day + Action Buttons)
   ============================================================================ */
#hud-top-bar {
  position: fixed;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.hud-zone-card {
  pointer-events: auto;
  background: var(--parchment-bg);
  border: 2.5px solid var(--wood-border);
  border-radius: 14px;
  padding: 6px 12px;
  box-shadow: var(--shadow-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: min(520px, 52vw);
}

.zone-time-badge {
  background: linear-gradient(135deg, #fde68a 0%, #f59e0b 100%);
  border: 2px solid #b45309;
  border-radius: 10px;
  padding: 4px 8px;
  text-align: center;
  min-width: 68px;
  flex-shrink: 0;
}

.zone-time-icon {
  font-size: 16px;
  display: block;
  line-height: 1.05;
}

.zone-time-text {
  font-size: 10.5px;
  font-weight: 800;
  color: #451a03;
}

.zone-info-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.zone-chapter-tag {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--lantern-warm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zone-title-main {
  font-size: 14.5px;
  font-weight: 900;
  color: var(--text-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zone-title-sub {
  display: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

@media (min-width: 1440px) {
  .zone-title-sub {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.hud-actions-group {
  pointer-events: auto;
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  flex-shrink: 0;
}

.chibi-btn {
  background: var(--parchment-card);
  border: 2px solid var(--wood-border);
  border-radius: 11px;
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-ink);
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  transition: transform 0.1s ease, background 0.15s ease;
}

.chibi-btn:hover {
  background: #fef3c7;
  transform: translateY(-1px);
}

.chibi-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #5c381e;
}

.chibi-btn.primary-gold,
.chibi-btn.primary-gold-action {
  background: linear-gradient(180deg, #fde047 0%, #f59e0b 100%);
  border-color: #92400e;
  color: #451a03;
}

.chibi-btn.accent-green {
  background: linear-gradient(180deg, #86efac 0%, #22c55e 100%);
  border-color: #166534;
  color: #052e16;
}

.btn-badge-pill {
  background: #78350f;
  color: #fef3c7;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10.5px;
  font-weight: 900;
}

.btn-label-short,
.action-btn-short {
  display: none;
}

/* ============================================================================
   3. BOTTOM HUD BAR: QUEST SCROLL / BOTTOM SHEET + INVENTORY BELT
   ============================================================================ */
#hud-bottom-bar {
  position: fixed;
  bottom: 10px;
  left: 12px;
  right: 12px;
  z-index: 15;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

/* Dialogue & Quest Scroll Card */
.quest-scroll-panel {
  pointer-events: auto;
  flex: 1 1 0;
  min-width: 0;
  max-width: 780px;
  background: var(--parchment-bg);
  border: 2.5px solid var(--wood-border);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: padding 0.18s ease, max-height 0.2s ease;
}

/* Mobile Bottom-Sheet Handle & Progressive Disclosure Pills (Hidden on wide Desktop) */
.quest-sheet-handle-bar {
  display: none;
}

.quest-sheet-toggle-btn {
  display: none;
}

.quest-card-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding-bottom: 5px;
  border-bottom: 1.5px dashed rgba(139, 90, 43, 0.3);
}

.quest-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.npc-speaker-avatar {
  background: linear-gradient(135deg, #d97706 0%, #92400e 100%);
  border: 2px solid #451a03;
  border-radius: 999px;
  padding: 3px 10px;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  color: #fffbeb;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(69, 26, 3, 0.25);
}

.npc-speaker-avatar .speaker-zh {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.1;
}

.npc-speaker-avatar .speaker-vi {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.95;
}

.quest-step-header {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}

.quest-step-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--lantern-warm);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quest-inline-badges {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.quest-inline-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: 999px;
  padding: 1.5px 7px;
  font-size: 10.5px;
  font-weight: 800;
}

.quest-inline-pill.action-pill {
  display: none;
}

.quest-inline-pill.audio-pill {
  background: #fef3c7;
  color: #78350f;
  border: 1px solid #d97706;
  cursor: pointer;
}

.quest-replay-cluster {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.quest-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 800;
  border: 1.5px solid #b45309;
  background: linear-gradient(180deg, #fef08a 0%, #f59e0b 100%);
  color: #451a03;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 0 #78350f;
  transition: transform 0.1s ease, background 0.15s ease;
}

.quest-replay-btn:hover {
  background: linear-gradient(180deg, #fef9c3 0%, #fbbf24 100%);
}

.quest-replay-btn:active {
  transform: translateY(1px);
}

.quest-replay-btn.is-playing {
  background: linear-gradient(180deg, #bbf7d0 0%, #22c55e 100%);
  border-color: #15803d;
  color: #052e16;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.35);
}

.quest-speed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 900;
  border: 1.5px solid #78350f;
  background: #fffbeb;
  color: #78350f;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 0 #78350f;
  transition: background 0.12s ease;
}

.quest-speed-btn.slow-active {
  background: #dcfce7;
  border-color: #15803d;
  color: #14532d;
}

/* Action Buttons inside Top Header Row on Desktop */
.quest-action-col {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.quest-action-col .chibi-btn {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 10px;
}

/* Full-Width Reading Body — 100% of Card Width */
.quest-text-body {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.quest-hanzi-line {
  width: 100%;
  font-size: clamp(16px, 1.35vw, 18.5px);
  font-weight: 900;
  color: #1c1917;
  line-height: 1.34;
  word-break: normal;
  overflow-wrap: break-word;
}

.quest-hanzi-line .hl-word {
  background: #fef08a;
  border-bottom: 2px solid #d97706;
  padding: 0 4px;
  border-radius: 4px;
  color: #9a3412;
}

.quest-pinyin-line {
  width: 100%;
  font-size: clamp(12.5px, 1.05vw, 14px);
  font-weight: 700;
  color: #9a3412;
  line-height: 1.35;
  word-break: normal;
  overflow-wrap: break-word;
}

.quest-vi-line {
  width: 100%;
  font-size: clamp(12.5px, 1.05vw, 14px);
  font-weight: 600;
  color: #44403c;
  line-height: 1.38;
  word-break: normal;
  overflow-wrap: break-word;
}

/* Right/Bottom Compact 6-Slot Inventory & Tool Belt (Bright Cream-Gold Theme) */
.inventory-belt-panel {
  pointer-events: auto;
  flex-shrink: 0;
  background: linear-gradient(180deg, #fffdf7 0%, #fef3c7 100%);
  border: 2.5px solid #b45309;
  border-radius: 16px;
  padding: 7px 10px;
  box-shadow: 0 6px 20px rgba(69, 26, 3, 0.2), inset 0 1px 0 #ffffff;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.inventory-belt-title {
  font-size: 11px;
  font-weight: 900;
  color: #78350f;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: center;
  border-bottom: 1.5px dashed rgba(180, 83, 9, 0.3);
  padding-bottom: 3px;
}

.inventory-dock-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.inv-dock-toggle-btn {
  display: none;
}

.inventory-slots-row {
  display: flex;
  gap: 5px;
}

.inv-slot {
  width: 54px;
  height: 60px;
  background: linear-gradient(180deg, #ffffff 0%, #fff7ed 100%);
  border: 2px solid #d6b88d;
  border-radius: 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px 2px;
  position: relative;
  cursor: pointer;
  transition: all 0.14s ease;
  box-shadow: inset 0 1px 0 #ffffff, 0 2px 4px rgba(120, 53, 15, 0.08);
}

.inv-label-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
}

.inv-slot:not(.owned) {
  background: linear-gradient(180deg, #faf5eb 0%, #f3ead8 100%);
  border: 2px dashed #c7b293;
}

.inv-slot:not(.owned) .inv-icon-badge {
  background: #ede3cf;
  border-color: #d5c3a6;
  opacity: 0.72;
}

.inv-slot:not(.owned) .inv-zh {
  color: #574534;
}

.inv-slot:not(.owned) .inv-vi {
  color: #78624c;
}

.inv-slot.owned {
  background: linear-gradient(180deg, #ffffff 0%, #fef3c7 100%);
  border: 2px solid #d97706;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.2), inset 0 1px 0 #ffffff;
}

.inv-slot.owned:hover {
  transform: translateY(-2px);
  border-color: #b45309;
  background: linear-gradient(180deg, #ffffff 0%, #fde68a 100%);
}

.inv-slot.equipped {
  background: linear-gradient(180deg, #fef08a 0%, #fbbf24 100%);
  border: 2.5px solid #b45309;
  box-shadow: 0 0 0 2.5px rgba(251, 191, 36, 0.45), 0 4px 10px rgba(180, 83, 9, 0.3);
  transform: translateY(-2px);
}

.inv-icon-badge {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(120, 53, 15, 0.12);
}

.inv-slot.equipped .inv-icon-badge {
  background: #ffffff;
  border-color: #92400e;
}

.inv-slot .inv-icon {
  font-size: 15px;
  line-height: 1;
}

.inv-slot .inv-zh {
  font-size: 11px;
  font-weight: 900;
  color: #2c1810;
  line-height: 1.05;
}

.inv-slot .inv-vi {
  font-size: 9px;
  font-weight: 800;
  color: #5c3a21;
  line-height: 1.05;
  text-align: center;
}

.inv-slot .inv-active-tag {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  background: #15803d;
  color: #ffffff;
  border: 1.5px solid #dcfce7;
  border-radius: 999px;
  font-size: 7.5px;
  font-weight: 900;
  padding: 0.5px 4px;
  white-space: nowrap;
  letter-spacing: 0.2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
}

.inv-slot .inv-qty {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #dc2626;
  color: #ffffff;
  border: 1.5px solid #ffffff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  padding: 0 5px;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

/* ============================================================================
   4. CONTEXTUAL CONTRASTIVE / SUBSTEP TOAST BANNER (Responsive Width)
   ============================================================================ */
#feedback-toast {
  position: fixed;
  top: 68px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  z-index: 25;
  background: rgba(255, 252, 242, 0.98);
  border: 2.5px solid var(--gold-accent);
  border-radius: 16px;
  padding: 10px 18px;
  box-shadow: 0 8px 24px rgba(44, 24, 16, 0.28);
  text-align: center;
  width: min(560px, calc(100vw - 24px));
  min-width: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#feedback-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#feedback-toast.toast-distractor {
  border-color: var(--lantern-red);
  background: linear-gradient(180deg, #fff5f5 0%, #fef2f2 100%);
}

#feedback-toast.toast-success {
  border-color: var(--jade-green);
  background: linear-gradient(180deg, #f0fdf4 0%, #dcfce7 100%);
}

.toast-header-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.toast-action-badge {
  background: #166534;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

#feedback-toast.toast-distractor .toast-action-badge {
  background: #b91c1c;
}

.toast-speaker-pill {
  background: #fef3c7;
  border: 1.5px solid #d97706;
  color: #78350f;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.toast-hanzi {
  font-size: clamp(15px, 1.4vw, 18px);
  font-weight: 900;
  color: #1c1917;
  line-height: 1.34;
  word-break: normal;
  overflow-wrap: break-word;
}

.toast-hanzi .hl-word {
  background: #fef08a;
  border-bottom: 2px solid #d97706;
  padding: 0 4px;
  border-radius: 4px;
  color: #9a3412;
}

.toast-pinyin {
  font-size: clamp(12px, 1.1vw, 13.5px);
  font-weight: 700;
  color: #9a3412;
  margin-top: 2px;
  line-height: 1.32;
}

.toast-vi {
  font-size: clamp(12px, 1.1vw, 13.5px);
  font-weight: 700;
  color: #292524;
  margin-top: 2px;
  line-height: 1.35;
}

/* ============================================================================
   5. MODAL OVERLAYS (Vocabulary Notebook, Village Map, Save/Load, Onboarding)
   ============================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(28, 25, 23, 0.58);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none !important;
}

.chibi-modal-card {
  background: #fffbeb;
  border: 3.5px solid var(--wood-border);
  border-radius: 22px;
  max-width: 820px;
  width: 100%;
  max-height: 88vh;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(180deg, #fde68a 0%, #fcd34d 100%);
  border-bottom: 2.5px solid var(--wood-border);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-title {
  font-size: clamp(15px, 1.6vw, 19px);
  font-weight: 900;
  color: #451a03;
}

.modal-close-btn {
  background: #ef4444;
  color: #fff;
  border: 2px solid #7f1d1d;
  border-radius: 10px;
  padding: 4px 11px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  padding: 10px 18px;
  border-top: 2px solid #e7e5e4;
  background: #fef3c7;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* Vocabulary Grid */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.vocab-card {
  background: #ffffff;
  border: 2px solid #d6d3d1;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.vocab-card.status-MASTERED,
.vocab-card.status-IMMEDIATE_RECALL_PASSED {
  border-color: #16a34a;
  background: #f0fdf4;
}

.vocab-card.status-COMPLETED,
.vocab-card.status-GUIDED_ACTION {
  border-color: #f59e0b;
  background: #fffbeb;
}

.vocab-card.status-SEEN {
  border-color: #38bdf8;
  background: #f0f9ff;
}

.vocab-card.distractor-card {
  border-style: dashed;
  border-color: #ea580c;
  background: #fff7ed;
}

.vocab-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

.vocab-hanzi {
  font-size: 20px;
  font-weight: 900;
  color: #1c1917;
}

.vocab-status-pill {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
}

.vocab-status-pill.MASTERED,
.vocab-status-pill.IMMEDIATE_RECALL_PASSED {
  background: #16a34a;
  color: #fff;
}

.vocab-status-pill.COMPLETED,
.vocab-status-pill.GUIDED_ACTION {
  background: #f59e0b;
  color: #451a03;
}

.vocab-status-pill.SEEN {
  background: #0284c7;
  color: #fff;
}

.vocab-status-pill.UNSEEN {
  background: #e7e5e4;
  color: #57534e;
}

.vocab-pinyin {
  font-size: 12.5px;
  font-weight: 700;
  color: #9a3412;
}

.vocab-vi {
  font-size: 12.5px;
  font-weight: 700;
  color: #44403c;
}

/* Save Slots Grid */
.save-slots-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.save-slot-card {
  background: #ffffff;
  border: 2.5px solid var(--wood-border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Zone Map Grid */
.zone-map-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.zone-map-card {
  background: #ffffff;
  border: 2px solid var(--wood-border);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ============================================================================
   6. RESPONSIVE & MOBILE-FIRST RPG UI BREAKPOINTS
   ============================================================================ */

/* --- BREAKPOINT A: Compact Desktop / Landscape Tablet (<= 1180px, e.g., 1024×768) --- */
@media (max-width: 1180px) {
  .hud-zone-card {
    padding: 5px 10px;
    max-width: 440px;
  }

  .zone-title-main {
    font-size: 13.5px;
  }

  .hud-actions-group .chibi-btn {
    padding: 5px 9px;
    font-size: 11.5px;
  }

  .quest-scroll-panel {
    padding: 9px 12px;
  }

  .inv-slot {
    width: 48px;
    height: 55px;
  }

  .inv-icon-badge {
    width: 22px;
    height: 22px;
  }

  .inv-slot .inv-icon {
    font-size: 14px;
  }

  .inv-slot .inv-zh {
    font-size: 10.5px;
  }

  .inv-slot .inv-vi {
    font-size: 8.5px;
  }
}

/* --- BREAKPOINT B: Tablet & Mobile RPG HUD Architecture (<= 960px, e.g., 768×1024, 430×932, 390×844) --- */
@media (max-width: 960px) {
  #hud-top-bar {
    top: 6px;
    left: 8px;
    right: 8px;
    gap: 6px;
  }

  .hud-zone-card {
    max-width: none;
    flex: 1 1 auto;
    padding: 4px 10px;
    border-radius: 999px;
    gap: 8px;
  }

  .zone-time-badge {
    min-width: 0;
    padding: 2px 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .zone-time-icon {
    font-size: 14px;
    display: inline;
  }

  .zone-time-text {
    font-size: 10px;
  }

  .zone-info-col {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
    overflow: hidden;
  }

  .zone-chapter-tag {
    font-size: 10px;
    flex-shrink: 0;
  }

  .zone-title-main {
    font-size: 12.5px;
  }

  /* Bottom HUD Stack: Compact Quest Tracker / Bottom Sheet + Slim Centered RPG Dock */
  #hud-bottom-bar {
    bottom: 6px;
    left: 8px;
    right: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
  }

  .quest-scroll-panel {
    position: relative;
    width: 100%;
    max-width: none;
    flex: none;
    padding: 7px 11px;
    border-radius: 15px;
    gap: 4px;
  }

  /* Progressive-Disclosure Handle & Mode Pills Bar */
  .quest-sheet-handle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding-bottom: 3px;
    border-bottom: 1px dashed rgba(139, 90, 43, 0.25);
  }

  .sheet-grab-pill {
    width: 26px;
    height: 4px;
    border-radius: 999px;
    background: rgba(139, 90, 43, 0.42);
    cursor: pointer;
    flex-shrink: 0;
  }

  .quest-sheet-mode-pills {
    display: flex;
    align-items: center;
    gap: 3px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .quest-sheet-mode-pills::-webkit-scrollbar {
    display: none;
  }

  .sheet-mode-pill {
    background: rgba(254, 243, 199, 0.9);
    border: 1.5px solid #d97706;
    border-radius: 999px;
    padding: 1.5px 6px;
    font-size: 9.5px;
    font-weight: 800;
    color: #78350f;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.12s ease;
  }

  .sheet-mode-pill.active {
    background: #d97706;
    color: #fffbeb;
    border-color: #78350f;
  }

  .quest-card-top-bar {
    padding-bottom: 2px;
    border-bottom: none;
    gap: 6px;
  }

  .quest-header-left {
    cursor: pointer;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .npc-speaker-avatar {
    padding: 2px 8px;
    gap: 4px;
  }

  .npc-speaker-avatar .speaker-zh {
    font-size: 12.5px;
  }

  .npc-speaker-avatar .speaker-vi {
    font-size: 10px;
  }

  .quest-step-header {
    flex-wrap: nowrap;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    gap: 4px;
  }

  .quest-step-title {
    font-size: 10.5px;
    flex: 1 1 0;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .quest-inline-badges {
    flex-shrink: 0;
  }

  .quest-inline-pill.action-pill {
    display: none;
  }

  .quest-inline-pill.audio-pill {
    font-size: 9px;
    padding: 1px 5px;
    flex-shrink: 0;
  }

  .quest-replay-cluster {
    gap: 3px;
    flex-shrink: 0;
  }

  .quest-replay-btn {
    padding: 1.5px 6px;
    font-size: 9.5px;
    gap: 2px;
  }

  .quest-speed-btn {
    padding: 1.5px 5px;
    font-size: 9px;
  }

  .quest-sheet-toggle-btn {
    display: inline-flex;
    align-items: center;
    background: #fef3c7;
    border: 1.5px solid #b45309;
    border-radius: 999px;
    padding: 2px 7px;
    font-size: 9.5px;
    font-weight: 800;
    color: #78350f;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ==========================================================================
     PROGRESSIVE DISCLOSURE STATES FOR `#hud-quest-scroll` (mini / half / full)
     ========================================================================== */

  /* 1. MINI STATE (Default Mobile RPG Quest Tracker — 1-line compact preview when exploring, 2-line compact full Hanzi while NPC is actively speaking) */
  #hud-quest-scroll[data-sheet-state="mini"] .quest-hanzi-line {
    font-size: 13.5px;
    line-height: 1.22;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
  }

  #hud-quest-scroll[data-sheet-state="mini"].audio-speaking .quest-hanzi-line {
    font-size: 12.5px;
    line-height: 1.2;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  #hud-quest-scroll[data-sheet-state="mini"] .quest-pinyin-line,
  #hud-quest-scroll[data-sheet-state="mini"] .quest-vi-line {
    display: none;
  }

  /* 2. HALF STATE (Bottom Sheet Half — Full Hanzi + On-Demand Pinyin OR Vietnamese) */
  #hud-quest-scroll[data-sheet-state="half"] .quest-hanzi-line {
    font-size: 15.5px;
    line-height: 1.34;
    white-space: normal;
  }

  #hud-quest-scroll[data-sheet-state="half"][data-lang-mode="hanzi"] .quest-pinyin-line,
  #hud-quest-scroll[data-sheet-state="half"][data-lang-mode="hanzi"] .quest-vi-line {
    display: none;
  }

  #hud-quest-scroll[data-sheet-state="half"][data-lang-mode="pinyin"] .quest-pinyin-line {
    display: block;
    font-size: 13px;
    line-height: 1.34;
  }

  #hud-quest-scroll[data-sheet-state="half"][data-lang-mode="pinyin"] .quest-vi-line {
    display: none;
  }

  #hud-quest-scroll[data-sheet-state="half"][data-lang-mode="vi"] .quest-pinyin-line {
    display: none;
  }

  #hud-quest-scroll[data-sheet-state="half"][data-lang-mode="vi"] .quest-vi-line {
    display: block;
    font-size: 13px;
    line-height: 1.35;
  }

  /* 3. FULL STATE (Expanded Bottom Sheet — Complete Hanzi + Pinyin + Vietnamese) */
  #hud-quest-scroll[data-sheet-state="full"] .quest-hanzi-line {
    font-size: 15.5px;
    line-height: 1.34;
    white-space: normal;
  }

  #hud-quest-scroll[data-sheet-state="full"] .quest-pinyin-line,
  #hud-quest-scroll[data-sheet-state="full"] .quest-vi-line {
    display: block;
    font-size: 12.5px;
    line-height: 1.34;
  }

  /* ==========================================================================
     THUMB-ZONE FLOATING ACTION BUTTONS (>= 44x44px Touch Targets, Always 8px Above Sheet)
     ========================================================================== */
  .quest-action-col {
    position: absolute;
    right: 2px;
    bottom: calc(100% + 8px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    pointer-events: auto;
  }

  .action-btn-text {
    display: none;
  }

  .action-btn-short {
    display: inline;
  }

  #btn-guide-to-target {
    min-height: 44px;
    min-width: 44px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 11.5px;
    box-shadow: 0 4px 12px rgba(5, 46, 22, 0.28), 0 2px 0 #14532d;
  }

  #btn-interact-now {
    min-height: 46px;
    min-width: 48px;
    padding: 0 15px;
    border-radius: 999px;
    font-size: 12.5px;
    box-shadow: 0 5px 14px rgba(146, 64, 14, 0.34), 0 2px 0 #78350f;
  }

  /* ==========================================================================
     SLIM MOBILE RPG INVENTORY DOCK (Icons + Active/Selected Item Label Only)
     ========================================================================== */
  .inventory-belt-panel {
    width: fit-content;
    max-width: calc(100vw - 16px);
    margin: 0 auto;
    padding: 4px 8px;
    border-radius: 999px;
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }

  .inventory-belt-title {
    display: none;
  }

  .inventory-dock-row {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .inv-dock-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1.5px solid #b45309;
    background: #fef3c7;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .inventory-slots-row {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .inv-slot {
    width: 36px;
    height: 34px;
    border-radius: 999px;
    padding: 0;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
  }

  .inv-slot .inv-active-tag {
    display: none;
  }

  .inv-slot .inv-icon-badge {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    margin: 0;
    border: none;
    background: transparent;
    box-shadow: none;
  }

  .inv-slot .inv-icon {
    font-size: 14px;
  }

  /* Hide text labels on inactive slots in slim dock */
  .inv-slot .inv-label-group {
    display: none;
  }

  /* Reveal inline label ONLY on equipped slot, tapped/selected slot, or when dock is expanded */
  .inv-slot.equipped,
  .inv-slot.selected-slot,
  .inventory-belt-panel.dock-expanded .inv-slot {
    width: auto;
    height: 34px;
    padding: 0 9px 0 4px;
    border-radius: 999px;
    gap: 4px;
    transform: none;
  }

  .inv-slot.equipped .inv-label-group,
  .inv-slot.selected-slot .inv-label-group,
  .inventory-belt-panel.dock-expanded .inv-slot .inv-label-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.02;
  }

  .inv-slot .inv-zh {
    font-size: 10px;
  }

  .inv-slot .inv-vi {
    font-size: 7.5px;
    white-space: nowrap;
  }

  .inv-slot .inv-qty {
    font-size: 8.5px;
    padding: 0 4px;
    min-width: 14px;
    top: -4px;
    right: -3px;
  }

  #feedback-toast {
    top: 52px;
    width: min(500px, calc(100vw - 16px));
    padding: 8px 12px;
    border-radius: 13px;
  }

  .zone-map-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- BREAKPOINT C: Mobile Portrait (<= 640px, e.g., 430×932 & 390×844) --- */
@media (max-width: 640px) {
  /* Single-Row Minimal Top Status Bar on Mobile (Height ~38px) */
  #hud-top-bar {
    top: 6px;
    left: 6px;
    right: 6px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
  }

  .hud-zone-card {
    flex: 1 1 auto;
    min-width: 0;
    padding: 4px 8px;
    border-radius: 999px;
    gap: 5px;
  }

  .zone-time-badge {
    padding: 2px 5px;
  }

  .zone-time-text {
    display: none;
  }

  .zone-info-col {
    flex-direction: column;
    gap: 0;
    min-width: 0;
  }

  .zone-chapter-tag {
    font-size: 8.5px;
    line-height: 1.05;
  }

  .zone-title-main {
    font-size: 11px;
    line-height: 1.15;
  }

  .hud-actions-group {
    display: flex;
    flex-direction: row;
    gap: 4px;
    flex-shrink: 0;
  }

  .hud-actions-group .chibi-btn {
    position: relative;
    min-width: 36px;
    height: 36px;
    padding: 0 7px;
    font-size: 11.5px;
    border-radius: 999px;
    justify-content: center;
    gap: 3px;
    box-shadow: 0 2px 0 #5c381e;
  }

  /* Invisible 46x46px hit-area expansion so compact 36px visual buttons meet >= 44x44pt touch target */
  .hud-actions-group .chibi-btn::after {
    content: "";
    position: absolute;
    inset: -5px;
  }

  .btn-label-full,
  .btn-label-short {
    display: none;
  }

  .btn-badge-pill {
    padding: 0.5px 4px;
    font-size: 9px;
  }

  .sheet-grab-pill {
    width: 14px;
  }

  .quest-sheet-toggle-btn {
    display: none;
  }

  /* Compact 3D World Labels on Mobile */
  .world-label-pill {
    padding: 2.5px 8px;
    font-size: 11px;
  }

  .world-label-pill .zh {
    font-size: 12px;
  }

  .world-label-pill .pinyin,
  .world-label-pill .vi {
    font-size: 9.5px;
  }

  /* Responsive Modals on Mobile */
  .modal-backdrop {
    padding: 8px;
  }

  .chibi-modal-card {
    max-height: 92vh;
    border-radius: 16px;
  }

  .modal-header {
    padding: 10px 12px;
  }

  .modal-body {
    padding: 12px;
  }

  .save-slots-grid,
  .zone-map-grid {
    grid-template-columns: 1fr;
  }

  .vocab-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
