/* game-theme.css: Đồng bộ giao diện chơi game (Chương 1 - 6) theo ngôn ngữ thị giác Quạ Đen
   (nền đen tuyền #000, thanh trên đỏ thẫm gọn, điểm nhấn đỏ #e04338, font Be Vietnam Pro chuẩn dấu tiếng Việt,
   vừa gọn 1 màn hình PC không cần cuộn dọc). */
:root {
  --bg: #000000 !important;
  --panel: #0e0e10 !important;
  --ink: #ffffff !important;
  --ink-soft: #9a9da6 !important;
  --line: rgba(255, 255, 255, .12) !important;
  --accent: #e04338 !important;
  --accent-2: #ff6257 !important;
  --slot: #141418 !important;
  --slot-line: rgba(255, 255, 255, .16) !important;
  --bar: #0e0e10 !important;
  --shadow: 0 18px 42px rgba(0, 0, 0, .75) !important;
  --font-display: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif !important;
  --font-apple: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif !important;
}

/* Ép dùng Be Vietnam Pro toàn bộ vùng chữ ở cả 6 chương để KHÔNG BAO GIỜ bị tách dấu tiếng Việt (ố, ế, ầ...) */
body,
.dialogue, .dialogue .who, #dialogueText,
.objective, .objective b, #objectiveText,
.caption,
.inv-wrap, .inv-empty, .slot, .slot .nm,
.vn-box, .vn-card, .vn-body, .vn-meta h3, .vn-text, .vn-speaker, .vn-role, .vn-sub, #chatText, #chatName, #chatRole,
.card h2, .radio-line, .stepper .val, .safe-display, .end-stats .st b,
.modal, .modal *, .close-card, .close-card *, .dpad-bar {
  font-family: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif !important;
}

body {
  background: #000000 !important;
  color: #ffffff !important;
  padding: 0 12px 10px !important;
}

.wrap {
  max-width: 1280px !important;
  gap: 8px !important;
}

/* ---------- Topbar đỏ thẫm siêu gọn (1 dòng trên PC, tối đa diện tích cho phòng game) ---------- */
.topbar {
  background: linear-gradient(90deg, #640e0e 0%, #741212 52%, #480909 100%) !important;
  border: 1px solid rgba(255, 255, 255, .14);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 7px 12px !important;
  gap: 5px !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .65);
}
.topbar .room-name {
  font-family: "Be Vietnam Pro", sans-serif !important;
  font-size: clamp(.9rem, 1.5vw, 1.05rem) !important;
  font-weight: 900 !important;
  text-transform: uppercase;
  letter-spacing: .02em !important;
  color: #ffffff !important;
  gap: 6px !important;
}
.room-name .chap {
  font-family: "JetBrains Mono", monospace !important;
  font-size: .66rem !important;
  color: rgba(255, 255, 255, .74) !important;
  font-weight: 700 !important;
}
.tbtn,
.topup-pill {
  background: rgba(0, 0, 0, .28) !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, .32) !important;
  border-radius: 6px !important;
  padding: 3px 9px !important;
  min-height: 29px !important;
  font-family: "Be Vietnam Pro", sans-serif !important;
  font-weight: 700 !important;
  font-size: .71rem !important;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.tbtn:hover,
.topup-pill:hover {
  background: rgba(255, 255, 255, .16) !important;
  border-color: #ffffff !important;
  color: #ffffff !important;
}
.clock-pill,
.live-timer,
#liveTimer {
  font-family: "JetBrains Mono", monospace !important;
  font-size: .71rem !important;
  padding: 3px 8px !important;
  min-height: 29px !important;
  border-radius: 6px !important;
  background: rgba(0, 0, 0, .4) !important;
  border: 1px solid rgba(255, 255, 255, .28) !important;
  color: #ffffff !important;
  display: inline-flex !important;
  align-items: center !important;
}
/* Ghi rõ nhãn GIỜ TRUYỆN để không nhầm với đồng hồ tốc độ chơi 00:00 */
#gameClock::before {
  content: "GIỜ TRUYỆN · ";
  color: rgba(255, 255, 255, .62);
  font-weight: 600;
  margin-right: 2px;
}
.topbar .save-status,
#saveStatus {
  font-size: .7rem !important;
  color: rgba(255, 255, 255, .75) !important;
}

/* ---------- Bố cục 2 cột vừa khít 1 màn hình PC (không phải cuộn xuống) ---------- */
.game-layout {
  grid-template-columns: minmax(0, 1fr) 310px !important;
  gap: 12px !important;
  align-items: start !important;
}
.scene-shell {
  border-radius: 8px !important;
  border: 1px solid rgba(255, 255, 255, .16) !important;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .85) !important;
  max-width: min(100%, calc((100dvh - 108px) * 4 / 3)) !important;
}

/* Trên PC đã có bàn phím WASD/Mũi tên + hộp Điều khiển nhanh -> ẩn thanh D-pad cảm ứng để khỏi bị dư chiều cao */
@media (min-width: 921px) {
  .dpad-bar { display: none !important; }
  .footer, footer { display: none !important; }
}

.nav-arrow {
  background: rgba(10, 10, 12, .88) !important;
  border: 1px solid rgba(224, 67, 56, .65) !important;
  color: #ffffff !important;
}
.nav-arrow:hover {
  background: #e04338 !important;
  border-color: #ff6257 !important;
  color: #ffffff !important;
}

/* ---------- Cột phải: Thoại + Mục tiêu + Túi đồ (phím 1-9) + Điều khiển nhanh ---------- */
.dialogue,
.objective,
.inv-wrap,
.caption,
.inventory,
.side-card,
.inv-panel {
  background: #0e0e10 !important;
  border: 1px solid rgba(255, 255, 255, .12) !important;
  border-radius: 8px !important;
  color: #f0f2f7 !important;
}
.dialogue {
  border-left: 3px solid #e04338 !important;
  padding: 10px 14px !important;
  font-size: .88rem !important;
  line-height: 1.52 !important;
  font-style: normal !important;
  height: 102px !important;
  min-height: 102px !important;
  max-height: 102px !important;
  overflow-y: auto !important;
  display: block !important;
  scrollbar-width: thin;
}
.dialogue .who {
  color: #e04338 !important;
  font-weight: 800 !important;
  font-style: normal !important;
}
.objective {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: center !important;
  gap: 3px !important;
  padding: 10px 14px !important;
  min-height: 68px !important;
  border-left: 3px solid rgba(224, 67, 56, .65) !important;
  font-size: .7rem !important;
  font-weight: 700 !important;
  letter-spacing: .08em !important;
  text-transform: uppercase;
  color: #e04338 !important;
}
.objective b,
#objectiveText {
  font-size: .85rem !important;
  line-height: 1.48 !important;
  color: #f4f6fa !important;
  font-weight: 600 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.inv-wrap {
  padding: 10px 12px !important;
}
.inv-label,
.inv-title,
.inventory-title,
.inv-head,
.panel-title {
  font-family: "JetBrains Mono", monospace !important;
  font-size: .72rem !important;
  font-weight: 700 !important;
  letter-spacing: .14em !important;
  text-transform: uppercase;
  color: #e04338 !important;
  margin-bottom: 8px !important;
}

#inventory {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
}
#inventory .inv-empty {
  grid-column: 1 / -1 !important;
  font-size: .81rem !important;
  color: #8f94a0 !important;
  line-height: 1.5 !important;
  padding: 4px 2px !important;
}
.slot {
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  background: #141418 !important;
  border: 1px solid rgba(255, 255, 255, .14) !important;
  border-radius: 7px !important;
  color: #eef0f5 !important;
  padding: 12px 8px 9px !important;
  min-height: 78px !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  transition: border-color .16s ease, background .16s ease, transform .14s ease;
}
.slot svg {
  width: 30px !important;
  height: 30px !important;
  flex-shrink: 0 !important;
}
.slot .nm {
  font-size: .74rem !important;
  font-weight: 700 !important;
  text-align: center;
  line-height: 1.25;
}
.slot-key {
  position: absolute;
  top: 5px;
  left: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #d6d9e2;
  font-family: "JetBrains Mono", monospace !important;
  font-size: .66rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.slot.selected .slot-key {
  background: #e04338;
  border-color: #ff6257;
  color: #ffffff;
}
.slot.selected,
.slot.active,
.slot:hover {
  border-color: #e04338 !important;
  box-shadow: 0 0 0 1px rgba(224, 67, 56, .45) !important;
  background: rgba(224, 67, 56, .14) !important;
}

/* Hộp phím tắt gọn ở cột phải */
.kbd-legend {
  background: #0b0b0d;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  padding: 10px 12px;
}
.kbd-legend-title {
  font-family: "JetBrains Mono", monospace !important;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  color: #8f94a0;
  margin-bottom: 7px;
}
.kbd-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: .76rem;
  color: #b7bac4;
}
.kbd-grid kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: #18181d;
  border: 1px solid rgba(255, 255, 255, .18);
  color: #ffffff;
  font-family: "JetBrains Mono", monospace !important;
  font-size: .68rem;
  font-weight: 700;
}

/* ---------- Modal câu đố & Visual Novel ---------- */
.modal-backdrop,
.overlay {
  background: rgba(0, 0, 0, .82) !important;
  backdrop-filter: blur(5px);
}
.modal,
.dialog,
.modal-card,
.close-card {
  background: #0e0e10 !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, .16) !important;
  border-top: 3px solid #e04338 !important;
  border-radius: 10px !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .9) !important;
}
.modal h2,
.modal h3,
.close-card h2,
.modal-title {
  font-weight: 900 !important;
  color: #ffffff !important;
  padding-right: 44px;
}
.modal p,
.close-card p,
.modal-sub {
  color: #b4b7c0 !important;
  padding-right: 12px;
}
.modal .close,
.modal-close,
.close-btn,
.close-x {
  background: #16161a !important;
  border: 1px solid rgba(255, 255, 255, .2) !important;
  color: #ffffff !important;
  border-radius: 6px !important;
}
.modal .close:hover,
.modal-close:hover,
.close-btn:hover,
.close-x:hover {
  border-color: #e04338 !important;
  color: #ff6257 !important;
}

/* Bố cục 2 cột gọn cho modal câu đố 2 bước (vừa khít 1 màn hình PC, không bị cắt nút) */
.close-card:has(.puzzle-split) {
  max-width: 680px !important;
  width: min(680px, 94vw) !important;
}
.puzzle-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 10px 0 6px;
  align-items: stretch;
}
.puzzle-pane {
  background: #141418;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.puzzle-step-tag {
  font-family: "JetBrains Mono", monospace !important;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #e04338;
}
.puzzle-pane .clockface {
  width: 176px !important;
  height: 176px !important;
  margin: 0 auto !important;
}
.puzzle-pane .jug-face {
  width: 152px !important;
  height: 176px !important;
  margin: 0 auto !important;
}
.puzzle-pane .steppers {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  margin: 0 !important;
}
.puzzle-pane .sub {
  margin: 0 !important;
  font-size: .78rem !important;
  line-height: 1.4 !important;
  padding: 0 !important;
  text-align: center;
}
@media (max-width: 640px) {
  .puzzle-split { grid-template-columns: 1fr; }
}

.btn,
.pbtn,
.choice-btn,
.modal button.primary {
  background: #e04338 !important;
  color: #ffffff !important;
  border: 1px solid #ff6257 !important;
  border-radius: 6px !important;
  font-weight: 800 !important;
}
.btn:hover,
.pbtn:hover,
.choice-btn:hover {
  background: #c93329 !important;
}
.btn-ghost,
.ghost,
.mbtn {
  background: #16161a !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, .18) !important;
  border-radius: 6px !important;
  font-weight: 700 !important;
}
.btn-ghost:hover,
.ghost:hover,
.mbtn:hover {
  border-color: #e04338 !important;
  background: rgba(224, 67, 56, .14) !important;
}

.vn-box,
.vn-card {
  background: rgba(10, 10, 12, .96) !important;
  border: 1px solid rgba(224, 67, 56, .55) !important;
  border-radius: 10px !important;
}
.vn-text,
#chatText {
  font-size: .94rem !important;
  line-height: 1.62 !important;
  color: #f4f6fa !important;
  font-style: normal !important;
}
.vn-speaker,
#chatName {
  color: #e04338 !important;
  font-weight: 900 !important;
  text-transform: uppercase;
  letter-spacing: .06em;
}


/* =====================================================================
   TỐI ƯU MOBILE & TABLET (<= 920px & <= 600px) CHO CẢ 6 CHƯƠNG
   - Khắc phục triệt để lỗi bị ép 2 cột trên điện thoại (.game-layout 1 cột).
   - Thanh topbar gọn gàng, cuộn ngang mượt 1 dòng cho các nút phụ.
   - Ẩn bảng phím tắt PC (.kbd-legend) & số phím (.slot-key) trên màn hình cảm ứng.
   - Thanh D-pad cảm ứng nút to >= 44px chuẩn ngón cái, modal cuộn mượt vừa màn hình.
   ===================================================================== */
@media (max-width: 920px) {
  body {
    padding: 0 8px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
  }
  .wrap {
    gap: 8px !important;
  }
  .game-layout {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .game-side {
    position: static !important;
    gap: 8px !important;
  }
  .scene-shell {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: 8px !important;
  }

  /* Thanh topbar mobile gọn: dòng 1 tên phòng, các nút còn lại vuốt ngang mượt */
  .topbar {
    padding: 8px 10px !important;
    gap: 6px !important;
    border-radius: 0 0 8px 8px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .topbar .room-name {
    flex: 0 0 auto !important;
    margin-right: 6px !important;
    font-size: .88rem !important;
    white-space: nowrap !important;
  }
  .topbar .room-name .chap { display: none !important; }
  .topbar .tbtn,
  .topbar .topup-pill,
  .topbar .clock-pill,
  .topbar .live-timer {
    flex: 0 0 auto !important;
    min-height: 34px !important;
    padding: 5px 10px !important;
    font-size: .72rem !important;
  }

  /* Ẩn bảng phím tắt PC & số phím 1-9 trên mobile cảm ứng */
  .kbd-legend,
  .slot-key {
    display: none !important;
  }

  /* Thanh D-pad cảm ứng chuẩn ngón cái (>= 44px) */
  .dpad-bar {
    display: flex !important;
    padding: 8px 10px !important;
    gap: 8px !important;
    background: #0e0e10 !important;
    border: 1px solid rgba(255, 255, 255, .14) !important;
    border-radius: 10px !important;
  }
  .dpad-bar .dpad-group {
    gap: 6px !important;
  }
  .dpad-bar .pad-btn {
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 12px !important;
    font-size: .88rem !important;
    border-radius: 8px !important;
  }
  .dpad-bar span { display: none !important; }

  /* Túi đồ mobile: xếp 3 cột gọn, dễ bấm bằng ngón tay */
  #inventory {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 7px !important;
  }
  .slot {
    min-height: 66px !important;
    padding: 8px 6px !important;
  }
  .slot svg { width: 28px !important; height: 28px !important; }

  /* Mũi tên chuyển phòng to hơn dễ chạm */
  .nav-arrow {
    width: 42px !important;
    height: 42px !important;
    font-size: 1.1rem !important;
  }
}

@media (max-width: 600px) {
  #gameClock::before { content: "" !important; margin: 0 !important; }
  .dialogue {
    padding: 10px 12px !important;
    font-size: .86rem !important;
  }
  .objective {
    padding: 8px 12px !important;
  }
  .objective b, #objectiveText {
    font-size: .82rem !important;
  }
  /* Modal vừa gọn màn hình điện thoại, không bị tràn mép */
  .modal,
  .dialog,
  .modal-card,
  .close-card,
  .close-card:has(.puzzle-split) {
    width: calc(100vw - 18px) !important;
    max-width: calc(100vw - 18px) !important;
    max-height: 88dvh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px !important;
  }
  .modal h2,
  .close-card h2 {
    font-size: 1.08rem !important;
    padding-right: 38px !important;
  }
  .puzzle-pane {
    padding: 10px !important;
  }
  .puzzle-pane .clockface {
    width: 152px !important;
    height: 152px !important;
  }
  .puzzle-pane .jug-face {
    width: 136px !important;
    height: 152px !important;
  }
  .btn, .pbtn, .choice-btn, .btn-ghost, .mbtn {
    min-height: 42px !important;
    font-size: .82rem !important;
  }
  /* Khung hội thoại Visual Novel gọn gàng trên điện thoại */
  .vn-box, .vn-card {
    padding: 10px 12px !important;
    gap: 10px !important;
  }
  .vn-avatar, .vn-portrait {
    width: 52px !important;
    height: 52px !important;
  }
  .vn-text, #chatText {
    font-size: .84rem !important;
    line-height: 1.5 !important;
  }
  .dpad-bar {
    justify-content: space-between !important;
  }
  .dpad-bar .pad-btn {
    min-width: 40px !important;
    height: 42px !important;
    padding: 0 9px !important;
    font-size: .78rem !important;
  }
}


/* ---------- Khung Dẫn chuyện mở đầu 3 thẻ slide (.brief-wrap) ---------- */
.brief-wrap {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brief-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brief-stamp {
  font-family: "JetBrains Mono", monospace !important;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: #e04338;
  text-transform: uppercase;
}
.brief-skip {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 6px;
  color: #9a9da6;
  padding: 4px 10px;
  min-height: 28px !important;
  font-size: .74rem;
  font-weight: 700;
}
.brief-skip:hover { border-color: #e04338; color: #ffffff; }
.brief-place {
  font-size: .8rem;
  color: #9a9da6;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.brief-kicker {
  font-family: "JetBrains Mono", monospace !important;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
  color: #ff7e75;
  margin-top: 2px;
}
.brief-title {
  font-size: clamp(1.12rem, 2.4vw, 1.38rem) !important;
  font-weight: 900 !important;
  color: #ffffff !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.25 !important;
}
.brief-body {
  font-size: .94rem !important;
  line-height: 1.68 !important;
  color: #d4d7e0 !important;
  margin: 2px 0 6px !important;
  padding: 0 !important;
}
.brief-guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0;
}
.bg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: #141418;
  border: 1px solid rgba(255, 255, 255, .1);
  border-left: 3px solid #e04338;
  border-radius: 7px;
  padding: 9px 11px;
  font-size: .84rem;
  line-height: 1.5;
  color: #d4d7e0;
}
.bg-row b { color: #ffffff; }
.bg-row code {
  background: #060608;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "JetBrains Mono", monospace !important;
  font-size: .74rem;
  color: #ff8078;
}
.bg-ic { font-size: 1.05rem; line-height: 1.3; flex-shrink: 0; }
.brief-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, .1);
  flex-wrap: wrap;
}
.brief-dots { display: flex; gap: 6px; align-items: center; }
.brief-dot {
  width: 8px; height: 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .22);
  transition: width .2s ease, background .2s ease;
}
.brief-dot.on { width: 22px; background: #e04338; }
.brief-btns { display: flex; gap: 8px; align-items: center; margin-left: auto; }


/* ---------- Quản lý 3 Ô lưu + Tự động lưu (.save-slots) ---------- */
.save-slots { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.save-slot-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #141418; border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px; padding: 10px 12px; flex-wrap: wrap;
}
.save-slot-row.auto { border-left: 3px solid #e04338; }
.save-slot-info { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.save-slot-info b { font-family: "JetBrains Mono", monospace !important; font-size: .78rem; color: #ffffff; letter-spacing: .06em; }
.save-slot-info span { font-size: .78rem; color: #9a9da6; }
.save-slot-btns { display: flex; gap: 6px; align-items: center; }
.save-cloud-bar {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .1);
}
