/* talk.css — hội thoại NPC / cốt truyện (js/ext_talk.js) + popup chung. Dùng token của css/kit.css; nạp sau kit.css. */

/* ===================== hội thoại ===================== */
.win.win-talk { top: auto; bottom: 150px; left: calc(50% - 250px); width: 620px; min-width: 0; max-width: calc(100vw - 230px); overflow: visible; }
.win.win-talk.has-side { width: 780px; left: calc(50% - 330px); }
.win-talk .win-head small { font: 600 13px/1 var(--f-text); color: rgba(42, 36, 53, .72); letter-spacing: 0; }
.win.win-talk .win-body { max-height: none; overflow: visible; padding: 12px 14px 13px; }
.win-talk.has-bust .win-body { padding-left: 74px; }
.tk-wrap { display: flex; gap: 14px; align-items: flex-start; }
.tk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tk-medal { flex: none; width: 96px; height: 96px; border: 3px solid var(--ink); border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #6a4a3a, #2a2236 75%); box-shadow: inset 0 0 0 3px var(--wood), 0 3px 0 var(--ink); }
/* tranh chân dung to đứng ngoài mép trái, chân chạm đáy khung; nhún nhẹ khi đang nói */
.tk-bust { position: absolute; right: calc(100% - 66px); bottom: -6px; z-index: 3; pointer-events: none; animation: tkBustIn .32s ease-out; }
.tk-bust img { display: block; height: 232px; width: auto; image-rendering: pixelated; transform-origin: 50% 100%; filter: drop-shadow(0 5px 0 rgba(0, 0, 0, .35)); }
.win-talk.typing .tk-bust img { animation: tkTalk .28s ease-in-out infinite alternate; }
@keyframes tkTalk { to { transform: translateY(-3px) scaleY(1.012); } }
@keyframes tkBustIn { from { opacity: 0; transform: translateX(-28px); } }
.tk-rib { align-self: flex-start; padding: 0 12px; font: 700 11.5px/20px var(--f-head); color: #fff; background: #6a5aa8; border: 2px solid var(--ink); border-radius: 8px; text-shadow: 0 1px 0 var(--ink); box-shadow: var(--lift); }
.tk-title { margin: -2px 0 0; font: 800 21px/1.15 var(--f-head); color: var(--amber); text-shadow: 0 2px 0 rgba(255, 255, 255, .7); }
/* ô lời thoại: giấy trắng, đuôi chỉ về NPC, mũi tên ▼ chờ bấm */
.tk-say { position: relative; min-height: 70px; padding: 10px 16px 14px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; cursor: var(--cur-ui);
  box-shadow: inset 0 -4px 0 rgba(42, 36, 53, .06), 0 2px 0 var(--ink); }
.win-talk.has-bust .tk-say::before, .win-talk.has-bust .tk-say::after { content: ''; position: absolute; top: 20px; width: 0; height: 0; border-style: solid; }
.win-talk.has-bust .tk-say::before { left: -13px; border-width: 9px 13px 9px 0; border-color: transparent var(--ink) transparent transparent; }
.win-talk.has-bust .tk-say::after { left: -9px; top: 22px; border-width: 7px 10px 7px 0; border-color: transparent var(--paper) transparent transparent; }
.tk-text { margin: 0; font: 400 14.5px/1.6 var(--f-text); color: var(--ink); }
.tk-text b { color: var(--amber); }
.win-talk.narr .tk-say { background: #f3ead8; }
.win-talk.narr .tk-text { font-style: italic; color: #5a4a3a; text-align: center; }
.tk-more { position: absolute; right: 12px; bottom: 6px; width: 0; height: 0; border-style: solid; border-width: 7px 6px 0 6px; border-color: var(--sky-d) transparent transparent transparent; animation: tkMore .5s ease-in-out infinite alternate; }
.win-talk.typing .tk-more { visibility: hidden; }
@keyframes tkMore { to { transform: translateY(3px); } }
/* lựa chọn: nút to có phím số + biểu tượng */
.tk-opts { display: grid; grid-template-columns: 1fr; gap: 6px; }
.tk-opts:has(> :nth-child(4)) { grid-template-columns: 1fr 1fr; }
.win .tk-opts button.tk-opt { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 10px 4px 6px; text-align: left; font: 700 13.5px/1.25 var(--f-head); }
.win .tk-opts button.tk-opt.quest { background: #fff1c0; box-shadow: inset 0 -3px 0 rgba(168, 98, 12, .18), inset 0 2px 0 rgba(255, 255, 255, .8), var(--lift); }
.win .tk-opts button.tk-opt.quest:hover { background: #fff6d6; }
.win .tk-opts button.tk-opt.bye { color: var(--ink-soft); background: var(--cream-2); }
.tk-opt kbd, .tk-btns kbd { flex: none; min-width: 20px; padding: 0 5px; font: 800 11px/16px var(--f-head); text-align: center; color: var(--ink-soft); background: var(--cream-2); border: 2px solid rgba(42, 36, 53, .5); border-radius: 6px; }
.tk-btns kbd { margin-right: 6px; }
.tk-ic { flex: none; width: 26px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.tk-l { flex: 1; min-width: 0; }
.tk-q { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font: 900 15px/1 var(--f-head); font-style: normal; color: var(--ink);
  background: var(--gold-2); border: 2px solid var(--ink); border-radius: 50%; animation: tkQ .9s ease-in-out infinite alternate; }
.tk-q.turn { background: #8ae0a0; }
@keyframes tkQ { to { transform: translateY(-2px); box-shadow: 0 0 8px 2px rgba(255, 207, 90, .8); } }
.tk-foot { display: flex; align-items: center; gap: 8px; }
.tk-page { margin-right: auto; font: 700 12px/1 var(--f-head); color: var(--ink-soft); }
.tk-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.win .tk-btns button { display: inline-flex; align-items: center; padding: 5px 14px; font-size: 14px; }
/* tranh truyện lúc trả nhiệm vụ (assets/pixel/story, vẽ ×2 như bản offline hiện tranh) */
.win-talk.has-panel { width: 760px; left: calc(50% - 320px); }
.tk-panel { display: flex; justify-content: center; margin: 0 0 10px; }
.tk-panel img { display: block; width: 512px; height: 288px; max-width: 100%; max-height: 34vh; object-fit: contain; image-rendering: pixelated; background: #0a0810;
  border: 3px solid var(--ink); border-radius: 12px; box-shadow: inset 0 0 0 2px var(--wood), 0 3px 0 var(--ink); animation: tkPanel .4s ease-out; }
@keyframes tkPanel { from { opacity: 0; transform: scale(.96); } }
/* cột phải trang cuối: cần làm + phần thưởng */
.tk-side { flex: 0 0 260px; align-self: stretch; display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; }
.tk-side .qd-card, .tk-side .qd-sys { margin: 0; }
.tk-side .qd-card { color: #f4ead8; background: var(--card); border-radius: 12px; }
.tk-side .qd-card > b { color: var(--gold-2); }
.tk-side .qd-card > small, .tk-side .qd-card p, .tk-side .qd-objs li i, .tk-side .qd-objs li small { color: #c8b898; }
.tk-side .qd-objs { margin: 6px 0; padding: 6px 8px; background: rgba(255, 255, 255, .06); border-radius: 8px; }
.tk-side .qd-objs li { padding: 2px 0; } .tk-side .qd-objs li b { color: var(--gold-2); } .tk-side .qd-objs li.done { color: #8ff08a; }
.tk-side .qd-rew { padding: 6px 8px; color: #fff4d8; background: rgba(255, 207, 90, .12); border: 2px dashed rgba(255, 207, 90, .5); border-radius: 8px; }
.tk-side > .qd-objs { color: var(--ink); background: var(--cream-2); border: 2px solid var(--ink); }
@media (max-width: 900px) {
  .win.win-talk, .win.win-talk.has-side { left: 8px; right: 8px; width: auto; max-width: none; }
  .win-talk.has-bust .win-body { padding-left: 14px; } .tk-bust { display: none; } .tk-wrap { flex-wrap: wrap; } .tk-side { flex-basis: 100%; }
}

/* ===================== popup chung (.kpop: chuyển nghề...; hộp gục ngã; hộp hỏi ở menu chính) ===================== */
.kpop { position: fixed; inset: 0; z-index: 88; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(24, 16, 36, .45), rgba(6, 4, 12, .8)); animation: popFade .2s ease-out; }
@keyframes popFade { from { opacity: 0; } }
.pop-rays { position: absolute; left: 50%; top: 50%; width: 620px; height: 620px; margin: -330px 0 0 -310px; border-radius: 50%; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 214, 110, .32) 0 9deg, transparent 9deg 18deg); -webkit-mask: radial-gradient(circle, #000 18%, transparent 68%); mask: radial-gradient(circle, #000 18%, transparent 68%);
  animation: popSpin 14s linear infinite; }
@keyframes popSpin { to { transform: rotate(360deg); } }
.pop-box, #death .box, #mm-ask .box { position: relative; min-width: 340px; max-width: 470px; padding: 50px 30px 22px; text-align: center; color: var(--ink); background: var(--cream);
  border: 4px solid var(--ink); border-radius: 18px; box-shadow: inset 0 0 0 3px var(--sky), 0 8px 0 rgba(0, 0, 0, .4), 0 20px 60px rgba(0, 0, 0, .5); animation: popIn .45s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes popIn { from { opacity: 0; transform: translateY(24px) scale(.82); } }
.pop-rib, #death .box:not(.fallen) h2 { position: absolute; left: 50%; top: -42px; width: 336px; height: 135px; margin: 0 0 0 -168px; padding-top: 37px;
  font: 800 20px/1.2 var(--f-head); color: #fff4d8; letter-spacing: .5px; background: url(../assets/pixel/ui_ribbon.png) center / 336px 135px no-repeat; image-rendering: pixelated; pointer-events: none;
  text-shadow: 2px 2px 0 var(--ink), -2px 2px 0 var(--ink), 2px -2px 0 var(--ink), -2px -2px 0 var(--ink), 0 3px 0 var(--ink); }
.pop-box h2 { margin: 4px 0 2px; font: 800 30px/1.15 var(--f-head); color: var(--amber); text-shadow: 0 3px 0 rgba(42, 36, 53, .15); }
.pop-sub { margin: 0 0 10px; font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); }
.pop-hero { display: block; width: 180px; height: 150px; margin: 6px auto 0; image-rendering: pixelated; background: radial-gradient(ellipse 45% 40% at 50% 70%, rgba(255, 207, 90, .45), transparent 70%); }
.pop-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 4px 0 10px; }
.pop-chips span { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 3px; font: 700 12.5px/1 var(--f-head); color: #f4ead8; background: var(--card); border: 2px solid var(--ink); border-radius: 10px; }
.pop-btns, #mm-ask .row { display: flex; justify-content: center; gap: 10px; margin-top: 8px; }
.pop-btns button, #death .box:not(.fallen) button, #mm-ask .box button { min-width: 140px; padding: 8px 20px !important; font-size: 16px !important; font-weight: 800 !important; border-radius: 11px; }
/* gục ngã: ruy băng đỏ */
#death { background: radial-gradient(ellipse at center, rgba(80, 0, 0, .25), rgba(30, 0, 0, .72)); }
#death .box:not(.fallen) { padding-top: 56px; box-shadow: inset 0 0 0 3px #ff9a8a, 0 8px 0 rgba(0, 0, 0, .4), 0 20px 60px rgba(0, 0, 0, .5); }
#death .box:not(.fallen) h2 { color: #fff0e8; filter: hue-rotate(150deg) saturate(1.3); }
#death .box:not(.fallen) p { margin: 4px 0 12px; font-size: 14px; color: var(--ink); }
#death .box.fallen { animation: popIn .45s cubic-bezier(.2, 1.5, .4, 1); }
/* hộp hỏi đồng ý ở menu chính */
#mm-ask { background: rgba(6, 4, 12, .62); }
#mm-ask .box { padding: 26px 28px 20px; }
#mm-ask p { margin: 0 0 14px; font-size: 15px; line-height: 1.55; color: var(--ink); }
#mm-ask p small { color: var(--ink-soft); font-size: 12.5px; }
.mm-toast { padding: 9px 18px 9px 14px; font: 800 14px/1.2 var(--f-head); color: #d8ffe0; background: rgba(28, 22, 36, .96); border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: inset 0 0 0 2px var(--green), 0 4px 0 rgba(0, 0, 0, .4); animation: popIn .3s ease-out; }
.mm-toast.bad { color: #ffd8d0; background: rgba(40, 18, 22, .96); border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--red), 0 4px 0 rgba(0, 0, 0, .4); }
