/* =====================================================================
   Bản Nghiệp Báo (khó): thanh nghiệp, chỉ tiêu, vật ném, khiên hồ sơ, cơn giận cuối.
   Nạp sau cùng nên ghi đè các file trước.
   ===================================================================== */
:root { --karma: #6a2fa0; --karma-hot: #d0306a; }

/* trang đầu */
.hard-badge { display: inline-block; margin: 2px 0 4px; padding: 3px 12px; border-radius: 6px; background: #2a0f0b; color: #ffd23a;
  border: 2px solid var(--cream); font: 800 16px/1.2 var(--cond); letter-spacing: 1.5px; transform: rotate(1.5deg); box-shadow: 0 3px 0 rgba(0, 0, 0, .25); }
.rules { width: min(100%, 360px); margin: 8px auto 0; padding: 8px 12px; font-size: 14px; line-height: 1.35; text-align: left; }
.rules summary { cursor: pointer; font: 800 16px var(--cond); color: var(--plaque); text-align: center; }
.rules p { display: flex; gap: 8px; margin: 6px 0 0; }
.rules p span { flex: 0 0 auto; }

/* HUD */
.karma { position: relative; width: 46%; height: 12px; margin-top: 2px; border-radius: 99px; background: rgba(0, 0, 0, .4); overflow: hidden; border: 1.5px solid rgba(251, 239, 207, .7); }
.karma i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--karma), #a052d6); transition: width .15s linear; }
.karma span { position: absolute; inset: 0; font: 800 9px/10px var(--cond); letter-spacing: 1.5px; color: #fbefcf; text-align: center; text-shadow: 0 1px 1px #000; }
.karma.warn i { background: linear-gradient(90deg, var(--karma-hot), #ff6a3a); animation: kpulse .5s ease-in-out infinite alternate; }
.karma.bump { animation: kbump .25s ease-out; }
@keyframes kpulse { to { filter: brightness(1.35); } }
@keyframes kbump { 40% { transform: scale(1.12, 1.4); } }
.quota { font: 800 13px/1 var(--cond); color: #fbefcf; background: rgba(42, 15, 11, .7); padding: 3px 8px; border-radius: 6px; margin-top: 2px; }
.quota.ok { background: #2f8f83; color: #fff; }
.quota-chip { background: #2a0f0b; color: #ffd23a; border-color: #2a0f0b; }

/* vật ném */
.proj { position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none; padding: 7px 11px; border-radius: 10px;
  background: #fbf6ea; color: #7a1d12; border: 3px solid #c8261f; font: 800 19px/1 var(--cond); white-space: nowrap;
  box-shadow: 3px 4px 0 rgba(42, 15, 11, .35); will-change: transform; }
.proj::after { content: ''; position: absolute; inset: -14px; border-radius: 50%; border: 2px dashed rgba(200, 38, 31, .55); }
.proj.gone { transition: opacity .2s; opacity: 0; }

/* khiên hồ sơ (Phát): bản thường không có ảnh khiên nên né "vô hình" */
.h-shield { position: absolute; left: 50%; top: 30%; width: 52%; height: 34%; z-index: 3; pointer-events: none;
  transform: translateX(-50%) rotate(-8deg) scale(0); transition: transform .1s; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(#efe0b0, #d9c486); border: 3px solid #8a6a28; border-radius: 6px; box-shadow: 0 6px 8px rgba(0, 0, 0, .3);
  font: 800 18px var(--cond); color: #6b4f12; letter-spacing: 1px; }
.h-shield::before { content: ''; position: absolute; top: -10px; left: -3px; width: 40%; height: 12px; background: #d4bd7a; border: 3px solid #8a6a28; border-bottom: 0; border-radius: 5px 5px 0 0; }
.rdoll.shielding + .h-shield { transform: translateX(-50%) rotate(-8deg) scale(1); }

/* sân */
.stage.rage::after { content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 5;
  box-shadow: inset 0 0 60px 12px rgba(200, 38, 31, .55); animation: rage .6s ease-in-out infinite alternate; }
@keyframes rage { to { box-shadow: inset 0 0 90px 22px rgba(255, 80, 30, .7); } }
.stage.struck::before { content: ''; position: absolute; inset: 0; z-index: 9; pointer-events: none; background: rgba(200, 38, 31, .35); animation: flash .35s ease-out forwards; }
@keyframes flash { to { opacity: 0; } }
.stage.karma-burst { filter: grayscale(.6) contrast(1.2) brightness(.7); transition: filter .5s; }
.stage.karma-burst .banner { background: linear-gradient(90deg, transparent, rgba(106, 47, 160, .95) 18%, rgba(106, 47, 160, .95) 82%, transparent); }

/* kết quả thua */
.result.fail h2 { color: #6a2fa0; }
.big-score .need { font-size: .45em; opacity: .6; }

@media (prefers-reduced-motion: reduce) { .karma.warn i, .stage.rage::after { animation: none; } }

/* sửa tên hình nhân */
.name-edit { margin-left: 4px; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--plaque); background: var(--cream); color: var(--plaque);
  font-size: 17px; line-height: 1; vertical-align: middle; cursor: pointer; }
.rename { display: flex; flex-direction: column; gap: 8px; width: min(100%, 340px); margin: 4px auto 8px; }
.rename[hidden] { display: none; }
.rename .name-in { width: 100%; font-size: 22px; }
.rename .muted { margin: 0; font-size: 13px; }
.ntag b { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* phần mở đầu */
.intro { cursor: pointer; user-select: none; -webkit-user-select: none; }
.in-art { position: relative; flex: none; height: 38vh; min-height: 230px; margin: -12px -16px 6px; overflow: hidden;
  background: #f6d98a; border-bottom: 4px solid var(--navy); display: flex; align-items: flex-end; justify-content: center; animation: inart .6s ease-out; }
@keyframes inart { from { opacity: 0; transform: scale(1.04); } }
.in-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.in-sign { position: absolute; left: 6%; top: 14%; width: 26%; transform: rotate(-4deg); filter: drop-shadow(0 4px 3px rgba(0, 0, 0, .3)); }
.in-dolls { display: flex; align-items: flex-end; justify-content: center; width: 100%; height: 78%; padding: 0 6px; }
.in-dolls .rdoll { position: relative; flex: 1; height: 100%; min-width: 0; }
.in-dolls .rdoll-img { display: block; margin: 0 auto; max-width: 100%; object-fit: contain; object-position: bottom; }
.in-altar { width: 86%; max-height: 92%; object-fit: contain; filter: drop-shadow(0 8px 6px rgba(90, 30, 0, .3)); }
.in-slip { height: 88%; transform: rotate(-12deg); animation: inslap 1.4s ease-in-out infinite; transform-origin: 80% 90%; }
@keyframes inslap { 50% { transform: rotate(6deg); } }
.intro.dark .in-art { border-color: #3a2420; }
.intro.dark .in-bg { filter: brightness(.4) saturate(.5); }
.intro .lines { flex: 1; }
.intro .lines b { color: var(--red); }
.intro.dark .lines b { color: var(--mustard); }
.in-accuse { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; font-size: 16px; line-height: 1.35; }
.in-accuse li { background: #fffaf0; border-left: 5px solid var(--red); border-radius: 8px; padding: 5px 10px; }
.in-accuse li b { margin-right: 4px; }
.in-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.in-foot .tap-more { margin: 0; }
.in-dots { display: flex; gap: 6px; }
.in-dots i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: .25; }
.in-dots i.on { opacity: .9; }
@media (prefers-reduced-motion: reduce) { .in-art, .in-slip { animation: none; } }
.in-night-slip { position: relative; height: 62%; margin-bottom: 8%; transform: rotate(-18deg); filter: drop-shadow(0 0 18px rgba(255, 210, 120, .35)) drop-shadow(0 8px 6px rgba(0, 0, 0, .6)); }

/* bà thầy (người dẫn chuyện) và lời đã nghe */
.thay { position: relative; margin: 10px 0 4px; padding: 10px 12px 10px 14px; border-radius: 12px; background: #2a0f0b; color: #fbefcf;
  font-size: 16px; line-height: 1.45; box-shadow: 0 3px 0 rgba(0, 0, 0, .2); }
.thay p { margin: 0; font-style: italic; }
.thay-name { display: inline-block; margin-bottom: 3px; font: 800 13px/1 var(--cond); letter-spacing: 1px; color: var(--mustard); text-transform: uppercase; }
.heard-box { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: #fffaf0; border: 2px dashed #b5654a; }
.heard-box .kind { display: block; font: 800 12px var(--cond); text-transform: uppercase; color: #b5654a; letter-spacing: .5px; }
.heard-box p { margin: 4px 0 0; font-size: 16px; line-height: 1.4; }

/* ---------- màn thấp (iPhone SE/8/mini, Safari có thanh địa chỉ) ----------
   Mâm cúng và 5 hình nhân ở trang đầu từng tính cỡ theo bề ngang nên tràn lên logo và che nút "Vào hẻm".
   Giờ cả hai co theo chiều cao khung giữa. */
.hero-v2 { position: relative; overflow: visible; }
.hero-altar { height: 92%; width: auto; max-width: 92%; object-fit: contain; bottom: 8%; }
.hero-dolls { grid-template-rows: 100%; }
.hero-dolls .rdoll { height: 100%; min-height: 0; }
.hero-dolls .rdoll-img { max-height: 100%; }
.title-screen > .img-btn { position: relative; z-index: 2; }
@media (max-height: 760px) {
  .title-screen { gap: 4px; }
  .logo-img { width: min(56%, 230px); }
  .logo-sm { font-size: 13px; }
  .hard-badge { font-size: 14px; padding: 2px 10px; margin: 0 0 2px; }
  .tag { font-size: 15px; }
  .title-screen .img-btn { max-width: 280px; }
  .rules { margin-top: 2px; }
  .title-screen .note { font-size: 12px; }
}
/* cảnh 01: câu người chơi chọn nằm trong lưới 2 cột của lựa chọn -> cho trải hết hàng */
.npc-choices .npc-you { grid-column: 1 / -1; }
@media (max-height: 760px) {
  .npc-stage { height: 26vh; min-height: 160px; }
  .npc-box p { font-size: 16px; }
  .story .lines p, .story .line { font-size: 17px; margin: 4px 0; }
}
/* thẻ hình nhân dài hơn màn: nút chơi luôn thấy ở đáy */
.sheet [data-act=play] { position: sticky; bottom: 0; z-index: 3; flex: none; }
/* mâm cúng: hình nhân 80% + khay lễ vật vượt chiều cao khung, tràn lên đè tiêu đề -> hình nhân chỉ lấy phần còn lại */
.tray-doll { height: auto; flex: 1 1 0; min-height: 0; display: flex; justify-content: center; }
.tray-doll .rdoll { height: 100%; }
@media (max-height: 760px) {
  .altar h2 { margin: 0; font-size: 24px; }
  .tray { height: 30vh; min-height: 170px; }
  .vow { min-height: 64px; font-size: 17px; }
  .altar .thay { margin: 4px 0 0; font-size: 15px; padding: 8px 12px; }
}
/* kết quả dài hơn màn: thanh nút luôn thấy ở đáy */
.result > .row:last-child { position: sticky; bottom: calc(-1 * max(14px, env(safe-area-inset-bottom))); z-index: 3; flex: none;
  margin: auto -16px calc(-1 * max(14px, env(safe-area-inset-bottom))); padding: 10px 16px max(14px, env(safe-area-inset-bottom));
  background: var(--mustard); background-image: var(--halftone); background-size: 6px 6px; box-shadow: 0 -6px 12px rgba(90, 40, 0, .18); }
@media (max-height: 760px) {
  .res-pic { height: 96px; }
  .result h2 { margin: 0; font-size: 24px; }
  .big-score { font-size: 42px; }
}
/* khi trang bao ngoài (link chia sẻ) đã chừa khoảng tai thỏ / thanh home, 100dvh làm game dài hơn chỗ trống
   và đẩy thanh dưới ra ngoài màn -> không cao quá phần thân trang */
#app { max-height: 100%; }

/* ---------- lực đập ---------- */
/* hiệu ứng nhún khi trúng bị animation lơ lửng (play.css) đè mất -> chạy cả hai cùng lúc (khác thuộc tính: transform / translate) */
.play-v4 .r-mover .rdoll.hit-anim .rdoll-img { animation: squash2 .2s cubic-bezier(.2, .9, .3, 1.3), hover2 1.1s ease-in-out infinite; }
@keyframes squash2 { 0% { transform: scale(1.18, .78) rotate(-6deg); } 45% { transform: scale(.92, 1.1) rotate(3deg); } 100% { transform: none; } }
/* lóe trắng lúc trúng */
.rdoll-img.flash { filter: brightness(2.1) saturate(.35) drop-shadow(0 0 10px rgba(255, 245, 210, .9)); }
/* khựng hình: dừng hẳn mọi chuyển động lặp */
.stage.frozen .rdoll-img, .stage.frozen .p-shadow, .stage.frozen .slip { animation-play-state: paused !important; }
/* vòng sóng va chạm */
.hit-ring { position: absolute; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; pointer-events: none; z-index: 6;
  border: 5px solid #fff3c4; box-shadow: 0 0 0 3px rgba(200, 38, 31, .55), inset 0 0 12px rgba(255, 220, 140, .8);
  animation: ring .3s ease-out forwards; }
.hit-ring.big { width: 120px; height: 120px; margin: -60px 0 0 -60px; border-width: 7px; animation-duration: .36s; }
@keyframes ring { from { transform: scale(.25); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
/* số điểm theo hệ số combo */
.pop.warm { font-size: 27px; color: #ffb02e; text-shadow: 2px 2px 0 #7a1d12; }
.pop.hot { font-size: 32px; color: #ffe08a; text-shadow: 2px 2px 0 #c8261f, 0 0 10px rgba(255, 120, 40, .8); }
@media (prefers-reduced-motion: reduce) { .hit-ring { animation-duration: .01s; } }

/* chọn chế độ chơi (trang đầu + Cài đặt) */
.mode-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(100%, 360px); margin: 0 auto; }
.mode-pick button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 6px; border-radius: 12px;
  background: var(--cream); color: var(--navy); border: 3px solid var(--navy); opacity: .75; }
.mode-pick button b { font: 800 17px/1.1 var(--cond); text-transform: uppercase; }
.mode-pick button small { font-size: 12px; opacity: .8; }
.mode-pick button[aria-checked="true"] { opacity: 1; background: var(--navy); color: var(--cream); box-shadow: 0 4px 0 var(--navy-d); }
.mode-pick button[data-mode="kho"][aria-checked="true"] { background: #2a0f0b; border-color: #2a0f0b; color: #ffd23a; box-shadow: 0 4px 0 #000; }
@media (max-height: 760px) { .mode-pick button { padding: 5px 6px; } .mode-pick button small { display: none; } }

/* đường dây hỗ trợ tâm lý */
.help { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.help.compact { margin: 8px 0 10px; padding: 8px 10px; border-radius: 10px; background: rgba(47, 143, 131, .1); border: 1px solid rgba(47, 143, 131, .4); font-size: 14px; }
.help-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.help-line span { display: flex; flex-direction: column; min-width: 0; }
.help-line small { font-size: 12px; opacity: .75; }
.help-tel { flex: none; font: 800 18px var(--cond); color: var(--navy); text-decoration: none; background: var(--cream); border: 2px solid var(--navy); border-radius: 8px; padding: 4px 10px; white-space: nowrap; }
.sel { -webkit-user-select: text; user-select: text; }
