:root {
  --bg: #1b1f25;
  --bg2: #232830;
  --bg3: #2c323b;
  --edge: #07090b;
  --hi: #3d4550;
  --text: #d6dae0;
  --dim: #8b929c;
  --gold: #e8c060;
  --green: #5ad85a;
  --red: #e04a3a;
  --blue: #4a8ae8;
  --slot: #12151a;
  --font: Verdana, Tahoma, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0c10; color: var(--text); font: 11px var(--font); user-select: none; -webkit-user-select: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; display: block; cursor: default; }
#overlay { position: fixed; inset: 0; pointer-events: none; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.45) 100%); }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
#boot { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; background: #0b0c10; z-index: 100; }
.boot-title { font: bold 54px Georgia, serif; letter-spacing: 10px; color: var(--gold); text-shadow: 0 0 20px rgba(232,192,96,0.5), 3px 3px 0 #000; }
.boot-sub { margin-top: 10px; color: var(--dim); font-size: 13px; }

/* ---- panels ---- */
.panel { background: linear-gradient(180deg, var(--bg2), var(--bg)); border: 1px solid var(--edge); box-shadow: inset 1px 1px 0 var(--hi), inset -1px -1px 0 #101318, 2px 2px 6px rgba(0,0,0,0.5); }
.ptitle { display: flex; align-items: center; gap: 5px; height: 18px; padding: 0 4px; background: linear-gradient(180deg, #313844, #262b33); border-bottom: 1px solid var(--edge); font-weight: bold; color: #e2e6ec; cursor: default; white-space: nowrap; }
.ptitle .ico { width: 13px; height: 13px; image-rendering: pixelated; }
.ptitle .sp { flex: 1; }
.ptitle .pbtn { width: 13px; height: 13px; line-height: 11px; text-align: center; border: 1px solid #0a0c0f; background: #3a414c; color: #c8ccd2; font-size: 10px; cursor: pointer; }
.ptitle .pbtn:hover { background: #4c5562; color: #fff; }
.btn { display: inline-block; padding: 3px 9px; border: 1px solid #0a0c0f; background: linear-gradient(180deg, #48505c, #343a44); color: #e8ecf0; font: bold 11px var(--font); cursor: pointer; box-shadow: inset 1px 1px 0 #5a6370; text-align: center; }
.btn:hover { background: linear-gradient(180deg, #56606e, #3e4550); }
.btn:active { box-shadow: inset 1px 1px 2px #000; }
.btn.gold { background: linear-gradient(180deg, #9a7a2a, #6a521a); box-shadow: inset 1px 1px 0 #c8a040; }
.btn.gold:hover { background: linear-gradient(180deg, #b08a32, #7a5e1e); }
.btn.red { background: linear-gradient(180deg, #8a3028, #5a1e18); box-shadow: inset 1px 1px 0 #b04a3a; }
.btn:disabled, .btn.disabled { opacity: 0.45; pointer-events: none; }
input[type=text], input[type=number], select { background: #0e1115; color: var(--text); border: 1px solid #3a414c; padding: 4px 6px; font: 12px var(--font); outline: none; }
input[type=text]:focus { border-color: var(--gold); }

/* ---- toolbar ---- */
#toolbar { position: absolute; left: 4px; top: 4px; display: flex; gap: 2px; padding: 3px; }
#toolbar .tb { width: 22px; height: 22px; border: 1px solid #0a0c0f; background: linear-gradient(180deg, #3e4652, #2a3038); display: flex; align-items: center; justify-content: center; cursor: pointer; }
#toolbar .tb img { width: 16px; height: 16px; image-rendering: pixelated; }
#toolbar .tb:hover { background: linear-gradient(180deg, #505a68, #363d47); }
#toolbar .tb.on { box-shadow: inset 0 0 0 1px var(--gold); }

/* ---- left stats ---- */
#leftcol { position: absolute; left: 4px; top: 36px; width: 186px; display: flex; flex-direction: column; gap: 3px; }
.statrow { display: flex; align-items: center; gap: 5px; padding: 1px 5px; line-height: 15px; }
.statrow img { width: 12px; height: 12px; image-rendering: pixelated; }
.statrow b { color: #fff; font-weight: normal; }
.xpbar { height: 5px; margin: 2px 6px 4px; background: #000; border: 1px solid #2a3038; }
.xpbar > div { height: 100%; background: linear-gradient(90deg, #2a9ac0, #6ad8f0); }
.pbody { padding: 3px 0; }

/* ---- right column ---- */
#rightcol { position: absolute; right: 4px; top: 4px; width: 196px; display: flex; flex-direction: column; gap: 3px; }
#minimap { display: block; width: 188px; height: 120px; margin: 3px; image-rendering: pixelated; background: #000; border: 1px solid #0a0c0f; cursor: pointer; }
.paperdoll { display: grid; grid-template-columns: repeat(3, 36px); gap: 3px; justify-content: center; padding: 5px 0 2px; position: relative; }
.paperdoll .slot.ph { opacity: 0.5; }
.purse { display: flex; justify-content: space-around; padding: 2px 4px 5px; font-size: 10px; color: var(--dim); }
.purse b { color: var(--gold); font-weight: bold; }
.bag { display: grid; grid-template-columns: repeat(5, 36px); gap: 2px; padding: 4px; justify-content: center; }
.slot { width: 36px; height: 36px; background: var(--slot); border: 1px solid #2a3038; box-shadow: inset 1px 1px 2px #000; position: relative; display: flex; align-items: center; justify-content: center; }
.slot img { width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.slot .cnt { position: absolute; right: 2px; bottom: 0; font-size: 10px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; pointer-events: none; }
.slot .lbl { position: absolute; left: 2px; top: 0; font-size: 9px; color: #aab; text-shadow: 1px 1px 0 #000; pointer-events: none; }
.slot.r1 { border-color: #3a8a3a; } .slot.r2 { border-color: #3a6ad0; } .slot.r3 { border-color: #9040d0; } .slot.r4 { border-color: #e08a20; }
.slot:hover { border-color: var(--gold); }
.slot.drop { box-shadow: inset 0 0 0 2px var(--gold); }
.slot .ghostico { opacity: 0.18; }

/* ---- hotbar & bars ---- */
#bottombar { position: absolute; left: max(50%, 548px); bottom: 6px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; }
#buffs { display: flex; gap: 2px; min-height: 22px; flex-wrap: wrap; justify-content: center; max-width: 420px; }
.buff { width: 22px; height: 22px; border: 1px solid #0a0c0f; position: relative; background: #12151a; }
.buff img { width: 20px; height: 20px; image-rendering: pixelated; }
.buff.debuff { border-color: #a02020; }
.buff .bt { position: absolute; bottom: -1px; left: 0; right: 0; text-align: center; font-size: 8px; color: #fff; text-shadow: 1px 1px 0 #000; }
#hotbar { display: flex; gap: 3px; padding: 4px 6px; }
#hotbar .slot { width: 38px; height: 38px; cursor: pointer; }
#hotbar .slot img { width: 34px; height: 34px; }
.cd { position: absolute; inset: 0; background: rgba(0,0,0,0.65); pointer-events: none; }
.cdtxt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 12px; color: #fff; text-shadow: 1px 1px 0 #000; pointer-events: none; }
.slot.unusable img { filter: grayscale(1) brightness(0.5); }
.slot.nomana img { filter: saturate(0.4) brightness(0.6) sepia(1) hue-rotate(190deg); }
.slot.active { box-shadow: inset 0 0 0 2px #e8e080; }
#vitals { width: 410px; padding: 4px 6px; display: flex; flex-direction: column; gap: 3px; }
.vbar { height: 15px; background: #000; border: 1px solid #0a0c0f; position: relative; box-shadow: inset 0 1px 2px #000; }
.vbar > div { height: 100%; transition: width 0.15s; }
.vbar.hp > div { background: linear-gradient(180deg, #4ae84a, #1a9a1a); }
.vbar.mp > div { background: linear-gradient(180deg, #4a7ae8, #1a3aa8); }
.vbar.xp { height: 6px; }
.vbar.xp > div { background: linear-gradient(90deg, #2a9ac0, #6ad8f0); }
.vbar span { position: absolute; inset: 0; text-align: center; line-height: 14px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; font-size: 11px; }
#castbar { width: 240px; height: 14px; position: absolute; bottom: 150px; left: max(50%, 548px); transform: translateX(-50%); }
#castbar > div { background: linear-gradient(180deg, #f0c040, #b08020); }

/* ---- target frame ---- */
#target { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); width: 240px; padding: 4px 6px 5px; }
#target .tn { font-weight: bold; text-align: center; margin-bottom: 3px; white-space: nowrap; overflow: hidden; }
#target .tsub { font-size: 10px; color: var(--dim); text-align: center; margin-bottom: 3px; }
#target .tbuffs { display: flex; gap: 2px; justify-content: center; margin-top: 3px; }
#target .tbuffs .buff { width: 16px; height: 16px; }
#target .tbuffs .buff img { width: 14px; height: 14px; }

/* ---- chat ---- */
#chat { position: absolute; left: 4px; bottom: 4px; width: 330px; height: 190px; display: flex; flex-direction: column; }
#chat .tabs { display: flex; gap: 1px; padding: 2px 2px 0; }
#chat .tab { padding: 2px 8px; background: #20252c; border: 1px solid #0a0c0f; border-bottom: none; cursor: pointer; color: var(--dim); }
#chat .tab.on { background: #343b46; color: #fff; }
#chatlog { flex: 1; overflow-y: auto; padding: 3px 5px; background: rgba(8,10,13,0.7); border-top: 1px solid #0a0c0f; font-size: 11px; line-height: 14px; user-select: text; -webkit-user-select: text; }
#chatlog::-webkit-scrollbar, .scroll::-webkit-scrollbar { width: 8px; }
#chatlog::-webkit-scrollbar-thumb, .scroll::-webkit-scrollbar-thumb { background: #3a414c; }
#chatin { margin: 2px; border: 1px solid #2a3038; background: #0c0e12; }
.m-sys { color: #e8e8a0; } .m-err { color: #ff7a6a; } .m-loot { color: #b8e0b8; } .m-rare { color: #6ab0ff; } .m-quest { color: #ffd060; } .m-skill { color: #80d8ff; }
.m-say .who { color: #f0c040; } .m-say { color: #f0f0d0; } .m-world { color: #f0a0f0; } .m-npc .who { color: #6af06a; } .m-npc { color: #d8f0d8; } .m-xp { color: #a0c8ff; } .m-combat { color: #c0a0a0; }
.kw { color: #7ad0ff; text-decoration: underline; cursor: pointer; }
.kw:hover { color: #fff; }

/* ---- dialog suggestions ---- */
#suggest { position: absolute; left: 4px; bottom: 198px; width: 330px; max-height: 200px; }
@media (min-width: 1500px) { #suggest { left: 338px; bottom: 4px; width: 240px; } }
#suggest .opts { max-height: 172px; overflow-y: auto; padding: 3px; }
.opt { display: flex; align-items: center; gap: 4px; padding: 3px 5px; cursor: pointer; color: #dfe3e8; border-bottom: 1px solid #252a31; }
.opt:hover { background: #343b46; color: #fff; }
.opt .tag { font-size: 9px; padding: 0 3px; border: 1px solid #0a0c0f; color: #000; font-weight: bold; }
.tag.offer { background: #ffd23a; } .tag.main { background: #ff9a2a; } .tag.ready { background: #6af06a; } .tag.active { background: #8a8a8a; } .tag.trade { background: #7ad0ff; } .tag.topic { background: #c0c0c0; } .tag.bye { background: #604040; color: #fff; }

/* ---- windows ---- */
.win { position: absolute; min-width: 220px; display: flex; flex-direction: column; z-index: 10; }
.win .wbody { padding: 6px; overflow: auto; max-height: 70vh; }
.win.wide .wbody { max-height: 76vh; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.sect { margin: 6px 0 3px; color: var(--gold); font-weight: bold; border-bottom: 1px solid #2c323b; padding-bottom: 2px; }
.row { display: flex; align-items: center; gap: 6px; }
.muted { color: var(--dim); }
.listitem { display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-bottom: 1px solid #252a31; cursor: pointer; }
.listitem:hover { background: #2c323b; }
.listitem.sel { background: #343b46; box-shadow: inset 2px 0 0 var(--gold); }
.listitem img.ic { width: 24px; height: 24px; image-rendering: pixelated; }

.skillgrid { display: grid; grid-template-columns: repeat(3, 150px); gap: 3px; }
.skillcell { display: flex; align-items: center; gap: 5px; padding: 3px; background: #15181d; border: 1px solid #2a3038; }
.skillcell img { width: 24px; height: 24px; image-rendering: pixelated; }
.skillcell .lv { margin-left: auto; font-weight: bold; color: var(--gold); font-size: 12px; }
.skillcell .bar { height: 3px; background: #000; margin-top: 2px; }
.skillcell .bar > div { height: 100%; background: #e8c060; }

.abgrid { display: flex; flex-wrap: wrap; gap: 3px; }
.abicon { width: 34px; height: 34px; border: 1px solid #0a0c0f; cursor: grab; position: relative; }
.abicon img { width: 32px; height: 32px; image-rendering: pixelated; }
.abicon.locked { filter: grayscale(1) brightness(0.45); cursor: default; }
.abicon .req { position: absolute; right: 1px; bottom: 0; font-size: 9px; font-weight: bold; text-shadow: 1px 1px 0 #000; }

.qgoal { padding: 1px 0 1px 10px; }
.qgoal.done { color: var(--green); }
.reward { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 4px; }
.choice { display: flex; gap: 4px; }
.choice .slot { cursor: pointer; }
.choice .slot.sel { box-shadow: inset 0 0 0 2px var(--gold); }

#tooltip { position: fixed; z-index: 50; max-width: 300px; padding: 6px 8px; pointer-events: none; background: rgba(14,16,20,0.97); border: 1px solid #4a525e; box-shadow: 0 2px 10px rgba(0,0,0,0.7); font-size: 11px; line-height: 15px; }
#tooltip .tt-name { font-weight: bold; font-size: 12px; }
#tooltip .tt-sub { color: var(--dim); }
#tooltip .tt-stat { color: #fff; }
#tooltip .tt-green { color: var(--green); }
#tooltip .tt-red { color: #ff6a5a; }
#tooltip .tt-desc { color: #e0c890; font-style: italic; margin-top: 3px; }
#tooltip .tt-set { color: #ffd060; }
#tooltip .tt-dim { color: #6a6f78; }

/* ---- banners ---- */
#banner { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); text-align: center; pointer-events: none; transition: opacity 0.6s; }
#banner .b1 { font: bold 30px Georgia, serif; color: var(--gold); text-shadow: 2px 2px 0 #000, 0 0 16px rgba(0,0,0,0.8); letter-spacing: 2px; }
#banner .b2 { font: 13px Georgia, serif; color: #e8e0c8; text-shadow: 1px 1px 0 #000; margin-top: 4px; }
#toasts { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.toast { font: bold 14px Georgia, serif; text-shadow: 2px 2px 0 #000; animation: toastup 2.6s forwards; }
@keyframes toastup { 0% { opacity: 0; transform: translateY(8px); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }
#gatherbar { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: 220px; padding: 3px; text-align: center; }

#death { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(60,0,0,0.35), rgba(0,0,0,0.75)); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 30; }
#death .t { font: bold 44px Georgia, serif; color: #c03020; text-shadow: 3px 3px 0 #000; }

/* ---- world map ---- */
.zgrid { display: grid; grid-template-columns: repeat(3, 150px); gap: 6px; }
.zcell { height: 70px; border: 1px solid #0a0c0f; padding: 4px; position: relative; background-size: cover; image-rendering: pixelated; cursor: default; }
.zcell .zn { font-weight: bold; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; }
.zcell .zl { font-size: 10px; text-shadow: 1px 1px 0 #000; }
.zcell.here { box-shadow: 0 0 0 2px var(--gold); }
.zcell.unknown { filter: brightness(0.35) grayscale(0.6); }
.zcell .zw { position: absolute; right: 3px; bottom: 2px; font-size: 10px; color: #8ad8ff; text-shadow: 1px 1px 0 #000; }

/* ---- menu ---- */
#menu { position: fixed; inset: 0; z-index: 40; display: flex; align-items: stretch; pointer-events: auto; }
#menu .mleft { width: 360px; margin: 16px; display: flex; flex-direction: column; gap: 8px; }
#menu .logo { font: bold 46px Georgia, serif; letter-spacing: 8px; color: var(--gold); text-shadow: 0 0 18px rgba(232,192,96,0.45), 3px 3px 0 #000; text-align: center; margin: 6px 0 0; }
#menu .tag { text-align: center; color: #c8c0a8; font: italic 13px Georgia, serif; text-shadow: 1px 1px 0 #000; margin-bottom: 6px; }
#menu .charcard { display: flex; align-items: center; gap: 8px; padding: 6px 8px; cursor: pointer; border-bottom: 1px solid #252a31; }
#menu .charcard:hover, #menu .charcard.sel { background: #2c323b; }
#menu .charcard.sel { box-shadow: inset 3px 0 0 var(--gold); }
#menu .mright { margin-left: auto; width: 400px; margin: 16px; max-height: calc(100vh - 32px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.kitgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.kitcard { padding: 5px 6px; border: 1px solid #2a3038; background: #15181d; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.kitcard img { width: 28px; height: 28px; image-rendering: pixelated; }
.kitcard:hover { border-color: #5a6370; }
.kitcard.sel { border-color: var(--gold); background: #2a2a20; }
.swatches { display: flex; gap: 3px; flex-wrap: wrap; }
.sw { width: 18px; height: 18px; border: 1px solid #000; cursor: pointer; }
.sw.sel { box-shadow: 0 0 0 2px var(--gold); }
.trait { display: inline-block; padding: 2px 6px; margin: 2px; border: 1px solid #3a414c; cursor: pointer; background: #15181d; }
.trait.sel { border-color: var(--gold); color: var(--gold); background: #2a2a20; }
.lanworld { display: flex; align-items: center; gap: 6px; padding: 5px; border-bottom: 1px solid #252a31; }

/* ---- controller (ROG Ally / Xbox) ---- */
.gp-focus { outline: 2px solid #ffd860 !important; outline-offset: 1px; box-shadow: 0 0 10px 2px rgba(255, 216, 96, 0.55) !important; position: relative; z-index: 2; }
.gp-held { opacity: 0.55; outline: 2px dashed #7ad0ff !important; }
#padhints { position: fixed; left: 0; right: 0; bottom: 0; height: 20px; z-index: 60; display: flex; gap: 12px; justify-content: center; align-items: center; background: rgba(8, 10, 13, 0.82); border-top: 1px solid #2a3038; color: #c8ccd4; font: 11px Verdana, sans-serif; pointer-events: none; white-space: nowrap; overflow: hidden; }
#padhints span { display: inline-flex; align-items: center; gap: 4px; }
.pb { display: inline-block; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 8px; background: #3a414c; color: #fff; font: bold 10px Verdana; line-height: 16px; text-align: center; }
.pb-a { background: #3a9a3a; } .pb-b { background: #b83a2a; } .pb-x { background: #2a6ac8; } .pb-y { background: #c8a020; color: #222; }
.pb-lb, .pb-rb, .pb-lt, .pb-ls, .pb-rs { border-radius: 4px; background: #5a6270; }
body.gamepad #bottombar { bottom: 26px; }
body.gamepad #chat { bottom: 24px; }
body.gamepad #gl { cursor: none; }
body.gamepad #hotbar .slot .lbl { font-size: 8px; color: #ffe8a0; }

/* ---- touch (phones / tablets) ---- */
#touchhud { position: absolute; inset: 0; pointer-events: none !important; z-index: 5; }
#touchhud > * { pointer-events: auto; }
#joy { position: absolute; left: 28px; bottom: 28px; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, rgba(40,46,56,0.35), rgba(20,24,30,0.55)); border: 2px solid rgba(200,210,230,0.35); touch-action: none; }
#joyknob { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, rgba(240,220,160,0.9), rgba(160,130,60,0.85)); border: 2px solid rgba(0,0,0,0.5); pointer-events: none; }
#tbtns { position: absolute; right: 24px; bottom: 24px; display: grid; grid-template-columns: repeat(3, 70px); gap: 10px; align-items: end; }
.tbtn { width: 70px; height: 70px; border-radius: 50%; background: rgba(30,34,42,0.7); border: 2px solid rgba(200,210,230,0.4); color: #fff; font-size: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; user-select: none; }
.tbtn small { font-size: 10px; color: #c8ccd4; margin-top: 1px; }
.tbtn.big { width: 92px; height: 92px; font-size: 34px; background: rgba(150,110,40,0.75); border-color: rgba(255,220,140,0.7); grid-row: span 2; grid-column: 3; justify-self: end; }
.tbtn.on { transform: scale(0.9); background: rgba(232,192,96,0.8); }
body.touch #chat { display: none; }
body.touch.chat-open #chat { display: flex; bottom: 190px; z-index: 6; }
body.touch #bottombar { left: 50%; }
body.touch #castbar { left: 50%; }
body.touch #tooltip { display: none; }
body.touch #gl { touch-action: none; }
#suggest .dtext { padding: 4px 6px 6px; color: #e8e4d8; line-height: 15px; border-bottom: 1px solid #2c323b; margin-bottom: 2px; user-select: text; }
#suggest .dtext b { color: #6af06a; }

/* ---- controller polish: hotbar glyphs, menus, dialogs ---- */
#hotbar .slot .lbl.padlbl { left: 1px; top: 1px; display: flex; align-items: center; gap: 1px; font-size: 7px; color: #d8dce4; }
#hotbar .slot .lbl.padlbl i { font-style: normal; font-weight: bold; background: rgba(60,66,78,0.9); border-radius: 2px; padding: 0 2px; line-height: 9px; }
#hotbar .slot .lbl.padlbl .pb { min-width: 11px; height: 11px; line-height: 11px; font-size: 8px; padding: 0 1px; border-radius: 6px; }
.pb-dpad { background: #4a5260; border-radius: 3px; }
body.gamepad #hotbar .slot:nth-child(5), body.gamepad #hotbar .slot:nth-child(9) { margin-left: 8px; }
body.pad-rb #hotbar .slot:nth-child(n+5), body.pad-lb #hotbar .slot:nth-child(-n+4), body.pad-lb #hotbar .slot:nth-child(n+9) { opacity: 0.35; }
body.pad-rb #hotbar .slot:nth-child(-n+4), body.pad-lb #hotbar .slot:nth-child(n+5):nth-child(-n+8) { border-color: #ffd860; box-shadow: 0 0 8px rgba(255,216,96,0.6), inset 1px 1px 2px #000; }
#hotbar .slot.pressed { transform: scale(0.9); border-color: #fff; }
body.gamepad #touchhud { display: none; }
body.gamepad.touch #tooltip { display: block; }
body.gamepad.touch #chat { display: flex; }

.modalback { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center; }
.modal { min-width: 300px; max-width: 440px; }
.modal .ptitle { height: 22px; font-size: 12px; }
.modaltext { padding: 12px 14px 6px; font-size: 12px; line-height: 17px; text-align: center; color: #e8e4d8; }
.modal .btn { min-width: 84px; padding: 6px 12px; font-size: 12px; }

.menuhead { display: flex; justify-content: space-between; align-items: center; padding: 2px 2px 8px; margin-bottom: 6px; border-bottom: 1px solid #2c323b; }
.mgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mtile { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px 6px; position: relative; font-size: 11px; }
.mtile img { width: 28px; height: 28px; image-rendering: pixelated; }
.mtile small { position: absolute; right: 3px; top: 2px; font-size: 9px; color: #9aa2ae; font-weight: normal; }

.invwrap { display: flex; gap: 10px; align-items: flex-start; }
.invcol { display: flex; flex-direction: column; }
.paperdoll.big { grid-template-columns: repeat(3, 44px); gap: 4px; padding: 4px 0; }
.bag.big { grid-template-columns: repeat(6, 42px); gap: 3px; padding: 4px 0; justify-content: start; }
.paperdoll.big .slot, .bag.big .slot { width: 42px; height: 42px; }
.paperdoll.big .slot img, .bag.big .slot img { width: 36px; height: 36px; }
.invpurse { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; }
.invpurse div { display: flex; align-items: center; gap: 4px; }
.invpurse img { width: 16px; height: 16px; image-rendering: pixelated; }
.invpurse b { color: var(--gold); }
.invdetail { min-height: 200px; padding: 6px 8px; background: rgba(10,12,16,0.7); border: 1px solid #2a3038; line-height: 15px; font-size: 11px; }
.invdetail .tt-name { font-weight: bold; font-size: 12px; }
.invdetail .tt-sub { color: var(--dim); }
.invdetail .tt-stat { color: #fff; }
.invdetail .tt-green { color: var(--green); }
.invdetail .tt-red { color: #ff6a5a; }
.invdetail .tt-desc { color: #e0c890; font-style: italic; margin-top: 3px; }
.invdetail .tt-set { color: #ffd060; }
.invdetail .tt-dim { color: #6a6f78; }
.qcgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.qcgrid .btn { padding: 6px 4px; }

#epilogue { position: fixed; inset: 0; z-index: 65; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(120,80,20,0.35), rgba(0,0,0,0.8)); animation: epifade 1.2s; }
@keyframes epifade { from { opacity: 0; } to { opacity: 1; } }
#epilogue .epi { width: 460px; max-width: calc(100vw - 32px); padding: 16px 20px; }
#epilogue .epititle { font: bold 32px Georgia, serif; color: var(--gold); text-align: center; letter-spacing: 2px; text-shadow: 0 0 16px rgba(232,192,96,0.5), 2px 2px 0 #000; margin-bottom: 8px; }
#epilogue .epitext { font: 13px Georgia, serif; line-height: 19px; color: #e8e0c8; text-align: center; }
#farewell { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: #0b0c10; font-size: 14px; }
#farewell .logo { font: bold 46px Georgia, serif; letter-spacing: 8px; color: var(--gold); text-shadow: 0 0 18px rgba(232,192,96,0.45), 3px 3px 0 #000; }
body.gamepad #menu .btn, body.gamepad .win .btn { padding: 5px 11px; }

