/* Immersion Town – phong cách tranh Đông Hồ: giấy điệp, mực tàu, đỏ son, vàng hoè, xanh chàm */
:root {
  --do-paper-bg: #F5E6C8;      /* Kem ngà vỏ sò */
  --do-paper-fiber: #E8D5B0;   /* Xơ giấy điệp */
  --ink-black: #1A1A1A;        /* Mực tàu khắc gỗ */
  --red-vermilion: #C83228;    /* Đỏ son */
  --yellow-heritage: #E6B422;  /* Vàng hoè di sản */
  --green-indigo: #1B4D3E;     /* Xanh chàm sông Hoài */
  --stone-grey: #817B72;       /* Xám đá hẻm phố */
  --paper-overlay-opacity: 0.18;
  --muted: #5b5349;
  --ok: #1B4D3E;
  --ok-bg: #dfeadb;
  --bad: #C83228;
  --bad-bg: #f6d9d2;
  --warn-bg: #f7e7b9;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: 'Be Vietnam Pro', 'Segoe UI', Tahoma, sans-serif;
  color: var(--ink-black);
  background: #2b2b2b;
  min-height: 100vh;
  line-height: 1.5;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 3px solid var(--yellow-heritage);
  outline-offset: 2px;
}

/* ==========================================================================
   1. GIẤY ĐIỆP ĐÔNG HỒ
   ========================================================================== */
.dongho-panel,
.dongho-paper-panel {
  position: relative;
  background-color: var(--do-paper-bg);
  border: 4px solid var(--ink-black);
  border-radius: 10px;
  box-shadow: 4px 4px 0 var(--ink-black), inset 1px 1px 2px rgba(0, 0, 0, 0.12);
  outline: 1px dashed rgba(26, 26, 26, 0.3);
  outline-offset: -3px;
}

.dongho-ink-text {
  color: var(--ink-black);
  text-shadow: 0.5px 0.5px 0 rgba(26, 26, 26, 0.3), -0.3px -0.3px 1px rgba(200, 50, 40, 0.15);
}

/* Lớp làm mờ phông nền khi bật khung thoại / thẻ từ (Backdrop Paper Blur) */
.dongho-backdrop-blur {
  backdrop-filter: blur(3.5px) sepia(25%) contrast(105%);
  -webkit-backdrop-filter: blur(3.5px) sepia(25%) contrast(105%);
  background-color: rgba(245, 230, 200, 0.55);
}

/* ==========================================================================
   KHUNG TRÒ CHƠI TRÊN GIẤY ĐIỆP
   (bản đồ 3/4 từ trên xuống, mặt đất lưới ô và Y-sort được vẽ trên canvas trong js/town.js)
   ========================================================================== */

/* Khung chứa Game Viewport */
.parallax-viewport {
  position: relative;
  width: 100%;
  margin: 0 auto;
  background-color: var(--do-paper-bg, #F5E6C8);
  border: 6px solid var(--ink-black, #1A1A1A);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.view {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
}

/* Layer 5: Lớp phủ vân xơ giấy điệp ngâm vỏ sò CỐ ĐỊNH */
.layer-paper-grain-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
  opacity: 0.22;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='paperNoise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='1 0 0 0 0  0 0.9 0 0 0  0 0 0.7 0 0  0 0 0 0.28 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23paperNoise)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

#world {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: pointer;
}

.paper-blur {
  position: absolute;
  inset: 0;
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

.paper-blur.show {
  opacity: 1;
  pointer-events: auto;
}

.loading {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  font-weight: 700;
  text-align: center;
  background: var(--do-paper-bg);
}

/* ==========================================================================
   2. THANH TRÊN & TRÀ ĐÁ HELPER
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: #2b2b2b;
  border-bottom: 3px solid var(--ink-black);
}

.home-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-weight: 800;
  color: var(--ink-black);
  text-decoration: none;
  background: var(--yellow-heritage);
  border: 3px solid var(--ink-black);
  border-radius: 8px;
  box-shadow: 3px 3px 0 #000;
  transition: transform 0.15s, box-shadow 0.15s;
}

.home-link:hover {
  transform: translateY(-1px);
  box-shadow: 4px 4px 0 #000;
}

.hud {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.trada-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  border-width: 3px;
  border-radius: 20px;
  box-shadow: 3px 3px 0 #000;
}

.trada-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--red-vermilion);
}

.trada-cups {
  display: flex;
  gap: 3px;
}

.cup {
  font-size: 1.05rem;
  filter: grayscale(100%);
  opacity: 0.3;
  transition: all 0.2s;
}

.cup.active {
  filter: none;
  opacity: 1;
}

.hud-item {
  padding: 3px 10px;
  font-weight: 700;
  white-space: nowrap;
  border-width: 3px;
  box-shadow: 3px 3px 0 #000;
}

.hud-btn {
  width: 38px;
  height: 34px;
  padding: 0;
  border-width: 3px;
  box-shadow: 3px 3px 0 #000;
}

/* Nút đổi ngôn ngữ chỉ dẫn EN/VI */
.hud-btn.lang-btn {
  width: 44px;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink-black);
}

.container {
  width: min(1180px, 100% - 24px);
  margin: 0 auto;
  padding: 16px 0 40px;
}

/* ==========================================================================
   3. KHUNG THOẠI ĐÔNG HỒ (Layer 4 – cố định)
   ========================================================================== */
.dialogue-box {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  gap: 18px;
  max-height: 68%;
  overflow: auto;
  padding: 14px 18px;
}

.npc-portrait {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--yellow-heritage);
  border: 3px solid var(--ink-black);
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--ink-black);
}

.npc-portrait img,
.npc-portrait canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dialogue-content {
  flex: 1;
  min-width: 0;
}

.npc-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-bottom: 6px;
}

.npc-name {
  padding: 2px 12px;
  font-weight: 800;
  color: #fff;
  background: var(--red-vermilion);
  border: 2px solid var(--ink-black);
  border-radius: 4px;
  box-shadow: 2px 2px 0 var(--ink-black);
}

.npc-role {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green-indigo);
}

.npc-header .close-btn {
  margin-left: auto;
}

.close-btn {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 0.8rem;
  line-height: 1;
  color: #fff;
  background: var(--red-vermilion);
  border: 2px solid var(--ink-black);
  border-radius: 50%;
  box-shadow: 1px 1px 0 var(--ink-black);
}

.dlg-body > p {
  margin: 0 0 8px;
}

.dialogue-text {
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.55;
}

.dialogue-text.vi {
  font-style: italic;
  color: #6b2a14;
}

.dlg-title {
  margin: 0 0 6px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.2rem;
}

.dlg-title small {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.dlg-trans {
  padding: 6px 10px;
  background: rgba(27, 77, 62, 0.1);
  border-left: 4px solid var(--green-indigo);
  border-radius: 4px;
}

.dlg-prompt {
  font-weight: 800;
  color: var(--red-vermilion);
}

.dlg-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
}

.objectives {
  margin: 0 0 8px;
  padding-left: 20px;
}

.prep-title {
  margin: 0 0 6px;
  font-weight: 700;
}

.term {
  font: inherit;
  color: inherit;
  padding: 0 2px;
  background: none;
  border: 0;
  border-bottom: 2px dotted var(--ink-black);
  border-radius: 2px;
}

.term.u {
  color: var(--red-vermilion);
  background: rgba(200, 50, 40, 0.1);
  border-bottom: 2px solid var(--red-vermilion);
}

.term.k {
  color: var(--green-indigo);
  border-bottom: 2px solid var(--green-indigo);
}

.chips .term {
  padding: 1px 10px;
  font-size: 0.88rem;
  font-weight: 700;
  border: 2px solid currentColor;
  border-radius: 999px;
}

/* Nút hành động */
.action-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.action-bar.start {
  justify-content: flex-start;
}

.btn-action {
  padding: 6px 16px;
  font-weight: 800;
  color: var(--ink-black);
  background: var(--yellow-heritage);
  border: 3px solid var(--ink-black);
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--ink-black);
  transition: transform 0.1s;
}

.btn-action:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn-action:disabled {
  opacity: 0.5;
  box-shadow: none;
}

.btn-action.small {
  padding: 3px 10px;
  font-size: 0.85rem;
  border-width: 2px;
}

.btn-action.big {
  padding: 10px 24px;
  font-size: 1.1rem;
}

.btn-primary {
  color: #fff;
  background: var(--red-vermilion);
}

.link-btn {
  padding: 4px 2px;
  font-weight: 700;
  color: var(--green-indigo);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mini-btn {
  padding: 0 2px;
  background: none;
  border: 0;
  font-size: 0.95rem;
}

.muted {
  color: var(--muted);
}

.notice {
  margin: 8px 0;
  padding: 8px 12px;
  font-size: 0.92rem;
  background: var(--warn-bg);
  border: 2px solid var(--ink-black);
  border-radius: 8px;
}

.notice.good {
  background: var(--ok-bg);
}

/* ==========================================================================
   4. THẺ TRA CỨU TỪ VỰNG (Poke & Prod)
   ========================================================================== */
.vocab-card {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 70;
  width: min(400px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 16px 18px;
  transform: translate(-50%, -50%);
  animation: card-in 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes card-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

.wc-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px;
  padding-bottom: 6px;
  font-size: 1rem;
  color: var(--red-vermilion);
  border-bottom: 2px dashed var(--ink-black);
}

.wc-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.wc-img {
  flex-shrink: 0;
  width: 96px;
  height: 96px;
  object-fit: contain;
  background: rgba(230, 180, 34, 0.15);
  border: 2px solid var(--ink-black);
  border-radius: 8px;
}

.wc-word {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--green-indigo);
}

.wc-phon,
.phon {
  margin: 0;
  color: var(--muted);
  font-family: 'Segoe UI', 'Lucida Sans Unicode', 'Arial Unicode MS', sans-serif;
}

.wc-phon em {
  color: var(--red-vermilion);
  font-size: 0.85rem;
}

.wc-vi {
  display: inline-block;
  margin: 8px 0 0;
  padding: 1px 6px;
  font-weight: 800;
  background: rgba(230, 180, 34, 0.35);
  border-radius: 3px;
}

.wc-ex {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.45);
  border-left: 4px solid var(--yellow-heritage);
  border-radius: 4px;
}

.wc-ex p {
  margin: 0;
  font-size: 0.92rem;
}

.wc-ex-vi {
  color: var(--muted);
}

.wc-meta {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.wc-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.tag-unknown.active {
  color: #fff;
  background: var(--red-vermilion);
}

.tag-known.active {
  color: #fff;
  background: var(--green-indigo);
}

/* ==========================================================================
   5. KHU PHỐ, BƯU THIẾP, MÀN TIÊU ĐỀ, THÔNG BÁO
   ========================================================================== */
.zone-chip {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 52;
  padding: 3px 12px;
  font-size: 0.85rem;
  font-weight: 800;
  border-width: 3px;
  box-shadow: 3px 3px 0 var(--ink-black);
}

.zone-chip:empty {
  display: none;
}

.toasts {
  position: absolute;
  top: 54px;
  left: 12px;
  z-index: 80;
  display: grid;
  gap: 6px;
  max-width: min(420px, 85%);
  pointer-events: none;
}

.toast {
  padding: 6px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  border-width: 3px;
  animation: toast-in 0.25s ease;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.toast.out {
  opacity: 0;
  transform: translateY(-6px);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
}



@keyframes card-in2 {
  from { opacity: 0; transform: scale(0.94) rotate(-1deg); }
}






.title-screen {
  position: absolute;
  inset: 0;
  z-index: 85;
  display: flex;
  overflow-y: auto;
  padding: 16px;
  background: url('../assets/scenes/title.webp') center / cover, var(--do-paper-bg);
}

/* Hoạ tiết Đông Hồ ở góc thẻ tiêu đề: mây cuộn và mặt trời đỏ */
.title-card {
  position: relative;
}

.title-card::before,
.title-card::after {
  content: '';
  position: absolute;
  pointer-events: none;
  background: no-repeat center / contain;
}

.title-card::before {
  top: 6px;
  left: 10px;
  width: 84px;
  height: 46px;
  background-image: url('../assets/deco/cloud.webp');
  opacity: 0.85;
}

.title-card::after {
  top: 12px;
  right: 16px;
  width: 46px;
  height: 46px;
  background-image: url('../assets/deco/red_sun.webp');
  opacity: 0.9;
}

@media (max-width: 720px) {
  .title-card::before {
    width: 70px;
    height: 40px;
    opacity: 0.45;
  }

  .title-card::after {
    width: 30px;
    height: 30px;
    opacity: 0.6;
  }
}

/* margin: auto căn giữa khi đủ chỗ, và vẫn cuộn được từ đầu thẻ khi màn hình thấp */
.title-screen > .title-card {
  margin: auto;
}

.title-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(560px, 100%);
  padding: 22px 26px;
  text-align: center;
  background-color: rgba(245, 230, 200, 0.94);
}

.title-kicker {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--red-vermilion);
}

.title-logo {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2rem, 6vw, 3.2rem);
  font-weight: 900;
  line-height: 1.05;
}

.title-sub,
.title-help {
  margin: 0;
}

.title-help {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Chọn Local Host nam / nữ */
.avatar-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.avatar-pick {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 8px 14px 6px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  border-width: 3px;
  box-shadow: none;
}

.avatar-pick.wearing {
  background-color: #f3dfa6;
  box-shadow: 3px 3px 0 var(--ink-black);
}

/* Chọn ngôn ngữ chỉ dẫn ở màn tiêu đề */
.lang-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
}

.lang-pick {
  padding: 4px 12px;
  font: inherit;
  color: var(--ink-black);
  cursor: pointer;
  background: var(--do-paper-bg, #F5E6C8);
  border: 2px solid var(--ink-black);
  border-radius: 999px;
}

.lang-pick.active {
  color: #FFF8E7;
  background: var(--green-indigo, #1B4D3E);
}

.name-input {
  width: 100%;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px;
  background: #fffaf0;
  border: 3px solid var(--ink-black);
  border-radius: 8px;
}

/* Nút cảm ứng 4 hướng (chữ thập) */
.touch-pad {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 53;
  display: none;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.pad-dirs {
  display: grid;
  grid-template-columns: repeat(3, 42px);
  grid-template-rows: repeat(3, 42px);
  gap: 2px;
  opacity: 0.8;
}

.pad-dirs .up { grid-area: 1 / 2; }
.pad-dirs .left { grid-area: 2 / 1; }
.pad-dirs .right { grid-area: 2 / 3; }
.pad-dirs .down { grid-area: 3 / 2; }

.pad-btn {
  width: 54px;
  height: 54px;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--ink-black);
  background: rgba(245, 230, 200, 0.85);
  border: 3px solid var(--ink-black);
  border-radius: 12px;
  box-shadow: 2px 2px 0 var(--ink-black);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.pad-dirs .pad-btn {
  width: 42px;
  height: 42px;
  font-size: 1rem;
  border-width: 2px;
}

.pad-btn.talk {
  background: rgba(230, 180, 34, 0.92);
}

@media (pointer: coarse), (max-width: 720px) {
  .touch-pad {
    display: flex;
  }
}

/* ==========================================================================
   6. THANH CÔNG CỤ
   ========================================================================== */
.toolbar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  font-size: 1.2rem;
  border-width: 3px;
  box-shadow: 3px 3px 0 #000;
}

.tool span {
  font-size: 0.82rem;
  font-weight: 800;
}

.tool:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.tool[aria-pressed='false'] {
  opacity: 0.55;
}

.tool .badge:not(:empty) {
  position: absolute;
  top: -10px;
  right: -8px;
  min-width: 22px;
  padding: 0 6px;
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 800;
  color: #fff;
  background: var(--red-vermilion);
  border: 2px solid var(--ink-black);
  border-radius: 999px;
}

.controls-hint {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: #d9ccb0;
}

.seal {
  display: inline-block;
  padding: 0 6px;
  font-weight: 900;
  color: var(--yellow-heritage);
  background: var(--red-vermilion);
  border: 2px solid var(--ink-black);
  border-radius: 4px;
}

/* ==========================================================================
   7. BÀI TẬP TRONG KHUNG THOẠI
   ========================================================================== */
.task-hint {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.slots {
  min-height: 52px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.35);
  border: 2px dashed var(--ink-black);
  border-radius: 8px;
}

.slots-empty {
  font-size: 0.86rem;
  color: var(--muted);
}

.bank {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.block {
  min-height: 38px;
  padding: 5px 10px;
  font-weight: 700;
  background: #fffaf0;
  border: 2px solid var(--ink-black);
  border-radius: 6px;
  box-shadow: 2px 2px 0 var(--ink-black);
}

.block.placed {
  background: #f3dfa6;
}

.block.locked {
  color: #fff;
  background: var(--green-indigo);
}

.choices {
  display: grid;
  gap: 8px;
}

.choice {
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  background: #fffaf0;
  border: 2px solid var(--ink-black);
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--ink-black);
}

.choice:hover:not(:disabled) {
  background: #f8ecc4;
}

.choice.right {
  color: #fff;
  background: var(--green-indigo);
}

.choice.wrong {
  background: var(--bad-bg);
  text-decoration: line-through;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 10px;
}

.chip {
  padding: 1px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  background: #fffaf0;
  border: 2px solid var(--ink-black);
  border-radius: 999px;
}

.chip.add::before {
  content: '+ ';
}

.chip.hit {
  color: #fff;
  background: var(--green-indigo);
}

.chip.hit::before {
  content: '✓ ';
}

.answer {
  width: 100%;
  min-height: 64px;
  padding: 8px 10px;
  font: inherit;
  font-size: 16px;
  background: #fffaf0;
  border: 3px solid var(--ink-black);
  border-radius: 8px;
  resize: vertical;
}

.helper {
  margin: 6px 0;
  padding: 6px 10px;
  background: rgba(230, 180, 34, 0.3);
  border: 2px solid var(--ink-black);
  border-radius: 8px;
}

.helper p {
  margin: 0;
}

.mic {
  width: 100%;
  min-height: 52px;
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  background: var(--red-vermilion);
  border: 3px solid var(--ink-black);
  border-radius: 10px;
  box-shadow: 3px 3px 0 var(--ink-black);
}

.mic.listening {
  background: var(--green-indigo);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 3px 3px 0 var(--ink-black), 0 0 0 0 rgba(200, 50, 40, 0.5); }
  50% { box-shadow: 3px 3px 0 var(--ink-black), 0 0 0 10px rgba(200, 50, 40, 0); }
}

/* Trò chuyện tự do với du khách (AI) */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 170px;
  overflow-y: auto;
  margin: 8px 0;
  padding: 10px;
  background: rgba(255, 255, 255, 0.45);
  border: 2px dashed var(--stone-grey);
  border-radius: 8px;
}

.chat-msg {
  max-width: 85%;
  padding: 7px 11px;
  border: 2px solid var(--ink-black);
  border-radius: 10px;
  box-shadow: 2px 2px 0 var(--ink-black);
}

.chat-msg p {
  margin: 0;
  line-height: 1.45;
}

/* Từ vựng tô sáng trong câu trả lời: xuống dòng như chữ thường, căn trái (không căn giữa như nút) */
.chat-msg .term {
  text-align: left;
  vertical-align: baseline;
}

.chat-msg small {
  display: block;
  margin-top: 3px;
  font-size: 0.75rem;
  color: var(--muted);
}

.chat-msg.npc {
  align-self: flex-start;
  background: var(--do-paper-bg);
}

.chat-msg.me {
  align-self: flex-end;
  background: var(--warn-bg);
}

.chat-msg.typing p {
  letter-spacing: 3px;
  animation: chat-blink 1s ease-in-out infinite;
}

@keyframes chat-blink {
  50% { opacity: 0.35; }
}

.chat-note,
.chat-used,
.chat-status {
  font-size: 0.85rem;
}

.chat-used,
.chat-status {
  margin: 4px 0;
}

.mic.small {
  width: auto;
  min-height: 0;
  margin-top: 0;
  padding: 6px 14px;
  font-size: 0.95rem;
}

.transcript {
  min-height: 1.4em;
  margin: 8px 0 2px;
  font-style: italic;
}

.transcript.interim {
  color: var(--muted);
}

.feedback {
  margin-top: 10px;
  padding: 10px 12px;
  border: 2px solid var(--ink-black);
  border-radius: 8px;
}

.feedback:empty {
  display: none;
}

.feedback p {
  margin: 0 0 6px;
}

.feedback.good { background: var(--ok-bg); }
.feedback.bad { background: var(--bad-bg); animation: shake 0.35s; }
.feedback.warn { background: var(--warn-bg); }

/* Độ khớp với câu mẫu khi chấm câu viết / câu nói */
.feedback .match {
  font-weight: 800;
  color: var(--green-indigo);
}

.fb-title {
  font-weight: 800;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.model {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 2px dashed var(--green-indigo);
  border-radius: 8px;
}

.model p {
  margin: 0;
}

.model-label {
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--green-indigo);
}

.model-text {
  font-weight: 600;
}

.reward-list {
  display: grid;
  gap: 6px;
  margin: 6px 0;
  padding: 0;
  list-style: none;
}

.reward-list li {
  padding: 5px 10px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid var(--ink-black);
  border-radius: 6px;
}

/* ==========================================================================
   8. BẢNG (SHEET): NHIỆM VỤ, SỔ TỪ, BOOKLETS, BOSS, HỒ SƠ
   ========================================================================== */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(26, 26, 26, 0.55);
  backdrop-filter: blur(3px) sepia(25%);
  -webkit-backdrop-filter: blur(3px) sepia(25%);
}

.sheet-panel {
  display: flex;
  flex-direction: column;
  width: min(780px, 100%);
  max-height: min(90vh, 920px);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 2px dashed var(--ink-black);
}

.sheet-head h2 {
  margin: 0;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.3rem;
  color: var(--red-vermilion);
}

.sheet-body {
  padding: 14px 16px 18px;
  overflow: auto;
}

.sheet-body h4 {
  margin: 16px 0 8px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.05rem;
}

.quest-list,
.boss-list {
  display: grid;
  gap: 12px;
}

.quest-card,
.boss-card {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-width: 3px;
  box-shadow: 3px 3px 0 var(--ink-black);
}

.quest-card.done {
  background-color: #e6efe0;
}

.quest-card.locked {
  opacity: 0.6;
}

/* Hành trình: 4 đèn lồng trên cổng Đêm hội */
.journey {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0 12px;
  font-weight: 700;
  font-size: 0.9rem;
}

.journey .jl {
  font-size: 1.35rem;
  filter: grayscale(1) opacity(0.4);
}

.journey .jl.lit {
  filter: drop-shadow(0 0 6px rgba(230, 180, 34, 0.9));
}

/* Nhãn mức độ Boss: B1, C1, THPT */
.level-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  vertical-align: middle;
  color: #FFF8E7;
  background: var(--green-indigo);
  border-radius: 999px;
}

.boss-card.advanced .level-tag {
  background: var(--red-vermilion);
}

.quest-card h3,
.boss-card h3 {
  margin: 0;
  font-size: 1rem;
}

.quest-card p,
.boss-card p {
  margin: 3px 0;
  font-size: 0.9rem;
}

.quest-thumb {
  flex-shrink: 0;
  width: 140px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 2px solid var(--ink-black);
  border-radius: 6px;
}

.quest-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.status {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.boss-card.locked {
  filter: grayscale(0.8);
  opacity: 0.75;
}

.boss-thumb {
  flex-shrink: 0;
  width: 88px;
  height: 88px;
  object-fit: contain;
  image-rendering: pixelated;
}

.boss-thumb.defeated {
  filter: grayscale(1) opacity(0.6);
  transform: rotate(-12deg);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.tab {
  padding: 4px 12px;
  font-size: 0.86rem;
  font-weight: 700;
  background: #fffaf0;
  border: 2px solid var(--ink-black);
  border-radius: 999px;
}

.tab.active {
  background: var(--yellow-heritage);
}

.word-list {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.word-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid var(--ink-black);
  border-radius: 8px;
}

.word-row.unknown {
  border-color: var(--red-vermilion);
}

.word-row.known {
  border-color: var(--green-indigo);
}

.word-row p {
  margin: 0;
}

.word-main {
  flex: 1;
  min-width: 0;
}

.word-meta {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
}

.word-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.word-img.big {
  width: 72px;
  height: 72px;
}

.rank {
  width: 26px;
  font-weight: 900;
  color: var(--red-vermilion);
  text-align: center;
}

.quiz-word {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
}

.quiz-word p {
  margin: 0;
}

.booklet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.booklet-card {
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 12px;
  text-align: left;
  border-width: 3px;
  box-shadow: 3px 3px 0 var(--ink-black);
}

.booklet-card.locked {
  opacity: 0.6;
  box-shadow: none;
}

.bk-icon {
  font-size: 1.6rem;
}

.booklet-card small {
  color: var(--muted);
}

.bk-title {
  margin: 0 0 6px;
  font-family: 'Playfair Display', Georgia, serif;
}

.bk-rule {
  padding: 8px 12px;
  background: rgba(27, 77, 62, 0.1);
  border-left: 4px solid var(--green-indigo);
  border-radius: 4px;
}

.bk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.bk-table td {
  padding: 6px 8px;
  border: 1.5px solid var(--ink-black);
}

.bk-table td:first-child {
  font-weight: 800;
  color: var(--red-vermilion);
}

.bk-examples {
  display: grid;
  gap: 6px;
  padding: 0;
  list-style: none;
}

.bk-examples li {
  display: flex;
  gap: 8px;
}

.bk-examples p {
  margin: 0;
}

.bk-check {
  margin-bottom: 12px;
}

.bk-check > p {
  margin: 0 0 6px;
}

/* Đấu Boss */
.arena {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: url('../assets/scenes/festival.webp') center / cover, #1E2A47;
  border: 4px solid var(--ink-black);
  border-radius: 10px;
}

.boss-img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  animation: float 2.4s ease-in-out infinite;
}

.boss-img.hit {
  animation: boss-hit 0.45s ease;
}

.boss-img.attack {
  animation: boss-attack 0.45s ease;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes boss-hit {
  0% { filter: brightness(3); transform: translateX(0); }
  30% { transform: translateX(-8px); }
  60% { transform: translateX(6px); }
  100% { filter: none; transform: translateX(0); }
}

@keyframes boss-attack {
  0% { transform: scale(1); }
  40% { transform: scale(1.25) translateX(12px); }
  100% { transform: scale(1); }
}

.arena-info {
  flex: 1;
  padding: 8px 12px;
  background: rgba(245, 230, 200, 0.9);
  border: 3px solid var(--ink-black);
  border-radius: 8px;
}

.boss-name {
  margin: 0 0 6px;
  font-weight: 900;
  color: var(--red-vermilion);
}

.hp-bar {
  height: 14px;
  overflow: hidden;
  background: #e8d5b0;
  border: 2px solid var(--ink-black);
  border-radius: 999px;
}

.hp-bar span {
  display: block;
  height: 100%;
  background: var(--red-vermilion);
  transition: width 0.4s ease;
}

.hearts {
  margin: 6px 0 0;
  font-size: 1.05rem;
}

.combo {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--red-vermilion);
}

.q-tag {
  margin: 12px 0 2px;
  font-size: 0.78rem;
  color: var(--muted);
}

.boss-q {
  margin: 0 0 10px;
  font-size: 1.02rem;
  font-weight: 600;
  white-space: pre-line;
}

.finish {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Hồ sơ */
.profile-head {
  display: flex;
  align-items: center;
  gap: 18px;
}

.profile-head p {
  margin: 2px 0;
}

.profile-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.4rem;
  font-weight: 900;
}

.host-canvas {
  flex-shrink: 0;
}

.wardrobe {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.outfit {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-width: 3px;
  box-shadow: none;
}

.outfit.wearing {
  background-color: #f3dfa6;
  box-shadow: 3px 3px 0 var(--ink-black);
}

.outfit.locked {
  filter: grayscale(1);
  opacity: 0.55;
}

.outfit small {
  color: var(--muted);
  text-align: center;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.stat {
  display: grid;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.45);
  border: 2px solid var(--ink-black);
  border-radius: 8px;
}

.stat b {
  font-size: 1.15rem;
  color: var(--red-vermilion);
}

.stat span {
  font-size: 0.8rem;
  color: var(--muted);
}

.traits,
.tips {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.traits li,
.tips li {
  padding: 8px 10px;
  border: 2px solid var(--ink-black);
  border-radius: 8px;
}

.traits li {
  background: var(--ok-bg);
}

.tips li {
  background: var(--warn-bg);
}

/* Giấy chứng nhận */
.certificate {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 22px 18px;
  text-align: center;
  outline: 3px double var(--red-vermilion);
  outline-offset: -12px;
}

.certificate p {
  margin: 0;
}

.cert-icon {
  width: 84px;
}

.cert-kicker {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--green-indigo);
}

.cert-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2rem;
  font-weight: 900;
  color: var(--red-vermilion);
}

.cert-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 900;
}

.cert-award {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--green-indigo);
}

.name-label {
  display: grid;
  gap: 4px;
  margin-top: 12px;
  font-weight: 700;
}

/* ==========================================================================
   9. ĐIỆN THOẠI
   ========================================================================== */
@media (max-width: 720px) {
  .topbar {
    padding: 6px 8px;
  }

  .trada-title,
  .hud-item small {
    display: none;
  }

  .title-screen {
    padding: 8px;
  }

  .title-card {
    gap: 6px;
    padding: 14px;
  }

  .title-sub,
  .title-help {
    font-size: 0.78rem;
  }

  .parallax-viewport {
    border-width: 4px;
  }

  .dialogue-box {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    max-height: none;
    gap: 10px;
    padding: 12px;
    border-width: 0;
    border-top: 4px solid var(--ink-black);
    border-radius: 0 0 6px 6px;
    box-shadow: none;
    outline: none;
  }

  .npc-portrait {
    width: 56px;
    height: 56px;
  }

  .npc-header {
    padding-right: 34px;
  }

  .npc-header .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
  }

  .npc-role {
    font-size: 0.76rem;
  }

  .dialogue-text {
    font-size: 1rem;
  }

  .vocab-card {
    position: fixed;
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 70vh;
    transform: none;
    z-index: 95;
    animation: none;
  }

  .toolbar {
    grid-template-columns: repeat(3, 1fr);
  }

  .sheet {
    padding: 0;
    place-items: end stretch;
  }

  .sheet-panel {
    width: 100%;
    max-height: 92vh;
    border-radius: 10px 10px 0 0;
  }

  .quest-thumb {
    width: 90px;
  }

  .arena {
    gap: 10px;
  }

  .boss-img {
    width: 76px;
    height: 76px;
  }

  .profile-head {
    align-items: flex-start;
  }
}

/* Báo cáo học tập (Hồ sơ → Xuất báo cáo) */
.report-wrap {
  padding: 14px 16px;
  margin-top: 10px;
  background: #fffaf0;
  box-shadow: none;
  overflow-x: auto;
}

.report h2 {
  margin: 0.2em 0;
  font-size: 1.3rem;
}

.report h3 {
  margin: 1.1em 0 0.4em;
  font-size: 1rem;
  border-bottom: 2px solid var(--ink-black);
}

.report .kicker {
  margin: 0;
  color: var(--red-vermilion, #C83228);
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.report .meta {
  margin: 0.2em 0;
}

.report table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.report th,
.report td {
  border: 1px solid #999;
  padding: 4px 6px;
  text-align: left;
  vertical-align: top;
}

.report th {
  background: var(--do-paper-bg);
}

@media print {
  body * {
    visibility: hidden;
  }

  .certificate,
  .certificate *,
  .report,
  .report * {
    visibility: visible;
  }

  .certificate,
  .report {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  /* Bỏ khung cuộn của bảng để in đủ cả báo cáo dài nhiều trang */
  .sheet,
  .sheet-panel,
  .sheet-body,
  .report-wrap {
    position: static;
    display: block;
    max-height: none;
    overflow: visible;
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
