/* ================= Game systems UI (js/game/*.js): plates, buffs, cast bar, MVP banner, death box, game windows ================= */

/* monster name plates */
#mob-plates { position: absolute; left: 0; top: 0; pointer-events: none; }
.mplate { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 11px; font-weight: 500; color: #fff; text-shadow: var(--outline); transform-origin: 0 0; margin: -16px 0 0 0; translate: -50% 0; pointer-events: none; }
.mplate .mlv { margin-right: 4px; font-size: 10px; font-weight: 700; }
.mplate.d-g .mlv { color: #a0a0a8; } .mplate.d-e .mlv { color: #7dff8a; } .mplate.d-n .mlv { color: #ffffff; }
.mplate.d-h .mlv { color: #ffc24a; } .mplate.d-x .mlv { color: #ff5a4a; }
.mplate.r-elite .mn { color: #ffd27a; } .mplate.r-mvp .mn { color: #ff8a5a; font-weight: 700; font-size: 12.5px; }
.mplate.sel .mn { text-decoration: underline; text-decoration-color: #ff6a5a; text-underline-offset: 2px; }

/* buff / status row under the player frame */
.buffrow { position: absolute; left: 6px; top: calc(100% + 2px); display: flex; flex-wrap: wrap; gap: 3px; max-width: 300px; pointer-events: auto; }
.buffrow .bf { position: relative; width: 26px; height: 26px; border-radius: 6px; overflow: hidden; background: rgba(6, 12, 32, 0.85); border: 1px solid var(--gold-dim); }
.buffrow .bf.bad { border-color: #ff6a5a; }
.buffrow .bf .ico { width: 100%; height: 100%; display: block; }
.buffrow .bf .bt { position: absolute; left: 0; right: 0; bottom: -1px; font-size: 9px; line-height: 10px; text-align: center; color: #fff; text-shadow: var(--outline); font-variant-numeric: tabular-nums; }
.st-ic { display: grid; place-items: center; width: 100%; height: 100%; font-size: 14px; color: #fff; background: radial-gradient(circle, #5a1a2a, #200810); }
.st-freeze, .st-slow { background: radial-gradient(circle, #1a4a7a, #081830); }
.st-poison { background: radial-gradient(circle, #2a5a1a, #0a2008); }
body.studio-open .buffrow { display: none; }

/* cast bar */
.castbar { position: absolute; left: 50%; bottom: calc(var(--safe-b, 0px) + 150px); width: 240px; height: 18px; margin-left: -120px; border-radius: 9px; overflow: hidden; z-index: 4;
  background: rgba(6, 12, 32, 0.9); border: 1.5px solid var(--gold); box-shadow: 0 0 0 1px #000; pointer-events: none; }
.castbar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(180deg, #8ae8ff, #2a7ad8); }
.castbar .cb-n { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; font-size: 11.5px; font-weight: 600; color: #fff; text-shadow: var(--outline); }

/* ground aim hint */
.aimhint { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 6px 14px; border-radius: 16px; font-size: 13px; color: #fff; background: rgba(10, 40, 80, 0.9); border: 1px solid #7fe8ff; pointer-events: auto; cursor: pointer; z-index: 5; }

/* MVP banner */
.mvpbanner { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); text-align: center; pointer-events: none; z-index: 8; padding: 8px 34px 10px;
  background: linear-gradient(90deg, transparent, rgba(80, 10, 10, 0.85) 18%, rgba(80, 10, 10, 0.85) 82%, transparent); }
.mvpbanner small { display: block; font-size: 13px; color: #ffd27a; letter-spacing: 0.08em; }
.mvpbanner b { display: block; font-size: 28px; font-weight: 700; color: #fff; text-shadow: 0 0 10px #ff5a2a, var(--outline); }
.mvpbanner.killed { background: linear-gradient(90deg, transparent, rgba(70, 50, 8, 0.88) 18%, rgba(70, 50, 8, 0.88) 82%, transparent); }
.mvpbanner.show { animation: mvpIn 5.2s ease-out forwards; }
@keyframes mvpIn { 0% { opacity: 0; transform: translateX(-50%) scale(1.6); } 8% { opacity: 1; transform: translateX(-50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }

/* death / respawn */
.deathbox { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(20, 0, 8, 0.45); }
.deathbox .db-in { width: min(360px, 90vw); padding: 18px 20px; border-radius: 12px; text-align: center; background: linear-gradient(180deg, rgba(40, 12, 24, 0.97), rgba(10, 4, 12, 0.97)); border: 1.5px solid #b84a4a; box-shadow: 0 0 0 1px #000, 0 14px 40px rgba(0, 0, 0, 0.6); }
.deathbox h3 { margin: 0 0 6px; font-size: 22px; color: #ffb0a0; }
.deathbox p { margin: 0 0 14px; font-size: 13px; color: #e8d0d8; }
.db-acts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* bot settings button next to AUTO */
.bot-gear { position: absolute; right: -6px; top: -34px; width: 30px; height: 30px; padding: 5px; border-radius: 50%; color: var(--gold-hi); background: radial-gradient(circle at 50% 35%, #2a4a8e, #0a1430 75%); border: 1.5px solid var(--gold); box-shadow: 0 0 0 1px #000; pointer-events: auto; }
.bot-gear svg { width: 100%; height: 100%; fill: currentColor; }
.slot.none .face { opacity: 0.35; filter: grayscale(1); }
/* cooldown sweep: real cooldowns dim the icon, the 0.6 s global cooldown only shades it lightly (the bot casts nonstop) */
.slot .cd { background: conic-gradient(rgba(2, 4, 14, 0.66) calc(var(--cd, 0) * 1turn), transparent 0); }
.slot.gcd .cd { background: conic-gradient(rgba(2, 4, 14, 0.3) calc(var(--cd, 0) * 1turn), transparent 0); }
.slot.unlearned .face { opacity: 0.45; filter: grayscale(0.8); }
.slot .cnt { pointer-events: none; }

/* ---------------- item tiles (rarity from GDB) */
.itile.gi { --rc: #4a5a7a; cursor: pointer; }
.itile.q-common { --rc: #c8c8d0; } .itile.q-special { --rc: #5ad85a; } .itile.q-rare { --rc: #4aa0ff; }
.itile.q-legend { --rc: #c060ff; box-shadow: 0 0 0 1px #000, 0 0 10px rgba(192, 96, 255, 0.6); }
.itile.q-lunelia { --rc: #7ad8ff; animation: lunelia 2.4s linear infinite; }
@keyframes lunelia { 0% { border-color: #7ad8ff; box-shadow: 0 0 0 1px #000, 0 0 10px #7ad8ff; } 33% { border-color: #fff2b0; box-shadow: 0 0 0 1px #000, 0 0 14px #fff2b0; }
  66% { border-color: #d08aff; box-shadow: 0 0 0 1px #000, 0 0 12px #d08aff; } 100% { border-color: #7ad8ff; box-shadow: 0 0 0 1px #000, 0 0 10px #7ad8ff; } }
.itile.gi .ico { width: 84%; height: 84%; image-rendering: pixelated; }
.itile .rf { position: absolute; left: 2px; top: 0; font-size: 11px; font-weight: 700; color: #ffe07a; text-shadow: var(--outline); }
.itile .cs { position: absolute; right: 3px; top: 3px; display: flex; gap: 1px; }
.itile .cs i { width: 4px; height: 4px; border-radius: 1px; background: #2a3450; box-shadow: 0 0 0 1px #000; }
.itile .cs i.on { background: #ffd27a; }
.itile .lk { position: absolute; left: 1px; bottom: 0; font-size: 9px; }
.itile .eqm { position: absolute; left: 2px; bottom: 0; font-size: 10px; font-weight: 700; color: #7dff8a; text-shadow: var(--outline); }
.itile.locked { filter: saturate(0.8); }
.ico.mini { width: 18px; height: 18px; vertical-align: -4px; margin-right: 3px; }

/* tooltip additions */
.tip .tstats { color: #fff; font-weight: 500; }
.tip .tsub { color: var(--muted); font-size: 12px; }
.tip .tbonus { color: #9ad8ff; }
.tip .tbad { color: #ff8a7a; }
.tip .tcmp { font-size: 12px; border-top: 1px solid var(--line-dim); padding-top: 4px; }
.tip .tcmp .up { color: #7dff8a; margin-right: 6px; } .tip .tcmp .down { color: #ff7a6a; margin-right: 6px; }
.tip { max-width: 290px; }

/* ---------------- character: equipment + stats */
.gdoll .doll-col { justify-content: flex-start; gap: 8px; }
.eqs { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.eqs .itile { width: 54px; height: 54px; }
.eqs .eql { font-size: 10px; color: var(--muted); }
.eqs .itile.emptyc .eqn { font-size: 9.5px; color: #6a7aa8; }
.doll-note { position: absolute; left: 6px; right: 6px; bottom: 44px; font-size: 10.5px; color: #ffd27a; text-align: center; text-shadow: var(--outline); }
.stat-body { flex-direction: row; gap: 10px; }
.stat-left { flex: 1.4; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.stat-right { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.shead { font-size: 14px; } .shead b { color: var(--gold-hi); }
.sexp { font-size: 12px; color: var(--muted); }
.srows { display: flex; flex-direction: column; gap: 4px; }
.srow { display: grid; grid-template-columns: 44px 74px 1fr auto 34px; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 8px; background: rgba(2, 6, 18, 0.4); border: 1px solid var(--line-dim); }
.srow .sk { font-size: 15px; color: var(--gold-hi); }
.srow .sv { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.srow em { font-style: normal; font-size: 11.5px; margin-left: 3px; }
.jb { color: #7dff8a; } .gb { color: #8ac8ff; }
.srow .sd { font-size: 11px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .sc { font-size: 11px; color: var(--muted); }
.srow .splus { min-width: 0; width: 32px; height: 28px; padding: 0; font-size: 18px; }
.spts { font-size: 13px; } .spts b { color: #ffe07a; font-size: 16px; }
.spts em { font-style: normal; }

/* ---------------- skill tree */
.win.skill-win { width: 680px; }
.sk-body { flex-direction: row; gap: 10px; }
.sk-tree { flex: none; padding: 6px; border-radius: 10px; background: radial-gradient(circle at 50% 30%, rgba(40, 70, 140, 0.35), rgba(2, 6, 18, 0.5)); border: 1px solid var(--line-dim); overflow: auto; max-height: 100%; }
.sk-canvas { position: relative; }
.sk-lines { position: absolute; left: 0; top: 0; pointer-events: none; }
.sk-lines line { stroke: #4a5a80; stroke-width: 3; }
.sk-lines line.met { stroke: #ffd27a; }
.sk-node { position: absolute; width: 62px; height: 66px; display: flex; flex-direction: column; align-items: center; cursor: pointer; touch-action: none; }
.sk-node .ski { width: 44px; height: 44px; margin-top: 4px; border-radius: 9px; overflow: hidden; border: 2px solid #4a5a80; box-shadow: 0 0 0 1px #000; background: #0a1430; }
.sk-node.pas .ski { border-radius: 50%; }
.sk-node .ski .ico { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.sk-node.has .ski { border-color: var(--gold); }
.sk-node.sel .ski { border-color: #fff; box-shadow: 0 0 0 1px #000, 0 0 10px #7fe8ff; }
.sk-node.locked .ski { filter: grayscale(1) brightness(0.55); }
.sk-node .skv { font-size: 10.5px; font-weight: 600; color: #fff; text-shadow: var(--outline); margin-top: 1px; }
.sk-node .skp { position: absolute; right: 2px; top: 0; width: 20px; height: 20px; padding: 0; border-radius: 50%; font-size: 15px; line-height: 18px; font-weight: 700; color: #1a2a00;
  background: linear-gradient(180deg, #b0ff8a, #4ac83a); border: 1px solid #e8ffd0; box-shadow: 0 0 0 1px #000; }
.sk-detail2 { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; overflow-y: auto; }
.sk-detail2 .skh { display: flex; gap: 10px; align-items: center; }
.sk-detail2 .skic { width: 52px; height: 52px; flex: none; border-radius: 10px; overflow: hidden; border: 2px solid var(--gold); }
.sk-detail2 .skic .ico { width: 100%; height: 100%; display: block; }
.sk-detail2 h4 { margin: 0; font-size: 16px; } .sk-detail2 h4 small { font-size: 11px; color: var(--muted); font-weight: 400; }
.sk-detail2 .meta { font-size: 11.5px; color: var(--cyan); }
.sk-detail2 p { margin: 0; line-height: 1.5; }
.sk-detail2 .nx { color: #9ad8ff; } .sk-detail2 .rq .ok { color: #7dff8a; } .sk-detail2 .rq .no { color: #ff8a7a; }
.skb { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.skb .pts { flex: 1; } .skb .pts b { color: #ffe07a; font-size: 16px; }

/* ---------------- shops / refine / storage / job / bot */
.shop-switch { display: flex; gap: 6px; flex: none; }
.row.dim { opacity: 0.55; }
.row .itile.gi { width: 46px; height: 46px; }
.sub .bad, b.bad { color: #ff8a7a; font-weight: 500; }
.ri-info .sub { font-size: 12px; color: var(--muted); }
.qty { display: flex; align-items: center; gap: 3px; }
.qty button { width: 28px; height: 28px; padding: 0; border-radius: 6px; color: #fff; background: rgba(20, 36, 76, 0.95); border: 1px solid var(--line); }
.qty span { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.sellrow { cursor: pointer; } .sellrow.on { background: rgba(60, 140, 90, 0.18); }
.sellrow input { width: 18px; height: 18px; }
.refine-body, .st-body, .job-body { flex-direction: row; gap: 10px; }
.rf-list { width: 46%; display: flex; flex-direction: column; gap: 4px; }
.rf-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; cursor: pointer; font-size: 13px; border: 1px solid transparent; }
.rf-row .itile { width: 40px; height: 40px; }
.rf-row.on { border-color: var(--gold); background: rgba(60, 100, 180, 0.2); }
.rf-row em { color: #7dff8a; font-style: normal; font-size: 11px; }
.rf-main { flex: 1; display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; }
.rf-big .itile { width: 72px; height: 72px; margin: 0 auto; }
.rf-name { margin-top: 6px; font-size: 15px; font-weight: 600; }
.rf-arrow { font-size: 18px; } .rf-arrow b { color: #ffe07a; font-size: 22px; }
.rf-info { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; align-items: center; }
.rf-info b { color: #ffe07a; } .rf-info em.ok { color: #7dff8a; font-style: normal; } .rf-info em.no { color: #ff8a7a; font-style: normal; }
.rf-fail { color: #ffb0a0; font-size: 12px; } .rf-bonus { color: var(--muted); font-size: 12px; }
.st-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.st-col h5 { margin: 0; font-size: 13px; color: var(--gold-hi); }
.st-body { flex-wrap: wrap; } .st-hint { width: 100%; }
.st-col .bag-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
.job-body { flex-direction: column; overflow-y: auto; }
.job-cur { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.job-cur img { width: 52px; height: 52px; image-rendering: pixelated; }
.job-cur b { font-size: 17px; color: var(--gold-hi); } .job-cur small { color: var(--muted); }
.job-req .ok { color: #7dff8a; margin-right: 6px; } .job-req .no { color: #ff8a7a; margin-right: 6px; }
.job-kids { display: flex; flex-wrap: wrap; gap: 8px; }
.job-card { flex: 1 1 200px; display: flex; gap: 8px; padding: 8px; border-radius: 10px; background: rgba(2, 6, 18, 0.45); border: 1.5px solid var(--jc, var(--gold)); }
.jc-art { width: 70px; flex: none; display: grid; place-items: center; overflow: hidden; }
.jc-art img { width: 100%; height: auto; }
.jc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.jc-info b { font-size: 15px; } .jc-info small { color: var(--muted); }
.jc-em { width: 28px; height: 28px; }
.jc-sk { display: flex; gap: 2px; } .jc-sk .ico { width: 22px; height: 22px; border-radius: 4px; }
.jc-note { color: #ffd27a; font-size: 11px; }
.jc-info .btn-gold { height: 34px; font-size: 14px; padding: 0 10px; margin-top: 4px; }
.win.small-win { width: 380px; height: auto; bottom: auto; }
.win.job-win { width: 640px; }
.bot-body { flex-direction: column; }
.ck { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 3px 0; cursor: pointer; }
.ck input { width: 18px; height: 18px; flex: none; }
.cks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.frow.rg input[type=range] { flex: 1; }
.frow.rg output { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }
.bsk { display: flex; align-items: center; gap: 6px; padding: 4px; border-bottom: 1px solid var(--line-dim); font-size: 13px; }
.bsk .ico { width: 30px; height: 30px; border-radius: 6px; flex: none; }
.bsk .bn { flex: 1; min-width: 0; } .bsk .bn small { display: block; color: var(--muted); font-size: 11px; }
.bsk select, .bot-body select { height: 30px; border-radius: 6px; color: #fff; background: #0c1736; border: 1px solid var(--line); max-width: 200px; }
.bsk input[type=number] { width: 46px; height: 28px; border-radius: 6px; color: #fff; background: #0c1736; border: 1px solid var(--line); }
.bsk .mv { height: 28px; padding: 0 8px; }
.sgrid { display: grid; grid-template-columns: 80px repeat(5, 1fr); gap: 4px; align-items: center; font-size: 12px; text-align: center; }
.sgrid span { text-align: left; color: var(--muted); }
.sgrid input { width: 18px; height: 18px; margin: 0 auto; }
.ad { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tag { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: rgba(20, 36, 76, 0.9); border: 1px solid var(--line); }
.tag.ok { border-color: #5ad85a; } .tag.no { border-color: #ff6a5a; }
.tag a { cursor: pointer; color: #ffb0a0; margin-left: 4px; }
.blog { font-size: 12.5px; line-height: 1.6; max-height: 340px; overflow-y: auto; font-variant-numeric: tabular-nums; }
.btn-ghost.danger { border-color: #ff6a5a; color: #ffb0a0; }

/* phones: stack two-column windows */
.win .win-body.sk-body, .win .win-body.stat-body, .win .win-body.refine-body, .win .win-body.st-body { flex-direction: row; }
@media (max-width: 700px), (orientation: portrait) and (max-width: 900px) {
  .win.skill-win, .win.job-win, .win.small-win { width: auto; max-width: 100vw; }
  .win .win-body.sk-body, .win .win-body.stat-body, .win .win-body.refine-body { flex-direction: column; }
  .sk-body, .stat-body, .refine-body { flex-direction: column; }
  .sk-tree { max-height: 55%; }
  .rf-list { width: 100%; max-height: 40%; }
  .srow { grid-template-columns: 40px 70px 1fr 34px; } .srow .sc { display: none; }
  .castbar { width: 180px; margin-left: -90px; bottom: 130px; }
  .mvpbanner b { font-size: 20px; }
}

/* unspent points badge on the menu buttons */
#menuRow .mbtn.pts::after { content: "+"; position: absolute; right: 2px; top: 0; width: 18px; height: 18px; border-radius: 50%; font-size: 14px; font-weight: 700; line-height: 17px; text-align: center;
  color: #1a2a00; background: linear-gradient(180deg, #b0ff8a, #4ac83a); box-shadow: 0 0 0 1px #000, 0 0 8px #7dff8a; animation: autoPulse 1.4s infinite; z-index: 2; }
#menuRow .mbtn { position: relative; }

/* change-job call to action */
.job-cta { position: absolute; left: 50%; bottom: calc(var(--safe-b, 0px) + 200px); max-width: 86vw; text-align: center; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 7px 16px; border-radius: 22px; border: 2px solid #ffe08a; background: linear-gradient(#7a3cff, #3b1a8a); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  box-shadow: 0 0 14px #b98cff, 0 2px 0 #000; animation: jobPulse 1.2s ease-in-out infinite; pointer-events: auto; }
.job-cta small { font-size: 10.5px; font-weight: 400; color: #ffe9b0; }
.job-cta.hidden { display: none; }
@keyframes jobPulse { 50% { box-shadow: 0 0 26px #ffd27a, 0 2px 0 #000; transform: translateX(-50%) scale(1.06); } }
/* skill learn bar stays pinned so repeated taps on "เรียน +1" always hit the button */
.sk-detail2 { position: relative; }
.sk-detail2 .skb { position: sticky; bottom: 0; margin-top: auto; padding-top: 6px; background: linear-gradient(transparent, rgba(8, 10, 40, 0.92) 30%); }

/* combat words in Thai (js/game/ctext.js LS.CT): status / miss / dodge, monster skill names, refine result */
#ct-layer { position: absolute; left: 0; top: 0; pointer-events: none; }
.ctw { position: absolute; left: 0; top: 0; display: none; white-space: nowrap; pointer-events: none; will-change: transform, opacity; transform-origin: 50% 100%;
  font-family: 'Kanit', sans-serif; font-size: 17px; font-weight: 700; line-height: 1.15; letter-spacing: 0.01em;
  text-shadow: 0 1px 0 #000, 0 2px 0 #14101e, 1px 0 0 #14101e, -1px 0 0 #14101e, 0 -1px 0 #14101e, 1px 1px 0 #14101e, -1px 1px 0 #14101e, 0 0 6px rgba(0, 0, 0, 0.55); }
.ctw.sk { font-size: 14px; font-weight: 600; }
.ctw.big { font-size: 22px; }

/* hotbar skill level: a small corner badge, so the skill icon stays visible (hidden on phone-size slots) */
.slot.skill .cnt { right: 0; bottom: 0; padding: 1px 3px 0; border-radius: 4px 0 2px 0; font-size: 10px; line-height: 1.1; color: #e8dcff; background: rgba(10, 4, 30, 0.72); text-shadow: 0 1px 0 #000; }
@media (max-width: 760px), (max-height: 540px) { .slot.skill .cnt { display: none; } }

.guide-tip { position: absolute; left: 50%; bottom: calc(var(--safe-b, 0px) + 262px); transform: translateX(-50%); max-width: 88vw; text-align: center; z-index: 39; padding: 6px 14px; border-radius: 16px;
  background: rgba(8, 12, 40, 0.88); border: 1px solid var(--gold-dim, #b88a34); color: #ffe9b0; font-size: 12.5px; line-height: 1.35; pointer-events: none; }
.guide-tip.hidden { display: none; }
