/* ==================== SPARK PAWS — giao diện pixel RPG ==================== */
@font-face{font-family:Handjet;font-weight:600;src:url(../assets/fonts/Handjet-600-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Handjet;font-weight:600;src:url(../assets/fonts/Handjet-600-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:Handjet;font-weight:600;src:url(../assets/fonts/Handjet-600-vietnamese.woff2) format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB}
@font-face{font-family:Handjet;font-weight:800;src:url(../assets/fonts/Handjet-800-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Handjet;font-weight:800;src:url(../assets/fonts/Handjet-800-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:Handjet;font-weight:800;src:url(../assets/fonts/Handjet-800-vietnamese.woff2) format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB}
@font-face{font-family:Baloo2;font-weight:600;src:url(../assets/fonts/Baloo2-600-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Baloo2;font-weight:600;src:url(../assets/fonts/Baloo2-600-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:Baloo2;font-weight:600;src:url(../assets/fonts/Baloo2-600-vietnamese.woff2) format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB}
@font-face{font-family:Baloo2;font-weight:800;src:url(../assets/fonts/Baloo2-800-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Baloo2;font-weight:800;src:url(../assets/fonts/Baloo2-800-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
@font-face{font-family:Baloo2;font-weight:800;src:url(../assets/fonts/Baloo2-800-vietnamese.woff2) format('woff2');unicode-range:U+0102-0103,U+0110-0111,U+0128-0129,U+0168-0169,U+01A0-01A1,U+01AF-01B0,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+1EA0-1EF9,U+20AB}

:root{
  --ink:#3b2a1a; --ink2:#6b5236; --paper:#e9d6a8; --gold:#f2b134; --red:#d9534f; --green:#4caf50; --blue:#3d8bd4;
  --px:3px; /* cỡ 1 "pixel" của khung giao diện */
}
*{box-sizing:border-box;margin:0;padding:0;-webkit-tap-highlight-color:transparent}
html,body{width:100%;height:100%;overflow:hidden;background:#1c1117;color:var(--ink);font-family:Baloo2,system-ui,sans-serif;font-weight:600;
  user-select:none;-webkit-user-select:none;touch-action:none}
#c{position:fixed;inset:0;display:block;image-rendering:pixelated}
img.px{image-rendering:pixelated;display:block;width:28px;height:28px;flex-shrink:0}
.h{font-family:Handjet,system-ui,sans-serif;font-weight:800;letter-spacing:.5px}
.hidden{display:none!important}

/* ---------- khung giấy da & nút (Kenney Pixel UI, 9-slice) ---------- */
.panel{border-style:solid;border-width:calc(var(--px)*4);border-image:url(../assets/ui/panel.png) 16 fill / calc(var(--px)*5) round;image-rendering:pixelated;padding:4px}
.panel.dark{border-image-source:url(../assets/ui/panel_dark.png);color:#fff3dc}
.inlay{background:#dcc28f;border:3px solid #9c7c4c;box-shadow:inset 0 3px 0 rgba(90,60,30,.18),0 2px 0 rgba(255,255,255,.35)}
.btn{font-family:Handjet,system-ui,sans-serif;font-weight:800;font-size:22px;color:#3b2a1a;letter-spacing:.5px;background:none;cursor:pointer;
  border-style:solid;border-width:calc(var(--px)*3);border-image:url(../assets/ui/btn_yellow.png) 16 fill / calc(var(--px)*4) round;image-rendering:pixelated;
  padding:2px 14px;min-height:48px;display:inline-flex;align-items:center;justify-content:center;gap:6px;transition:transform .06s}
.btn:active:not(:disabled){border-image-source:url(../assets/ui/btn_yellow_p.png);transform:translateY(2px)}
.btn.green{border-image-source:url(../assets/ui/btn_green.png);color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.25)}
.btn.green:active:not(:disabled){border-image-source:url(../assets/ui/btn_green_p.png)}
.btn.blue{border-image-source:url(../assets/ui/btn_blue.png);color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.25)}
.btn.blue:active:not(:disabled){border-image-source:url(../assets/ui/btn_blue_p.png)}
.btn.red{border-image-source:url(../assets/ui/btn_red.png);color:#fff;text-shadow:0 2px 0 rgba(0,0,0,.25)}
.btn.red:active:not(:disabled){border-image-source:url(../assets/ui/btn_red_p.png)}
.btn.grey{border-image-source:url(../assets/ui/btn_grey.png)}
.btn.grey:active:not(:disabled){border-image-source:url(../assets/ui/btn_grey_p.png)}
.btn:disabled{filter:grayscale(1) brightness(.85);opacity:.6;cursor:not-allowed}
.btn.sm{font-size:18px;min-height:40px;padding:0 10px}
.btn.block{width:100%}
.btn img{width:24px;height:24px}

/* ---------- HUD ---------- */
#hud{position:fixed;inset:0;pointer-events:none;z-index:5}
#hud .tl{position:absolute;left:10px;top:10px;display:flex;gap:8px;align-items:flex-start}
#hud .por{width:64px;height:64px;padding:0;display:flex;align-items:center;justify-content:center}
#hud .por img{width:44px;height:44px}
.bars{min-width:150px;padding:2px 8px 4px}
.lv{font-size:20px;line-height:1.1;color:var(--ink)}
.bar{height:14px;background:#4a3324;border:2px solid #2a1a12;margin-top:3px;position:relative}
.bar i{position:absolute;left:0;top:0;bottom:0;background:var(--red);box-shadow:inset 0 -3px 0 rgba(0,0,0,.2), inset 0 3px 0 rgba(255,255,255,.25)}
.bar.xp{height:8px}.bar.xp i{background:var(--blue)}
.bar span{position:absolute;inset:0;font-family:Handjet;font-weight:800;font-size:13px;line-height:10px;color:#fff;text-align:center;text-shadow:0 1px 0 #000}
#hud .tr{position:absolute;right:10px;top:10px;display:flex;gap:8px;align-items:flex-start;pointer-events:auto}
.res{display:flex;align-items:center;gap:6px;padding:2px 10px;font-family:Handjet;font-weight:800;font-size:22px;min-height:48px}
.res img{width:28px;height:28px}
.iconbtn{width:56px;height:56px;padding:0;min-height:0}
.iconbtn img{width:32px;height:32px}
#quest{position:absolute;left:10px;top:88px;max-width:min(300px,60vw);padding:2px 10px 6px;font-size:15px;line-height:1.3;pointer-events:auto;cursor:pointer}
#quest b{font-family:Handjet;font-weight:800;font-size:19px;display:block;color:#7a3e12}
#bossBar{position:absolute;left:50%;transform:translateX(-50%);top:78px;width:min(420px,62vw);padding:0 10px 6px;text-align:center}
#bossBar .h{font-size:20px;color:#7a1e1e}
#bossBar .bar{height:14px}
@media (max-width:520px){#bossBar{top:auto;bottom:220px;width:70vw}}
#banner{position:absolute;left:50%;top:18%;transform:translateX(-50%);font-size:clamp(30px,6vw,52px);color:#fff;text-align:center;white-space:nowrap;
  text-shadow:0 3px 0 #3b2a1a,3px 0 0 #3b2a1a,-3px 0 0 #3b2a1a,0 -3px 0 #3b2a1a,0 6px 0 rgba(0,0,0,.35);opacity:0;transition:opacity .4s}
#banner.show{opacity:1}
#toasts{position:absolute;left:10px;bottom:14px;display:flex;flex-direction:column-reverse;gap:6px;align-items:flex-start;max-width:calc(100% - 200px)}
body.desktop #toasts{bottom:110px}
.toast{display:flex;align-items:center;gap:8px;padding:0 10px;font-size:15px;line-height:1.25;animation:tin .25s}
.toast img{width:28px;height:28px}
@keyframes tin{from{transform:translateY(10px);opacity:0}}

/* ---------- nút hành động ---------- */
#actions{position:fixed;right:12px;bottom:14px;z-index:6;display:grid;grid-template-columns:repeat(2,auto);gap:10px;align-items:end}
.act{position:relative;width:72px;height:72px;padding:0;min-height:0;pointer-events:auto}
.act img{width:40px;height:40px}
.act .key{position:absolute;left:-6px;bottom:-8px;font-family:Handjet;font-weight:800;font-size:14px;background:#3b2a1a;color:#fff3dc;padding:0 5px;border-radius:3px}
.act .cd{position:absolute;inset:-2px;background:conic-gradient(rgba(30,20,10,.65) var(--p,0%),transparent 0);pointer-events:none}
.act .cnt{position:absolute;right:-6px;top:-8px;font-family:Handjet;font-weight:800;font-size:16px;background:var(--red);color:#fff;padding:0 6px;border-radius:3px}
#talkBtn{grid-column:1 / span 2;width:auto;height:60px;font-size:24px}
body.desktop #actions{right:50%;transform:translateX(50%);grid-template-columns:repeat(4,auto)}
/* mobile: cụm nút hình vòng cung ở góc phải dưới */
body:not(.desktop) #actions{display:block;width:190px;height:200px;right:8px;bottom:10px}
body:not(.desktop) #actions .act{position:absolute}
body:not(.desktop) #sk0{right:0;bottom:0;width:86px;height:86px}
body:not(.desktop) #sk0 img{width:48px;height:48px}
body:not(.desktop) #sk1{right:96px;bottom:0}
body:not(.desktop) #potBtn{right:10px;bottom:98px;width:64px;height:64px}
body:not(.desktop) #talkBtn{right:0;bottom:174px;width:auto;height:56px;white-space:nowrap}
body:not(.desktop) .act .key{display:none}
body.desktop #talkBtn{grid-column:auto;order:-1}
#joy{position:fixed;width:120px;height:120px;margin:-60px 0 0 -60px;border-radius:50%;border:4px solid rgba(255,248,225,.5);background:rgba(59,42,26,.25);z-index:4;pointer-events:none}
#joy i{position:absolute;left:50%;top:50%;width:52px;height:52px;margin:-26px 0 0 -26px;border-radius:50%;background:rgba(255,248,225,.75);border:4px solid #3b2a1a}

/* ---------- hộp thoại ---------- */
#dialog{position:fixed;left:50%;bottom:16px;transform:translateX(-50%);width:min(760px,calc(100% - 20px));z-index:20;display:flex;gap:10px;align-items:flex-end}
#dialog .dpor{width:96px;height:96px;flex-shrink:0;display:flex;align-items:center;justify-content:center}
#dialog .dpor img{width:68px;height:68px}
#dialog .dbox{flex:1;padding:6px 14px 10px;min-height:120px;position:relative}
#dialog .dname{font-family:Handjet;font-weight:800;font-size:24px;color:#7a3e12;line-height:1.1}
#dialog .dtext{font-size:18px;line-height:1.5;margin-top:2px}
#dialog .dchoices{display:flex;flex-direction:column;gap:6px;margin-top:10px}
#dialog .dnext{position:absolute;right:12px;bottom:6px;font-family:Handjet;font-weight:800;font-size:16px;color:var(--ink2);animation:blink 1s infinite}
@keyframes blink{50%{opacity:.3}}
@media (max-width:520px){
  #hud .tl{gap:4px;left:6px;top:6px}
  #hud .por{width:52px;height:52px}
  #hud .por img{width:36px;height:36px}
  .bars{min-width:0;width:128px;padding:0 6px 3px}
  .lv{font-size:17px}
  #hud .tr{right:6px;top:6px;gap:4px}
  .res{font-size:19px;padding:0 6px;min-height:44px}
  .res img{width:22px;height:22px}
  .iconbtn{width:48px;height:48px}
  #quest{top:66px;left:6px;max-width:58vw;font-size:13px}
  #quest b{font-size:16px}
  #toasts{max-width:calc(100% - 210px);bottom:12px}
}
@media (max-width:560px){#dialog{flex-direction:column;align-items:stretch}#dialog .dpor{width:64px;height:64px;margin-bottom:-18px;margin-left:6px;z-index:1}#dialog .dpor img{width:44px;height:44px}#dialog .dtext{font-size:17px}}

/* ---------- bảng lớn (menu, cửa hàng...) ---------- */
#overlay{position:fixed;inset:0;z-index:15;background:rgba(28,17,23,.55);display:flex;align-items:center;justify-content:center;padding:10px}
#sheet{width:min(860px,100%);max-height:100%;display:flex;flex-direction:column;padding:4px 6px 8px}
.sh-head{display:flex;align-items:center;gap:8px;padding:2px 2px 8px}
.sh-title{font-size:30px;flex:1;color:#7a3e12}
.tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px}
.tab{font-size:19px;min-height:44px}
.tab.on{border-image-source:url(../assets/ui/btn_green.png);color:#fff}
.sh-body{overflow-y:auto;touch-action:pan-y;padding:2px;flex:1;min-height:0}
.row{display:flex;gap:10px;flex-wrap:wrap}
.col{display:flex;flex-direction:column;gap:8px}
.muted{color:var(--ink2);font-size:15px}
.sec{font-family:Handjet;font-weight:800;font-size:22px;color:#7a3e12;margin:10px 0 4px}

/* ô vật phẩm */
.slot{position:relative;width:64px;height:64px;padding:0;display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;background:#5a3d27;border:3px solid #3b2a1a;box-shadow:inset 0 0 0 2px var(--rc,#7a5a3a),inset 0 4px 0 rgba(0,0,0,.3)}
.slot img{width:40px;height:40px}
.slot.sel{outline:3px solid #fff;outline-offset:1px}
.slot .rar{position:absolute;left:3px;right:3px;bottom:2px;height:5px;background:var(--rc)}
.slot .eq{position:absolute;right:-4px;top:-6px;font-family:Handjet;font-weight:800;font-size:13px;background:var(--green);color:#fff;padding:0 4px;border-radius:3px}
.slot.empty{opacity:.55;cursor:default}
.grid{display:flex;flex-wrap:wrap;gap:6px}
.card{padding:6px 10px;min-width:220px;flex:1}
.card .nm{font-family:Handjet;font-weight:800;font-size:22px;color:var(--rc);text-shadow:0 1px 0 rgba(255,255,255,.4)}
.card .sub{font-size:14px;color:var(--ink2)}
.card .main{font-weight:800;font-size:17px}
.card .aff{font-size:15px;color:#2f6b2a}
.stat{display:grid;grid-template-columns:1fr auto;gap:2px 14px;font-size:15px;padding:6px 10px}
.stat b{font-family:Handjet;font-size:19px}

/* kỹ năng */
.sk{display:flex;gap:10px;padding:6px 10px;align-items:flex-start}
.sk img{width:44px;height:44px;flex-shrink:0}
.sk .t{font-family:Handjet;font-weight:800;font-size:21px}
.sk .d{font-size:14px;color:var(--ink2);line-height:1.35}
.sk.lock{opacity:.55}
.skgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:8px}

/* cửa hàng */
.shop-item{display:flex;align-items:center;gap:10px;padding:4px 10px}
.shop-item .nm{flex:1;font-size:16px}
.shop-item .price{font-family:Handjet;font-weight:800;font-size:20px;display:flex;align-items:center;gap:4px}
.shop-item .price img{width:22px;height:22px}

/* màn hình chính */
#title{position:fixed;inset:0;z-index:25;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:16px;background:linear-gradient(180deg,rgba(28,17,23,.15),rgba(28,17,23,.55))}
.logo{font-size:clamp(52px,12vw,104px);line-height:.9;color:#ffd23f;text-align:center;
  text-shadow:0 5px 0 #3b2a1a,5px 0 0 #3b2a1a,-5px 0 0 #3b2a1a,0 -5px 0 #3b2a1a,5px 5px 0 #3b2a1a,-5px 5px 0 #3b2a1a,0 10px 0 rgba(0,0,0,.3)}
.logo small{display:block;font-size:.34em;color:#fff3dc;margin-top:10px;letter-spacing:1px}
.menu{display:flex;flex-direction:column;gap:10px;width:min(340px,100%)}
.menu .btn{font-size:26px;min-height:58px}
.heroes{display:flex;gap:10px;flex-wrap:wrap;justify-content:center}
.hero{width:200px;padding:6px 10px 10px;text-align:center;cursor:pointer}
.hero img{width:96px;height:96px;margin:0 auto}
.hero .t{font-family:Handjet;font-weight:800;font-size:28px}
.hero .d{font-size:14px;color:var(--ink2);min-height:38px}
.credit{font-size:12px;color:#fff3dc;opacity:.8;text-align:center}
#fade{position:fixed;inset:0;background:#1c1117;z-index:30;opacity:0;pointer-events:none;transition:opacity .25s}
#fade.on{opacity:1}
.vol{display:flex;align-items:center;gap:10px;font-size:17px;margin:8px 0}
.vol input{flex:1;accent-color:#7a3e12;height:28px}
