/* Digits and number punctuation come from a regular system font so numbers stay easy to read;
   everything else uses the pixel font. */
@font-face { font-family: 'Nums'; src: local('Segoe UI Semibold'), local('SegoeUI-Semibold'), local('Roboto Medium'), local('Helvetica Neue Medium'), local('Arial'); font-weight: 400; unicode-range: U+0030-0039, U+002B-002F, U+0025, U+003A, U+00D7; }
@font-face { font-family: 'Nums'; src: local('Segoe UI Bold'), local('SegoeUI-Bold'), local('Roboto Bold'), local('Helvetica Neue Bold'), local('Arial Bold'), local('Arial'); font-weight: 600 900; unicode-range: U+0030-0039, U+002B-002F, U+0025, U+003A, U+00D7; }
:root {
  --wood: #6b4128;
  --wood2: #8a5a35;
  --edge: #3a2214;
  --cream: #fff3dc;
  --gold: #ffd36a;
  --green: #7dffb0;
  --red: #ff6a5a;
  --ui: 'Nums', 'Pixelify Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2f8fdc; font-family: var(--ui); color: var(--cream); user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: var(--ui); cursor: pointer; }
input { font-family: var(--ui); user-select: text; -webkit-user-select: text; }

.box { background: rgba(58, 34, 20, 0.88); border: 3px solid var(--edge); box-shadow: inset 0 0 0 2px var(--wood2), 0 3px 0 rgba(0, 0, 0, 0.3); border-radius: 8px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#stats { position: absolute; left: calc(10px + env(safe-area-inset-left)); top: calc(10px + env(safe-area-inset-top)); width: 230px; padding: 8px 10px; }
#stats .row1 { display: flex; justify-content: space-between; font-size: 16px; margin-bottom: 4px; }
#stats .row1 span { color: var(--gold); }
#stats .row2 { display: flex; gap: 12px; font-size: 14px; margin-top: 4px; }
#stats .row2 #online { margin-left: auto; opacity: 0.7; font-size: 12px; }
.bar { position: relative; height: 14px; background: #24140b; border-radius: 4px; overflow: hidden; margin: 3px 0; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: #888; transition: width 0.2s; }
.bar span { position: relative; display: block; text-align: center; font-size: 11px; line-height: 14px; text-shadow: 0 1px 0 #000; }
.bar.hp i { background: linear-gradient(#ff7a6a, #d8402f); }
.bar.xp i { background: linear-gradient(#8ae8ff, #3fa2e8); }
#zone { position: absolute; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top)); padding: 6px 14px; font-size: 15px; display: flex; gap: 10px; align-items: center; white-space: nowrap; }
#zone .safe { color: var(--green); font-size: 12px; }
#zone .pvp { color: #ffb36a; font-size: 12px; }
#zone .cl { color: #b9e3ff; font-size: 12px; }
#bossbar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(58px + env(safe-area-inset-top)); width: min(480px, 64vw); text-align: center; pointer-events: none !important; }
#bossbar .bn { font-size: 17px; font-weight: 700; color: #ffcfc6; text-shadow: 0 2px 0 #000, 0 0 4px #000; margin-bottom: 2px; }
#bossbar .bb { position: relative; height: 22px; background: #1d0f08; border: 3px solid var(--edge); border-radius: 6px; overflow: hidden; box-shadow: 0 3px 0 rgba(0,0,0,.35); }
#bossbar .bb i, #bossbar .bb .trail { position: absolute; left: 0; top: 0; bottom: 0; }
#bossbar .bb i { background: linear-gradient(#ff6a5a, #c42a1e 60%, #8a1810); transition: width 0.15s; }
#bossbar .bb .trail { background: #ffe0a0; transition: width 0.7s ease-in 0.35s; }
#bossbar .bv { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
/* Bosses use the big bar at the top instead of a floating label. */
.tag.boss { visibility: hidden; }
#minimap { position: absolute; right: calc(10px + env(safe-area-inset-right)); top: calc(10px + env(safe-area-inset-top)); width: 150px; height: 150px; border: 3px solid var(--edge); border-radius: 8px; box-shadow: inset 0 0 0 2px var(--wood2), 0 3px 0 rgba(0,0,0,.3); cursor: pointer; image-rendering: pixelated; }
#menu { position: absolute; right: calc(10px + env(safe-area-inset-right)); top: calc(170px + env(safe-area-inset-top)); display: grid; grid-auto-flow: column; grid-template-rows: repeat(6, auto); gap: 6px; direction: rtl; }
#menu > * { direction: ltr; }
#menu button { width: 58px; height: 52px; background: var(--wood); border: 3px solid var(--edge); border-radius: 8px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.25); color: var(--cream); font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; padding: 0; }
#menu button span { font-size: 10px; margin-top: 3px; }
#menu button:active { transform: translateY(2px); box-shadow: none; }

#chat { position: absolute; left: calc(10px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); width: min(420px, 44vw); pointer-events: none !important; }
#chatlog { max-height: 180px; overflow-y: auto; font-size: 14px; scrollbar-width: none; }
#chatlog::-webkit-scrollbar { display: none; }
.cm { padding: 2px 6px; text-shadow: 0 1px 0 #000, 0 0 3px #000; transition: opacity 0.6s; word-wrap: break-word; }
.cm.old { opacity: 0; }
.cm .tt { color: #6fc3ff; } .cm .pm { color: #ffb3ff; } .cm b.adm { color: #ffb3ff; }
#chatin { display: none; width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 6px; border: 3px solid var(--edge); background: rgba(36, 20, 11, 0.92); color: var(--cream); font-size: 15px; outline: none; pointer-events: auto; }
#chat.open #chatin { display: block; }
#chat.open { pointer-events: auto !important; }
#chat.open #chatlog { background: rgba(36, 20, 11, 0.55); border-radius: 6px; pointer-events: auto; }
#chat.open .cm.old { opacity: 1; }

.round { position: absolute; border-radius: 50%; border: 3px solid var(--edge); background: var(--wood); color: var(--cream); box-shadow: inset 0 -5px 0 rgba(0,0,0,.25), 0 3px 0 rgba(0,0,0,.3); display: flex; align-items: center; justify-content: center; padding: 0; }
.round:active { transform: translateY(2px); }
#actbtn { right: calc(22px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom)); width: 84px; height: 84px; font-size: 36px; background: #b8492f; }
#potbtn { right: calc(118px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 56px; height: 56px; font-size: 24px; }
#potbtn span { position: absolute; right: -4px; bottom: -4px; background: var(--edge); border-radius: 8px; font-size: 12px; padding: 1px 5px; }
#chatbtn { display: none; left: calc(14px + env(safe-area-inset-left)); bottom: calc(176px + env(safe-area-inset-bottom)); width: 44px; height: 44px; font-size: 20px; }
#joy { display: none; position: absolute; left: calc(26px + env(safe-area-inset-left)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 130px; height: 130px; border-radius: 50%; background: rgba(36, 20, 11, 0.35); border: 3px solid rgba(255, 243, 220, 0.35); touch-action: none; }
#joyknob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 243, 220, 0.75); border: 3px solid var(--edge); pointer-events: none; }
.ph button, #pbody button { background: #c98a3c; color: #2a170c; border: 2px solid var(--edge); border-radius: 6px; padding: 6px 12px; font-size: 14px; font-weight: 600; box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }
#pbody button:active { transform: translateY(1px); }
#toasts { position: absolute; left: 50%; transform: translateX(-50%); top: calc(96px + env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none !important; }
.toast { background: rgba(36, 20, 11, 0.9); border: 2px solid var(--edge); border-radius: 6px; padding: 5px 12px; font-size: 15px; animation: pop 0.2s ease-out; }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } }

/* Labels over entities */
#labels, #floats { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; text-align: center; white-space: nowrap; font-size: 13px; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
.tag .nm small { color: var(--gold); }
.tag .tt { color: #6fc3ff; }
.tag.pl .nm { color: #fff; }
.tag.me .nm { color: #ffe46b; }
.tag .hpb { display: none; width: 46px; height: 5px; margin: 2px auto 0; background: #300; border: 1px solid #000; }
.tag .hpb i { display: block; height: 100%; background: #ff4a3a; }
.tag.pl .hpb i { background: #4ade80; }
.tag.hurt .hpb { display: block; }
.float { position: absolute; left: 0; top: 0; font-size: 17px; font-weight: 700; white-space: nowrap; text-shadow: 0 2px 0 #000, 0 0 3px #000; }
.float.dmg { color: #fff; } .float.crit { color: #ffd23f; font-size: 22px; } .float.hurt { color: #ff5a4a; }
.float.gain { color: #e8ffe0; font-size: 15px; } .float.xp { color: #8ae8ff; font-size: 14px; } .float.coin { color: var(--gold); font-size: 15px; } .float.rare { color: #ffb3ff; font-size: 20px; }
.float .ic { width: auto; height: auto; background: none; box-shadow: none !important; font-size: inherit; }

/* Panels */
#panel { position: fixed; z-index: 10; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 20px)); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: #f4dfb8; color: #3a2214; border: 4px solid var(--edge); border-radius: 10px; box-shadow: inset 0 0 0 3px #c98a3c, 0 8px 0 rgba(0,0,0,.35); }
.ph { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--wood); color: var(--cream); font-size: 20px; font-weight: 700; border-radius: 5px 5px 0 0; }
.ph button { padding: 2px 10px !important; }
#pbody { overflow-y: auto; padding: 10px 12px 14px; font-size: 15px; user-select: text; }
#pbody h4 { margin: 12px 0 6px; font-size: 16px; color: var(--wood); }
#pbody .hint { color: #6b4a33; font-size: 13px; margin: 6px 0; }
#pbody .warn { background: #ffd9b0; border: 2px solid #c98a3c; border-radius: 6px; padding: 6px 8px; font-size: 13px; }
#pbody button:disabled { opacity: 0.45; cursor: default; }
#pbody button.wide { width: 100%; margin-top: 6px; padding: 9px; }
#pbody button.danger { background: #d8584a; color: #fff; }
#pbody input { padding: 7px 9px; border: 2px solid var(--edge); border-radius: 6px; font-size: 15px; background: #fff8ea; flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; }
.ic { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; background: #3a2214; font-size: 17px; line-height: 1; vertical-align: middle; flex-shrink: 0; }
.ic.big { width: 40px; height: 40px; font-size: 24px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.detail { display: flex; gap: 10px; align-items: center; margin-top: 10px; padding: 8px; background: #ead0a0; border-radius: 8px; }
.detail .acts { margin-left: auto; display: flex; gap: 6px; }
.gears { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.gear { display: flex; gap: 8px; align-items: center; background: #ead0a0; border-radius: 8px; padding: 6px; }
.gear small { display: block; font-size: 11px; color: #6b4a33; }
.gear b { font-size: 13px; }
.statline { margin: 8px 0; font-size: 14px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button { background: #e3c48f !important; }
.tabs button.near { color: #1f6b2f !important; }
.tabs button.on { background: #c98a3c !important; outline: 2px solid var(--edge); }
.rec { display: flex; gap: 10px; align-items: center; padding: 7px; margin-bottom: 6px; border-radius: 8px; background: #ead0a0; opacity: 0.75; }
.rec.ok { opacity: 1; }
.rec .rm { flex: 1; min-width: 0; }
.rec .rm small { display: block; color: #6b4a33; font-size: 12px; }
.rec .rm small.own { display: inline; margin-left: 6px; color: #1f6b2f; }
.rec .rm small.n { color: #b8321f; }
.rec .rb { display: flex; flex-direction: column; gap: 4px; }
.ings { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 3px 0; }
.ing { font-size: 13px; display: inline-flex; align-items: center; gap: 3px; }
.ing .ic { width: 20px; height: 20px; font-size: 12px; }
.ing.n { color: #b8321f; } .ing.y { color: #1f6b2f; }
.slider { display: flex; gap: 10px; align-items: center; }
.slider input { flex: 1; }
#pbody .bar { background: #c9a87a; height: 10px; }
#pbody .bar i { background: #3fbf5f; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #999; margin: 0 6px; }
.dot.on { background: #3fbf5f; }
table.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
table.keys td { padding: 3px 4px; border-bottom: 1px solid #d9bd8c; }
table.keys td:first-child { font-weight: 700; white-space: nowrap; }
#bigmap { display: block; margin: 0 auto; max-width: 100%; border: 3px solid var(--edge); border-radius: 6px; image-rendering: pixelated; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; justify-content: center; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 4px; border: 1px solid #3a2214; }

/* Login */
#login { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, rgba(47,143,220,.2), rgba(20,50,90,.75)); }
.lbox { width: min(360px, calc(100vw - 32px)); padding: 22px; text-align: center; background: #f4dfb8; color: #3a2214; border: 4px solid var(--edge); border-radius: 12px; box-shadow: inset 0 0 0 3px #c98a3c, 0 8px 0 rgba(0,0,0,.35); }
.lbox h1 { margin: 0; font-size: 44px; color: #2f8fdc; text-shadow: 3px 3px 0 var(--edge); letter-spacing: 1px; }
.lbox .tag { position: static; white-space: normal; text-shadow: none; font-size: 14px; color: #6b4a33; margin: 6px 0 14px; }
.lbox input { display: block; width: 100%; margin: 8px 0; padding: 11px; font-size: 17px; border: 3px solid var(--edge); border-radius: 8px; background: #fff8ea; }
#lbtns { display: flex; gap: 8px; margin-top: 10px; }
#lbtns button { flex: 1; padding: 11px; font-size: 16px; font-weight: 700; background: #3fbf5f; color: #fff; border: 3px solid var(--edge); border-radius: 8px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.2); }
#lbtns button.alt { background: #c98a3c; color: #2a170c; }
#lbtns.busy { opacity: 0.5; pointer-events: none; }
#lerr { color: #b8321f; min-height: 18px; margin: 8px 0 0; font-size: 14px; }
.lbox .small { font-size: 12px; color: #6b4a33; margin: 4px 0 0; }
#dead { position: fixed; inset: 0; z-index: 15; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(90, 0, 0, 0.45); font-size: 40px; font-weight: 700; text-shadow: 0 3px 0 #000; pointer-events: none; }
#dead small { font-size: 18px; }
#conn { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 30; padding: 10px 18px; background: rgba(36, 20, 11, 0.9); border: 3px solid var(--edge); border-radius: 8px; font-size: 18px; }

/* Touch devices */
@media (pointer: coarse) {
  #joy, #chatbtn { display: block; }
  #chatbtn { display: flex; }
  #chat { bottom: calc(230px + env(safe-area-inset-bottom)); width: min(340px, 60vw); }
  #chat.open { bottom: calc(10px + env(safe-area-inset-bottom)); }
  #chatlog { max-height: 110px; font-size: 13px; }
}
@media (max-width: 700px) {
  #stats { width: 170px; padding: 6px 8px; }
  #stats .row2 #online { display: none; }
  #stats .row1 { font-size: 14px; }
  #minimap { width: 104px; height: 104px; }
  #menu { top: calc(122px + env(safe-area-inset-top)); gap: 4px; }
  #menu button { width: 46px; height: 42px; font-size: 17px; }
  #menu button span { display: none; }
  #zone { top: auto; bottom: calc(176px + env(safe-area-inset-bottom)); font-size: 13px; padding: 4px 10px; flex-direction: column; gap: 0; }
  #bossbar { top: calc(176px + env(safe-area-inset-top)); width: 92vw; }
  #toasts { top: calc(236px + env(safe-area-inset-top)); width: 70vw; }
}
@media (max-height: 500px) {
  #menu { flex-direction: row; flex-wrap: wrap; top: auto; right: calc(124px + env(safe-area-inset-right)); bottom: calc(96px + env(safe-area-inset-bottom)); width: 200px; justify-content: flex-end; }
  #minimap { width: 90px; height: 90px; }
  #zone { bottom: auto; top: calc(8px + env(safe-area-inset-top)); flex-direction: row; gap: 8px; }
  #chat { bottom: calc(150px + env(safe-area-inset-bottom)); }
}

/* ---- Hotbar, stamina, clock ---- */
.bar.st { height: 6px; }
.bar.st i { background: linear-gradient(#ffe46b, #e0a020); transition: width 0.08s; }
#stats.blocking .bar.st i { background: linear-gradient(#d9dde3, #8d939b); }
#clock { font-size: 12px; opacity: 0.9; }
#hotbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 5px; padding: 5px; background: rgba(58, 34, 20, 0.85); border: 3px solid var(--edge); border-radius: 10px; }
#hotbar .slot { width: 52px; height: 52px; background: #5a3826; }
#hotbar .held { position: absolute; left: 50%; bottom: 100%; transform: translateX(-50%); margin-bottom: 4px; white-space: nowrap; font-size: 13px; text-shadow: 0 1px 0 #000, 0 0 3px #000; pointer-events: none; }
#menu button.on { background: #b8492f; outline: 2px solid var(--gold); }

/* ---- Slots (shared by hotbar and panels) ---- */
.slot { position: relative; height: 54px; border-radius: 6px; background: #e3c48f; border: 2px solid var(--edge); display: flex; align-items: center; justify-content: center; touch-action: none; cursor: grab; user-select: none; }
.slot.empty { background: #d6b47c; cursor: default; }
#hotbar .slot.empty { background: #4a2e1f; }
.slot .ph { font-size: 10px; color: rgba(58, 34, 20, 0.55); text-align: center; line-height: 1.1; }
#hotbar .slot .ph { color: rgba(255, 243, 220, 0.35); font-size: 14px; }
.slot.cur { outline: 3px solid var(--gold); outline-offset: 1px; }
.slot.sel { box-shadow: 0 0 0 3px #fff; }
.slot.out { width: 64px; height: 64px; }
.slot .ic { width: 38px; height: 38px; font-size: 22px; pointer-events: none; }
.slot .n { position: absolute; right: 3px; bottom: 1px; font-size: 12px; color: #fff; text-shadow: 0 1px 0 #000, 0 0 2px #000; pointer-events: none; }
.grid.g5 { grid-template-columns: repeat(5, 1fr); }
.grid.g6 { grid-template-columns: repeat(6, 1fr); }
.ghost { position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.ghost .ic { width: 44px; height: 44px; font-size: 26px; opacity: 0.9; }
.ghost .n { position: absolute; right: 0; bottom: 0; font-size: 13px; color: #fff; text-shadow: 0 1px 0 #000; }

/* ---- Inventory / container panels ---- */
.invtop { display: flex; gap: 12px; align-items: flex-start; }
.equip { display: grid; grid-template-columns: repeat(5, 54px); gap: 6px; }
.eqrow { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.eqrow .slot { width: 54px; }
.eqrow small { font-size: 10px; color: #6b4a33; }
.charstats { flex: 1; font-size: 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.dim { color: #8a6a4a; font-weight: 400; }
#pbody .acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.detail .dinfo { flex: 1; min-width: 0; }
.split { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 140px; }
.split input { flex: 1; }
.furnace { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 10px; background: #ead0a0; border-radius: 10px; }
.fcol { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 60px; }
.fcol .slot { width: 56px; }
.flame { width: 44px; height: 8px; background: #6b4a33; border-radius: 4px; overflow: hidden; }
.flame i { display: block; height: 100%; background: linear-gradient(90deg, #ff5a2a, #ffd36a); }
.farrow { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 26px; color: #6b4a33; }
.fbar { width: 70px; height: 10px; background: #c9a87a; border-radius: 5px; overflow: hidden; }
.fbar i { display: block; height: 100%; background: #3fbf5f; }
.rbrow { flex-direction: row !important; flex-wrap: wrap; justify-content: flex-end; }
#pbody .rbrow button { padding: 4px 8px; font-size: 12px; }

/* ---- Combat feedback ---- */
.tag.warn .nm::before, .tag.stun .nm::before { content: ''; display: inline-block; width: 1em; height: 1em; margin-right: 3px; vertical-align: -0.12em; background: url(/emoji/2757.svg) center / contain no-repeat; }
.tag.stun .nm::before { background-image: url(/emoji/1f4ab.svg); }
.tag.warn .nm { color: #ffb3a8; animation: blink 0.18s infinite alternate; }
@keyframes blink { to { opacity: 0.55; } }
.float.parry { color: #ffe46b; font-size: 24px; }
.float.txt { font-size: 15px; }
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 5; }
#flash.go { animation: flash 0.35s ease-out; }
@keyframes flash { from { opacity: 0.35; } to { opacity: 0; } }
#blockbtn { right: calc(118px + env(safe-area-inset-right)); bottom: calc(96px + env(safe-area-inset-bottom)); width: 56px; height: 56px; font-size: 24px; }
#dashbtn { right: calc(34px + env(safe-area-inset-right)); bottom: calc(124px + env(safe-area-inset-bottom)); width: 56px; height: 56px; font-size: 24px; }
@media (pointer: fine) { #blockbtn, #dashbtn, #actbtn, #potbtn { display: none; } }

/* ---- Emoji images (Twemoji) ---- */
img.emo { width: 1.15em; height: 1.15em; vertical-align: -0.2em; pointer-events: none; }
.ic img.emo { width: 72%; height: 72%; vertical-align: middle; }
/* Floating "+3 🪵" pickups: icon matches the text size. */
.float .ic img.emo, .float img.emo { width: 1.1em; height: 1.1em; vertical-align: -0.2em; }
#menu button img.emo { width: 22px; height: 22px; }
.round img.emo { width: 55%; height: 55%; }

/* ---- Mana, abilities, class choice, broadcasts ---- */
.bar.mp i { background: linear-gradient(#8ab8ff, #4a6fe0); }
#abil { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom)); display: flex; gap: 6px; }
#abil:empty { display: none; }
.ab { position: relative; width: 48px; height: 48px; padding: 0; border-radius: 10px; border: 3px solid var(--edge); background: #4a2e6a; box-shadow: inset 0 -4px 0 rgba(0,0,0,.3); color: #fff; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.ab img.emo { width: 28px; height: 28px; position: relative; z-index: 1; }
.ab .cdw { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, 0.6); z-index: 2; pointer-events: none; }
.ab .k { position: absolute; left: 3px; top: 1px; font-size: 10px; z-index: 3; text-shadow: 0 1px 0 #000; }
.ab .mc { position: absolute; right: 2px; bottom: 1px; font-size: 10px; color: #9fc4ff; z-index: 3; text-shadow: 0 1px 0 #000; }
.ab.nomana { filter: grayscale(0.8) brightness(0.7); }
.ab.locked { filter: grayscale(1) brightness(0.55); }
.ab .lk { position: absolute; right: 1px; bottom: 0; font-size: 10px; z-index: 3; color: #fff; text-shadow: 0 1px 0 #000; }
.ab .lk img.emo { width: 10px; height: 10px; }

/* ---- Crafting ---- */
.craftui { display: flex; gap: 8px; min-height: 340px; }
.ctabs { display: flex; flex-direction: column; gap: 4px; width: 118px; flex-shrink: 0; }
#pbody .ctabs button { display: flex; align-items: center; gap: 6px; padding: 5px 7px; text-align: left; background: #e3c48f; font-size: 13px; position: relative; }
#pbody .ctabs button.on { background: #c98a3c; outline: 2px solid var(--edge); }
.ctabs button em { font-style: normal; flex: 1; }
.ctabs button i { font-style: normal; font-size: 11px; background: #3fbf5f; color: #fff; border-radius: 8px; padding: 0 5px; }
.cmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; border: 2px solid var(--edge); }
.chip.y { background: #b8f0c4; } .chip.n { background: #ead0a0; color: #8a6a4a; }
#pbody .cbar .tog { margin-left: auto; padding: 3px 8px; font-size: 12px; background: #e3c48f; }
#pbody .cbar .tog.on { background: #8fd99f; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 5px; align-content: start; max-height: 210px; overflow-y: auto; padding: 2px; }
#pbody .ctile { position: relative; height: 52px; padding: 0; background: #e3c48f; display: flex; align-items: center; justify-content: center; }
#pbody .ctile .ic { width: 38px; height: 38px; font-size: 22px; pointer-events: none; }
#pbody .ctile .n { position: absolute; right: 2px; bottom: 0; font-size: 11px; color: #fff; text-shadow: 0 1px 0 #000; }
#pbody .ctile.ok { background: #b8f0c4; }
#pbody .ctile.miss, #pbody .ctile.far { opacity: 0.55; }
#pbody .ctile.sel { outline: 3px solid #fff; box-shadow: 0 0 0 5px var(--edge); opacity: 1; }
.cdetail { display: flex; gap: 10px; align-items: flex-start; padding: 8px; background: #ead0a0; border-radius: 8px; }
.cdi { flex: 1; min-width: 0; }
.cdi > small { display: block; color: #6b4a33; font-size: 12px; margin-top: 2px; }
.cdi small.n { color: #b8321f; }
@media (max-width: 560px) {
  .craftui { flex-direction: column; }
  .ctabs { flex-direction: row; flex-wrap: wrap; width: auto; }
  .ctabs button em { display: none; }
  .cdetail { flex-wrap: wrap; }
}

/* ---- Skill tree ---- */
.skhead { display: flex; gap: 10px; align-items: center; padding: 8px; background: #ead0a0; border-radius: 8px; }
.skhead .cicon img.emo { width: 36px; height: 36px; }
.skhead small { display: block; font-size: 12px; color: #6b4a33; }
.skhead .pts { margin-left: auto; text-align: center; background: #3a2214; color: var(--gold); border-radius: 8px; padding: 4px 10px; }
.skhead .pts b { font-size: 22px; display: block; }
.skhead .pts small { color: var(--cream); }
.sktree { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sktier h5 { margin: 4px 0; text-align: center; font-size: 14px; color: var(--wood); }
.sknode { background: #fff3dc; border: 2px solid #c9a87a; border-radius: 8px; padding: 6px; margin-bottom: 6px; font-size: 12px; }
.sknode.abil { border-color: #8a5cff; }
.sknode.done { background: #d8f5dc; border-color: #3fbf5f; }
.sknode.part { background: #f3f0c8; border-color: #c9a24a; }
.sknode.can { box-shadow: 0 0 0 2px var(--gold); }
.sknode.lock { opacity: 0.6; }
.skt { display: flex; gap: 6px; align-items: center; }
.skt small { display: block; color: #8a6a4a; font-size: 11px; }
.ski img.emo { width: 24px; height: 24px; }
.sknode p { margin: 4px 0; color: #4a3020; line-height: 1.3; }
.skok { color: #1f6b2f; font-weight: 700; font-size: 12px; }
.skwhy { color: #8a6a4a; font-size: 11px; }
#pbody .sknode button { width: 100%; padding: 4px; font-size: 12px; }
@media (max-width: 560px) { .sktree { grid-template-columns: 1fr; } }

/* ---- Quests & achievements ---- */
.quest { padding: 8px; margin-bottom: 8px; background: #ead0a0; border-radius: 8px; border: 2px solid transparent; }
.quest.done { border-color: #3fbf5f; background: #d8f5dc; }
.quest.claimed { opacity: 0.6; }
.quest .qt { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.quest .qt small { color: #6b4a33; white-space: nowrap; }
#pbody .quest .bar, #pbody .ach .bar { height: 14px; margin: 5px 0; }
#pbody .quest .bar span, #pbody .ach .bar span { font-size: 10px; line-height: 14px; color: #fff; }
#pbody .quest button { width: 100%; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; margin-top: 8px; }
.ach { padding: 6px; background: #ead0a0; border-radius: 8px; font-size: 13px; opacity: 0.75; }
.ach.ok { opacity: 1; background: #f6e3b0; border: 2px solid #c9a24a; }
.ach small { display: block; color: #6b4a33; font-size: 11px; }
#pbody .ach button { width: 100%; margin-top: 4px; padding: 3px; font-size: 12px; }
.ttl { color: #ffd36a; font-size: 0.85em; }
#pbody .ttl { color: #a8731f; }

/* ---- Trading ---- */
.tradebox { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tside { background: #ead0a0; border-radius: 8px; padding: 6px; border: 2px solid transparent; min-height: 110px; }
.tside.ready { border-color: #3fbf5f; background: #d8f5dc; }
.tside h4 { margin: 0 0 6px !important; }
.titem { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 0; }
.titem .ic { width: 24px; height: 24px; font-size: 14px; }
#pbody .titem button { padding: 1px 7px; font-size: 12px; margin-left: auto; }
.titem .tbtns { margin-left: auto; display: flex; gap: 3px; }
.tinv { max-height: 200px; overflow-y: auto; background: #ead0a0; border-radius: 8px; padding: 6px; }
#pbody #tready.on { background: #8fd99f; }
#pbody .tside input { width: 90px; flex: 0 1 auto; }
.lbrow button { padding: 2px 8px !important; font-size: 12px !important; }

/* ---- Prompt, chat bubbles, elites ---- */
#prompt { position: fixed; left: 50%; top: calc(110px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 22; display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-size: 15px; }
#prompt button { background: #3fbf5f; color: #fff; border: 2px solid var(--edge); border-radius: 6px; padding: 5px 12px; font-weight: 700; }
#prompt button.alt { background: #c98a3c; color: #2a170c; }
.tag .bub { max-width: 220px; white-space: normal; margin: 0 auto 4px; padding: 4px 8px; background: rgba(255, 248, 234, 0.95); color: #3a2214; border: 2px solid var(--edge); border-radius: 8px; font-size: 12px; text-shadow: none; line-height: 1.25; }
.tag .elite { color: #ffd36a; }
#bossbar.enraged .bb { box-shadow: 0 0 12px #ff3b2f, 0 3px 0 rgba(0,0,0,.35); }
#bossbar .enr { color: #ff8a5a; font-size: 13px; animation: blink 0.4s infinite alternate; }
.packh { display: flex; align-items: center; justify-content: space-between; }
#pbody .packh button { padding: 2px 10px; font-size: 12px; margin-left: 4px; }
@media (max-width: 560px) { .tradebox { grid-template-columns: 1fr; } }

/* ---- Leaderboard ---- */
.lb { display: flex; flex-direction: column; gap: 4px; }
.lbrow { display: flex; gap: 10px; align-items: center; padding: 6px 10px; background: #ead0a0; border-radius: 8px; font-size: 14px; }
.lbrow.me { outline: 2px solid var(--gold); background: #f6e3b0; }
.lbrow .rk { width: 26px; text-align: center; font-weight: 700; }
.lbrow b { flex: 1; }
.lbrow .lc { font-size: 12px; color: #6b4a33; }
.lbrow .lv { font-weight: 700; color: var(--wood); min-width: 48px; text-align: right; }
.ab:active { transform: translateY(2px); }
#classpick { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; background: rgba(15, 30, 60, 0.7); padding: 12px; }
.cpbox { width: min(820px, 100%); max-height: 100%; overflow-y: auto; padding: 16px; background: #f4dfb8; color: #3a2214; border: 4px solid var(--edge); border-radius: 12px; box-shadow: inset 0 0 0 3px #c98a3c, 0 8px 0 rgba(0,0,0,.35); text-align: center; }
.cpbox h2 { margin: 0 0 4px; font-size: 28px; }
.cpbox .hint { font-size: 13px; color: #6b4a33; margin: 0 0 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 10px; border: 3px solid var(--edge); border-radius: 10px; background: #fff3dc; color: #3a2214; font-family: var(--ui); text-align: left; box-shadow: inset 0 -5px 0 var(--cc); }
.card:hover { transform: translateY(-3px); box-shadow: inset 0 -5px 0 var(--cc), 0 6px 0 rgba(0,0,0,.15); }
.card .cicon img.emo { width: 44px; height: 44px; }
.card b { font-size: 20px; color: var(--cc); text-shadow: 1px 1px 0 var(--edge); }
.card ul { margin: 0; padding-left: 18px; font-size: 13px; align-self: stretch; }
.card .abl { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; font-size: 12px; }
.card .abl span { background: #ead0a0; border-radius: 6px; padding: 2px 6px; }
#bcast { position: fixed; left: 50%; top: 30%; transform: translate(-50%, -50%); z-index: 18; width: min(90vw, 900px); text-align: center; font-size: clamp(28px, 5vw, 56px); font-weight: 700; color: #ffe46b; text-shadow: 0 4px 0 #3a2214, 0 0 12px rgba(0,0,0,.6); pointer-events: none; opacity: 0; }
#bcast.go { animation: bcast 5.5s ease-out forwards; }
@keyframes bcast { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); } 8% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 12% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
.mapctl { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
#pbody .mapctl button { min-width: 36px; padding: 4px 10px; font-size: 16px; }
#bigmap { touch-action: none; cursor: grab; }

@media (pointer: coarse) {
  #abil { bottom: calc(258px + env(safe-area-inset-bottom)); }
  #hotbar { bottom: calc(176px + env(safe-area-inset-bottom)); }
  #hotbar .slot { width: 46px; height: 46px; }
  #chat { bottom: calc(316px + env(safe-area-inset-bottom)); }
}
@media (max-width: 700px) {
  #zone { bottom: auto; top: calc(124px + env(safe-area-inset-top)); left: calc(10px + env(safe-area-inset-left)); transform: none; }
  .invtop { flex-direction: column; }
  .equip { grid-template-columns: repeat(5, 1fr); width: 100%; }
  .eqrow .slot { width: 100%; }
  #hotbar .slot { width: 42px; height: 42px; }
}

/* ---- Character sheet (inventory) ---- */
.charsheet { display: grid; grid-template-columns: auto 150px auto 1fr; gap: 10px; align-items: center; }
.eqcol { display: flex; flex-direction: column; gap: 6px; }
.eqcol .slot { width: 54px; }
.pmodel { position: relative; width: 150px; height: 190px; border-radius: 10px; background: radial-gradient(circle at 50% 40%, #fff3dc, #d6b47c); border: 2px solid var(--edge); box-shadow: inset 0 -12px 18px rgba(58, 34, 20, 0.25); }
.pmodel canvas { display: block; width: 150px; height: 190px; }
.pmodel .pname { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; font-size: 12px; color: #6b4a33; pointer-events: none; }
.charsheet .charstats { grid-template-columns: 1fr; align-self: stretch; align-content: center; }
table.binds td { padding: 2px 4px; }
#pbody button.key { min-width: 90px; padding: 3px 10px; font-family: var(--ui); }
#pbody button.key.wait { background: #ffe46b; animation: blink 0.5s infinite alternate; }
@media (max-width: 560px) {
  .charsheet { grid-template-columns: auto 1fr auto; }
  .pmodel { width: 100%; }
  .pmodel canvas { margin: 0 auto; }
  .charsheet .charstats { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
}

/* ---- Tool icons, Town Hall, Collection ---- */
.ic img.emo.tool { width: 92%; height: 92%; image-rendering: auto; }
.float img.emo.tool { width: 1.3em; height: 1.3em; }
.tag.thtag { font-size: 13px; color: #ffe08a; font-weight: bold; line-height: 1.25; }
.tag.thtag .bt { color: #9fe3ff; font-weight: normal; font-size: 12px; }
.chip.th { background: #f0d890; }
#pbody .ctile.lock { opacity: 0.45; filter: grayscale(0.7); }
#pbody .ctile .lk { position: absolute; left: 2px; top: 1px; font-size: 10px; color: #fff; text-shadow: 0 1px 0 #000; }
#pbody .ctile .lk img.emo { width: 10px; height: 10px; }
.thhead { display: flex; gap: 12px; align-items: center; padding: 8px; background: #ead0a0; border-radius: 8px; margin-bottom: 8px; }
.thhead > div { display: flex; flex-direction: column; gap: 2px; }
.thlv { display: flex; flex-direction: column; align-items: center; min-width: 62px; padding: 4px 6px; background: #6b4a33; color: #ffe08a; border-radius: 8px; border: 2px solid var(--edge); }
.thlv b { font-size: 28px; line-height: 1; }
.thlv small { font-size: 10px; color: #f4e2c0; }
.thbuild { padding: 8px; background: #d8ecf5; border-radius: 8px; margin-bottom: 8px; }
#pbody .bar.big { height: 20px; margin: 6px 0; }
#pbody .bar.big span { font-size: 12px; line-height: 20px; color: #fff; }
.thcost { display: flex; flex-direction: column; gap: 5px; margin: 6px 0; }
.throw { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #ead0a0; border-radius: 8px; }
.throw.ok { background: #b8f0c4; }
.throw .thi { flex: 1; min-width: 0; font-size: 13px; }
#pbody .throw .bar { height: 12px; }
#pbody .throw .bar span { font-size: 10px; line-height: 12px; color: #fff; }
.throw small { font-size: 11px; white-space: nowrap; }
.throw small.y { color: #2f7d3a; font-weight: bold; }
.thlevels { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 5px; }
.thlevels > div { padding: 5px 8px; background: #ead0a0; border-radius: 8px; font-size: 13px; opacity: 0.7; display: flex; flex-direction: column; }
.thlevels > div.ok { background: #b8f0c4; opacity: 1; }
.thlevels small { font-size: 11px; }
.colgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 5px; margin-bottom: 6px; }
#pbody .coltile { position: relative; height: 48px; padding: 0; background: #c9a87a; display: flex; align-items: center; justify-content: center; }
#pbody .coltile .ic { width: 38px; height: 38px; font-size: 22px; pointer-events: none; box-shadow: none !important; background: transparent; }
#pbody .coltile .ic img { filter: brightness(0) opacity(0.4); }
#pbody .coltile.got { background: #b8f0c4; }
#pbody .coltile.got .ic img { filter: none; }
#pbody .coltile.rare.got { background: #f6dc8a; box-shadow: inset 0 0 0 2px #c9a24a; }
#pbody .coltile.sel { outline: 3px solid #fff; box-shadow: 0 0 0 5px var(--edge); }
.coldetail { display: flex; gap: 10px; align-items: center; padding: 8px; background: #ead0a0; border-radius: 8px; margin: 6px 0 10px; }
.coldetail > div { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.coldetail small { font-size: 12px; }

/* =========================================================================
   UI v2: polished panels, HUD player frame, tooltips, health bars, loot.
   ========================================================================= */
:root { --hbb: 12px; --slot: 52px; --panel-w: 720px; --parch: #f6e4c0; --parch2: #ecd2a2; --ink: #3a2214; --gold2: #ffcf55; }
@media (pointer: coarse) { :root { --hbb: 176px; --slot: 46px; } }
@media (max-width: 700px) { :root { --slot: 42px; } }

/* Shared boxes */
.box { background: linear-gradient(180deg, rgba(64, 38, 22, 0.92), rgba(40, 23, 13, 0.92)); border: 2px solid #1e1009; box-shadow: inset 0 0 0 2px rgba(201, 138, 60, 0.45), inset 0 1px 0 3px rgba(255, 220, 160, 0.06), 0 4px 10px rgba(0, 0, 0, 0.35); border-radius: 10px; }

/* Player frame */
#stats { width: 262px; padding: 8px 10px 7px; --cc: #c98a3c; }
#stats .pf { display: flex; gap: 9px; align-items: center; }
#stats .pfa { position: relative; flex: 0 0 52px; height: 52px; border-radius: 50%; background: radial-gradient(circle at 40% 30%, #6a4a30, #22130a 75%); border: 3px solid var(--cc); box-shadow: 0 0 0 2px #1e1009, inset 0 -6px 10px rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; }
#stats .pfa img.emo { width: 30px; height: 30px; }
#stats .pfa b { position: absolute; right: -6px; bottom: -5px; min-width: 24px; height: 22px; padding: 0 5px; border-radius: 11px; background: linear-gradient(#ffe08a, #d9a030); color: #2a170c; border: 2px solid #1e1009; font-size: 13px; line-height: 18px; text-align: center; }
#stats .pfm { flex: 1; min-width: 0; }
#stats .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; font-size: 15px; margin: 0 0 3px; }
#stats .row1 b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#stats .row1 span { color: var(--gold); font-size: 11px; opacity: 0.9; white-space: nowrap; }
#stats .row2 { gap: 12px; font-size: 13px; margin-top: 6px; padding-top: 5px; border-top: 1px solid rgba(255, 220, 160, 0.12); }
.bar { border-radius: 6px; background: #1a0d06; box-shadow: inset 0 2px 3px rgba(0,0,0,.6); }
.bar span { font-weight: 600; letter-spacing: 0.2px; }
#stats .bar.hp { height: 17px; margin: 2px 0 3px; }
#stats .bar.hp span { line-height: 17px; font-size: 11px; }
.bar.hp i { background: linear-gradient(#ff8a78, #e0442f 55%, #a82418); box-shadow: inset 0 1px 0 rgba(255,255,255,.35); transition: width 0.15s; }
.bar.hp .trail { position: absolute; left: 0; top: 0; bottom: 0; background: #ffe2b0; transition: width 0.6s ease-in 0.3s; }
.bar.hp::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(0,0,0,.28) calc(10% - 1px) 10%); pointer-events: none; }
#stats.low .bar.hp { animation: lowhp 0.9s infinite alternate; }
@keyframes lowhp { to { box-shadow: inset 0 2px 3px rgba(0,0,0,.6), 0 0 8px 2px rgba(255, 60, 40, 0.75); } }
#stats .bar.mp { height: 11px; } #stats .bar.mp span { line-height: 11px; font-size: 9px; }
.bar.mp i { background: linear-gradient(#9cc4ff, #4a6fe0 60%, #2f4bb0); }
#stats .bar.st { height: 5px; margin-top: 3px; }

/* Crypt status (under the player frame) */
#dgbox { position: absolute; left: calc(10px + env(safe-area-inset-left)); top: calc(118px + env(safe-area-inset-top)); width: 262px; padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
#dgbox b { font-weight: 600; }
#dgbox span { color: #c9b28a; white-space: nowrap; }
#dgbox.open { border-color: #2a7a70; box-shadow: inset 0 0 0 2px rgba(127, 232, 216, 0.55), 0 0 14px rgba(127, 232, 216, 0.45); animation: dgpulse 1.2s infinite alternate; }
#dgbox.open span { color: #9ff0e6; }
#dgbox.in { box-shadow: inset 0 0 0 2px rgba(127, 232, 216, 0.4), 0 4px 10px rgba(0,0,0,.35); }
#dgbox.in span { color: #c8fff6; }
@keyframes dgpulse { to { box-shadow: inset 0 0 0 2px rgba(127, 232, 216, 0.9), 0 0 22px rgba(127, 232, 216, 0.7); } }

/* Zone banner, minimap, menu */
#zone { padding: 5px 14px; border-radius: 20px; font-size: 14px; }
#minimap { border: 2px solid #1e1009; border-radius: 12px; box-shadow: inset 0 0 0 2px rgba(201,138,60,.5), 0 4px 10px rgba(0,0,0,.4); background: #16202e; image-rendering: auto; }
#menu { top: calc(172px + env(safe-area-inset-top)); gap: 5px; }
#menu button { position: relative; width: 56px; height: 50px; background: linear-gradient(180deg, #7a4c2e, #5a361f); border: 2px solid #1e1009; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255, 210, 150, 0.18), inset 0 -4px 0 rgba(0,0,0,.25), 0 3px 6px rgba(0,0,0,.3); transition: transform 0.08s, background 0.12s; }
#menu button:hover { background: linear-gradient(180deg, #8f5c38, #6a4026); transform: translateY(-1px); }
#menu button .mk { position: absolute; left: 3px; top: 2px; font-style: normal; font-size: 9px; line-height: 1; color: #ffe08a; opacity: 0.85; }
@media (pointer: coarse) { #menu button .mk { display: none; } }

/* Hotbar, XP bar, quick heal */
#hotbar { bottom: calc(var(--hbb) + env(safe-area-inset-bottom)); gap: 5px; padding: 5px; background: linear-gradient(180deg, rgba(64,38,22,.94), rgba(36,20,11,.94)); border: 2px solid #1e1009; border-radius: 12px; box-shadow: inset 0 0 0 2px rgba(201,138,60,.4), 0 4px 10px rgba(0,0,0,.35); }
#hotbar .slot { width: var(--slot); height: var(--slot); }
#hotbar .held { bottom: calc(100% + 14px); font-size: 13px; font-weight: 600; }
#xpbar { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(var(--hbb) + env(safe-area-inset-bottom) + var(--slot) + 16px); width: calc(var(--slot) * 5 + 34px); height: 9px; margin: 0; border: 2px solid #1e1009; border-radius: 6px; }
#xpbar i { background: linear-gradient(#a6f0ff, #3fa2e8 60%, #2a78c0); box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
#xpbar span { position: absolute; inset: -1px 0 0; font-size: 9px; line-height: 9px; opacity: 0; transition: opacity 0.15s; }
#xpbar:hover { height: 14px; } #xpbar:hover span { opacity: 1; line-height: 14px; font-size: 10px; }
#abil { bottom: calc(var(--hbb) + env(safe-area-inset-bottom) + var(--slot) + 44px); }
#quick { position: absolute; left: calc(50% + var(--slot) * 2.5 + 30px); bottom: calc(var(--hbb) + env(safe-area-inset-bottom)); width: calc(var(--slot) + 16px); height: calc(var(--slot) + 16px); border-radius: 12px; background: linear-gradient(180deg, rgba(64,38,22,.94), rgba(36,20,11,.94)); border: 2px solid #1e1009; box-shadow: inset 0 0 0 2px rgba(201,138,60,.4), 0 4px 10px rgba(0,0,0,.35); overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer; }
#quick .qic img { width: 34px; height: 34px; display: block; }
#quick .qk { position: absolute; left: 5px; top: 3px; font-size: 10px; color: #ffe08a; }
#quick .qn { position: absolute; right: 5px; bottom: 2px; font-size: 13px; font-weight: 700; text-shadow: 0 1px 0 #000, 0 0 3px #000; }
#quick.empty { opacity: 0.55; filter: grayscale(0.8); }
#quick .cdw, #potbtn .cdw, .slot .cdw { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(10, 6, 3, 0.62); pointer-events: none; }
#potbtn { overflow: hidden; }
@media (pointer: coarse) { #quick { display: none; } }

/* Slots and icons */
.slot { border: 2px solid #2a170c; background: radial-gradient(circle at 50% 35%, #ead09c, #d2ae74); box-shadow: inset 0 -3px 0 rgba(0,0,0,.12), inset 0 1px 0 rgba(255,255,255,.35); transition: transform 0.06s, box-shadow 0.12s; }
.slot.empty { background: radial-gradient(circle at 50% 35%, #d9ba84, #c7a26a); box-shadow: inset 0 2px 4px rgba(0,0,0,.18); }
#hotbar .slot { background: radial-gradient(circle at 50% 35%, #6a4630, #3e2516); }
#hotbar .slot.empty { background: radial-gradient(circle at 50% 35%, #4a2f1e, #2e1a0e); }
.slot:not(.empty):hover { box-shadow: inset 0 0 0 2px rgba(255, 226, 150, 0.8), 0 0 8px rgba(255, 210, 120, 0.45); }
.slot.cur { outline: 3px solid var(--gold2); outline-offset: 1px; box-shadow: 0 0 10px rgba(255, 207, 85, 0.55); }
.slot.rare { box-shadow: inset 0 0 0 2px #ff8cf0, 0 0 8px rgba(255, 140, 240, 0.5); }
.slot .n { font-weight: 700; font-size: 12px; }
.ic { background: radial-gradient(circle at 50% 30%, #5a3a24, #24140b 80%); border-radius: 7px; box-shadow: inset 0 0 0 1px rgba(255,220,160,.12); }
.ic.gear { box-shadow: inset 0 0 0 2px var(--rc, #888), inset 0 -8px 12px rgba(0,0,0,.35); }
.ic.rare { box-shadow: inset 0 0 0 2px #ff8cf0, 0 0 6px rgba(255, 140, 240, 0.6); }
.ic img.emo.gi { width: 84%; height: 84%; filter: drop-shadow(0 1px 1px rgba(0,0,0,.45)); }
.float .ic img.emo.gi { width: 1.25em; height: 1.25em; }
#pbody .ctile .ic, #pbody .coltile .ic { width: 40px; height: 40px; }

/* Panels: one fixed size so they never jump around */
#panel { width: min(var(--panel-w), calc(100vw - 20px)); height: min(660px, calc(100vh - 32px)); height: min(660px, calc(100dvh - 32px)); max-height: none; background: linear-gradient(180deg, var(--parch), var(--parch2)); border: 3px solid #1e1009; border-radius: 14px; box-shadow: inset 0 0 0 3px #c98a3c, inset 0 0 0 5px rgba(255, 240, 210, 0.35), 0 14px 36px rgba(0,0,0,.5); animation: panelin 0.14s ease-out; }
@keyframes panelin { from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); } }
.ph { padding: 9px 12px 9px 16px; background: linear-gradient(180deg, #7a4c2e, #4e2e19); border-bottom: 2px solid #1e1009; border-radius: 11px 11px 0 0; font-size: 19px; color: #ffe8b8; text-shadow: 0 2px 0 rgba(0,0,0,.45); box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.25); }
.ph #ptitle img.emo { width: 22px; height: 22px; margin-right: 2px; }
.ph button#pclose { width: 32px; height: 32px; padding: 0 !important; border-radius: 50%; background: linear-gradient(#e0705e, #b8402f); color: #fff; font-size: 16px; border: 2px solid #1e1009; }
.ph button#pclose:hover { filter: brightness(1.12); }
#pbody { flex: 1; min-height: 0; padding: 12px 14px 16px; scrollbar-width: thin; scrollbar-color: #b88a52 transparent; }
#pbody::-webkit-scrollbar { width: 9px; } #pbody::-webkit-scrollbar-thumb { background: #b88a52; border-radius: 6px; border: 2px solid var(--parch2); }
#pbody h4 { font-size: 15px; letter-spacing: 0.3px; color: #6b3f22; border-bottom: 1px solid rgba(107, 63, 34, 0.18); padding-bottom: 3px; }
.ph button, #pbody button { background: linear-gradient(180deg, #e7ae62, #c4842f); color: #2a170c; border: 2px solid #2a170c; border-radius: 8px; box-shadow: inset 0 1px 0 rgba(255,255,255,.35), inset 0 -3px 0 rgba(0,0,0,.18), 0 2px 0 rgba(0,0,0,.15); transition: filter 0.1s, transform 0.06s; }
#pbody button:hover:not(:disabled) { filter: brightness(1.08); }
#pbody button.danger { background: linear-gradient(180deg, #e8705e, #c24434); color: #fff; }
.rec, .detail, .cdetail, .quest, .ach, .throw, .thhead, .coldetail, .lbrow, .tside, .tinv { background: rgba(255, 246, 226, 0.55); box-shadow: inset 0 0 0 1px rgba(107, 63, 34, 0.18); }
.detail { min-height: 64px; }
.tabs button.on, #pbody .ctabs button.on { background: linear-gradient(180deg, #ffd27a, #e0a24a) !important; }
#pbody .ctabs button { background: rgba(255, 246, 226, 0.6); box-shadow: inset 0 0 0 1px rgba(107, 63, 34, 0.25); }
.cgrid { max-height: none; flex: 1; min-height: 120px; }
.craftui { min-height: 0; height: 100%; }
#panel[data-p="craft"] #pbody { display: flex; flex-direction: column; overflow: hidden; }
#panel[data-p="craft"] .craftui { flex: 1; min-height: 0; }
#panel[data-p="craft"] .cmain { min-height: 0; }
#panel[data-p="craft"] .cgrid { overflow-y: auto; }
#pbody .ctile { background: radial-gradient(circle at 50% 35%, #ead09c, #d2ae74); }
#pbody .ctile.ok { background: radial-gradient(circle at 50% 35%, #d6f7dc, #a6e2b2); }
#pbody .ctile:hover { filter: brightness(1.06); }

/* Map */
#panel[data-p="map"] #pbody { display: flex; flex-direction: column; align-items: center; overflow: hidden; }
#bigmap { max-width: none; border: 2px solid #1e1009; border-radius: 10px; box-shadow: 0 0 0 2px #c98a3c, 0 4px 12px rgba(0,0,0,.35); image-rendering: auto; background: #16202e; }
.mapctl { align-self: stretch; }
.mapinfo { margin-left: auto; font-size: 12px; color: #6b4a33; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend { margin-top: 6px; }
.maphint { margin: 4px 0 0 !important; }

/* Tooltip */
#tip { position: fixed; left: 0; top: 0; z-index: 60; max-width: 300px; min-width: 150px; padding: 9px 11px; pointer-events: none; color: #f6ead2; background: linear-gradient(180deg, rgba(38, 24, 14, 0.97), rgba(24, 14, 8, 0.97)); border: 2px solid #120904; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255, 207, 85, 0.35), 0 8px 22px rgba(0,0,0,.55); font-size: 13px; line-height: 1.35; }
#tip .tth { display: flex; gap: 9px; align-items: center; }
#tip .tth b { font-size: 15px; display: block; }
#tip .tth small { color: #b8a080; font-size: 11px; }
#tip .ttn { color: #cdb88f; font-size: 12px; }
#tip .ttl2 { margin-top: 7px; padding-top: 6px; border-top: 1px solid rgba(255,220,160,.14); }
#tip .ttl2 b { color: #ffe08a; }
#tip .ttd { margin: 6px 0 0; color: #d8c7a6; font-style: italic; font-size: 12px; }
#tip .ttd.src { font-style: normal; color: #ffb35a; }
#tip .ttf { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; padding-top: 5px; border-top: 1px solid rgba(255,220,160,.14); color: var(--gold); font-size: 12px; }
#tip .tthint { margin: 6px 0 0; color: #8f7a5a; font-size: 11px; }
#tip .up { color: #7dffb0; } #tip .down { color: #ff8a7a; } #tip .dim { color: #9a8a6a; }
#tip .ttxt b { color: #ffe08a; }
#tip .kbd { display: inline-block; padding: 0 6px; margin-left: 4px; border-radius: 4px; background: #4a2e1c; border: 1px solid #120904; color: #ffe08a; font-size: 11px; }
#tip img.emo { width: 1.1em; height: 1.1em; }

/* Name tags and health bars over heads */
.tag .hpb { position: relative; width: 58px; height: 7px; margin: 3px auto 0; background: #2a0b08; border: 1px solid #0c0503; border-radius: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.6); overflow: hidden; }
.tag .hpb b, .tag .hpb i { position: absolute; left: 0; top: 0; bottom: 0; display: block; }
.tag .hpb b { background: #ffe2b0; transition: width 0.55s ease-in 0.25s; }
.tag .hpb i { height: auto; background: linear-gradient(#ff8a78, #d8402f 60%, #9a2216); box-shadow: inset 0 1px 0 rgba(255,255,255,.35); transition: width 0.12s; }
.tag.pl .hpb i { background: linear-gradient(#9cf5b4, #3fbf5f 60%, #278a40); }
.tag.mate .hpb i { background: linear-gradient(#a8dcff, #4a9fe0 60%, #2a6fb0); }
.tag .hpb.low i { animation: blink 0.4s infinite alternate; }
.tag .hpb::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(20% - 1px), rgba(0,0,0,.35) calc(20% - 1px) 20%); }
.tag.me .hpb { display: block; width: 64px; height: 8px; }
.tag.me .nm { color: #ffe46b; font-size: 12px; }
.tag .nm { font-weight: 600; }
.tag .nm small { font-size: 10px; }

/* Loot chests */
.tag.loottag { font-size: 12px; color: #fff3dc; font-weight: 600; line-height: 1.25; }
.tag.loottag .lt { color: #c9b28a; font-weight: 400; }
.tag.loottag .lc { color: #ffe08a; animation: blink 0.6s infinite alternate; }
.tag.loottag.white { color: #ffffff; text-shadow: 0 0 6px #ffd36a, 0 1px 0 #000; }
.tag.loottag.rare { color: #ffc4ff; }
.loothead { display: flex; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; background: rgba(255, 246, 226, 0.6); box-shadow: inset 0 0 0 1px rgba(107, 63, 34, 0.2); margin-bottom: 10px; }
.loothead.white { background: linear-gradient(135deg, #fffdf4, #f6e7b8); box-shadow: inset 0 0 0 2px #e0b040, 0 0 12px rgba(255, 207, 85, 0.45); }
.loothead .lchest img.emo { width: 40px; height: 40px; }
.loothead small { display: block; color: #6b4a33; font-size: 12px; margin-top: 2px; }
.lootgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.lootrow { display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; background: rgba(255, 246, 226, 0.6); box-shadow: inset 0 0 0 1px rgba(107, 63, 34, 0.18); }
.lootrow.rare { background: linear-gradient(135deg, #fff0ff, #f3d4f6); box-shadow: inset 0 0 0 2px #e080e0, 0 0 10px rgba(255, 140, 240, 0.45); }
.lootrow .rm { flex: 1; min-width: 0; }
.lootrow .rm small { display: block; color: #6b4a33; font-size: 11px; }
#pbody .lootrow button { padding: 4px 10px; font-size: 12px; }

/* Boss results */
#bossres { position: fixed; left: 50%; top: 16%; transform: translateX(-50%); z-index: 19; width: min(420px, 92vw); padding: 12px 16px 12px; color: #fff3dc; background: linear-gradient(180deg, rgba(48, 30, 16, 0.95), rgba(26, 15, 8, 0.95)); border: 2px solid #120904; border-radius: 14px; box-shadow: inset 0 0 0 2px rgba(255, 207, 85, 0.55), 0 12px 30px rgba(0,0,0,.55); cursor: pointer; }
#bossres.go { animation: brin 0.35s cubic-bezier(.2,1.4,.4,1); }
@keyframes brin { from { opacity: 0; transform: translateX(-50%) scale(0.8); } }
#bossres .brh { text-align: center; font-size: 20px; font-weight: 700; color: #ffd36a; text-shadow: 0 2px 0 #000; margin-bottom: 8px; }
#bossres .brr { display: grid; grid-template-columns: 28px minmax(60px, 1fr) 1.3fr auto; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 8px; font-size: 14px; }
#bossres .brr.me { background: rgba(255, 207, 85, 0.16); box-shadow: inset 0 0 0 1px rgba(255, 207, 85, 0.5); }
#bossres .md img.emo { width: 22px; height: 22px; }
#bossres .brr b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bossres .brbar { height: 8px; border-radius: 4px; background: #1a0d06; overflow: hidden; }
#bossres .brbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb02e, #ffe08a); }
#bossres .brd { font-size: 13px; white-space: nowrap; } #bossres .brd small { color: #b8a080; }
#bossres .brme { margin-top: 8px; text-align: center; font-size: 14px; color: #ffe08a; }
#bossres .brhint { text-align: center; font-size: 12px; color: #b8a080; margin-top: 2px; }

/* Help credits, misc */
#pbody .credits { margin-top: 14px; font-size: 11px; opacity: 0.8; }
#pbody .credits a { color: #6b3f22; }
.toast { background: linear-gradient(180deg, rgba(48, 30, 16, 0.95), rgba(28, 16, 9, 0.95)); border: 2px solid #120904; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(255, 207, 85, 0.3), 0 4px 10px rgba(0,0,0,.35); }
#bossbar .bb { border-radius: 8px; border: 2px solid #120904; box-shadow: inset 0 0 0 1px rgba(255, 207, 85, 0.35), 0 4px 10px rgba(0,0,0,.4); }

@media (max-width: 700px) {
  #stats { width: 200px; }
  #stats .pf { gap: 7px; }
  #stats .pfa { flex-basis: 40px; height: 40px; } #stats .pfa img.emo { width: 22px; height: 22px; }
  #dgbox { width: 200px; top: calc(104px + env(safe-area-inset-top)); font-size: 11px; padding: 4px 8px; }
  #panel { height: calc(100dvh - 20px); }
  #menu { top: calc(124px + env(safe-area-inset-top)); }
}
@media (max-height: 500px) { #dgbox { display: none; } }
/* Slot placeholders share the .ph class name with the panel header: undo the header look. */
.slot .ph { display: block; background: none; border: 0; box-shadow: none; padding: 0; border-radius: 0; text-shadow: none; font-size: 10px; font-weight: 600; color: rgba(58, 34, 20, 0.5); }
#hotbar .slot .ph { color: rgba(255, 243, 220, 0.35); font-size: 14px; }
/* Square slots at a fixed size, centred, instead of stretching across the panel. */
#pbody .grid.g6 { grid-template-columns: repeat(6, 62px); justify-content: center; }
#pbody .grid.g5 { grid-template-columns: repeat(5, 62px); justify-content: center; }
#pbody .grid .slot { height: 62px; }
#pbody .grid .slot .ic { width: 42px; height: 42px; }
@media (max-width: 560px) { #pbody .grid.g6 { grid-template-columns: repeat(6, 1fr); } #pbody .grid.g5 { grid-template-columns: repeat(5, 1fr); } #pbody .grid .slot { height: 52px; } }
.ctabs { width: 142px; }
#pbody .ctabs button { font-size: 12.5px; padding: 5px 6px; }
.ctabs button em { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 700px) { #zone { top: calc(134px + env(safe-area-inset-top)); } }
@media (max-width: 700px) and (max-height: 500px) { #zone { top: calc(8px + env(safe-area-inset-top)); } }

/* ---- Inventory: two columns so everything fits without scrolling ---- */
.invwrap { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.invleft { display: flex; flex-direction: column; gap: 8px; }
.invleft .charsheet { grid-template-columns: auto 150px auto; gap: 8px; }
.invleft .charstats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 12.5px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 246, 226, 0.55); box-shadow: inset 0 0 0 1px rgba(107, 63, 34, 0.18); }
.invleft .charstats .dim { grid-column: 1 / -1; }
.invleft .eqcol .slot, .invleft .eqrow .slot { width: 52px; height: 52px; }
.invright h4.packh, .invright h4 { margin-top: 0 !important; }
.invright h4:last-of-type { margin-top: 8px !important; }
#pbody .invright .grid.g6 { grid-template-columns: repeat(6, 52px); justify-content: start; gap: 5px; }
#pbody .invright .grid.g5 { grid-template-columns: repeat(5, 52px); justify-content: start; gap: 5px; }
#pbody .invright .grid .slot { height: 52px; }
#pbody .invright .grid .slot .ic { width: 38px; height: 38px; }
#panel[data-p="inv"] .detail, #panel[data-p="inv"] .dtl { margin-top: 10px; }
@media (max-width: 700px) { .invwrap { grid-template-columns: 1fr; } #pbody .invright .grid.g6, #pbody .invright .grid.g5 { justify-content: center; } }

/* ---- Creative menu ---- */
.crtop { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.crtop .tabs { margin: 0; }
.crtop input { flex: 1; min-width: 140px; }
.crgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 4px; max-height: 210px; overflow-y: auto; margin-top: 8px; padding: 4px; border-radius: 8px; background: rgba(58, 34, 20, 0.12); }
#pbody .crgrid .ctile { height: 46px; }
#pbody .crgrid .ctile .ic { width: 36px; height: 36px; }
#pbody .crgrid .ctile.rare { box-shadow: inset 0 0 0 2px #e080e0; }
.crbag { display: flex; gap: 12px; align-items: flex-start; }
.crside { display: flex; flex-direction: column; gap: 8px; align-items: center; padding-top: 26px; }
.slot.trash { width: 56px; height: 56px; font-size: 26px; background: radial-gradient(circle at 50% 35%, #e8a090, #b8584a) !important; cursor: default; }
#panel[data-p="creative"] #pbody .grid.g6 { grid-template-columns: repeat(6, 50px); justify-content: start; }
#panel[data-p="creative"] #pbody .grid.g5 { grid-template-columns: repeat(5, 50px); justify-content: start; }
#panel[data-p="creative"] #pbody .grid .slot { height: 50px; }

/* ---- Dungeon list (under the player frame) ---- */
#dgbox { flex-direction: column; align-items: stretch; gap: 2px; padding: 6px 10px; }
#dgbox .dgrow { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; opacity: 0.85; }
#dgbox .dgrow.top { font-size: 13px; opacity: 1; }
#dgbox .dgrow b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dgbox .dgrow.open span, #dgbox .dgrow.open em { color: #9ff0e6; font-style: normal; font-weight: 700; }
#dgbox .dgrow.locked { opacity: 0.55; }
#dgbox .dgrow small { color: #9a8a6a; font-size: 11px; }
@media (max-width: 700px) { #dgbox .dgrow:not(.top) { display: none; } }
#panel[data-p="creative"] #pbody { display: flex; flex-direction: column; overflow: hidden; }
#panel[data-p="creative"] .crgrid { flex: 1; max-height: none; min-height: 96px; }
#panel[data-p="creative"] #pbody h4 { margin: 6px 0 4px; }
#panel[data-p="creative"] #pbody .grid.g6 { grid-template-columns: repeat(6, 44px); gap: 4px; }
#panel[data-p="creative"] #pbody .grid.g5 { grid-template-columns: repeat(5, 44px); gap: 4px; }
#panel[data-p="creative"] #pbody .grid .slot { height: 44px; }
#panel[data-p="creative"] #pbody .grid .slot .ic { width: 32px; height: 32px; }
#panel[data-p="creative"] .crbag { flex-shrink: 0; }
#panel[data-p="creative"] .hint { margin: 4px 0; }

/* ---- Backpack slots you haven't bought yet ---- */
.slot.locked { background: repeating-linear-gradient(45deg, #b89868, #b89868 6px, #a8885a 6px, #a8885a 12px) !important; opacity: 0.6; cursor: default; flex-direction: column; font-size: 16px; color: #3a2214; }
.slot.locked.next { opacity: 1; cursor: pointer; box-shadow: inset 0 0 0 2px #ffcf33; }
.slot.locked.next:hover { filter: brightness(1.1); }
.slot.locked small { font-size: 10px; font-weight: 700; color: #2a170c; }

/* ---- Tutorial ---- */
#tutbox { position: absolute; left: 50%; transform: translateX(-50%); top: calc(52px + env(safe-area-inset-top)); width: min(420px, 90vw); padding: 8px 14px; display: flex; flex-direction: column; gap: 3px; text-align: center; box-shadow: inset 0 0 0 2px rgba(255, 228, 107, 0.7), 0 0 16px rgba(255, 228, 107, 0.4); }
#tutbox b { color: #ffe46b; font-size: 13px; }
#tutbox span { font-size: 15px; }
#tutbox .bar { height: 6px; margin: 3px 0 0; }
#tutbox .bar i { background: linear-gradient(#ffe46b, #e0a020); }
@media (max-width: 700px) { #tutbox { top: auto; bottom: calc(320px + env(safe-area-inset-bottom)); } }

/* ---- Wheel of Fortune ---- */
.wheelwrap { position: relative; width: 300px; height: 300px; margin: 4px auto 8px; }
.wheelwrap canvas { display: block; width: 300px; height: 300px; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); }
.wheelptr { position: absolute; left: 50%; top: -12px; transform: translateX(-50%); font-size: 30px; color: #e04848; text-shadow: 0 2px 0 #2a170c; }
#pbody #spinbtn.on { background: linear-gradient(#8fe0a0, #3fbf5f); color: #102a14; font-size: 16px; }
.prizes { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 8px; font-size: 12px; }
.prizes span { padding: 2px 8px; border-radius: 10px; background: rgba(255, 246, 226, 0.6); box-shadow: inset 0 0 0 1px rgba(107, 63, 34, 0.25); }
.prizes span.jack { background: #1e1430; color: #ffe46b; }

/* ---- Shop cosmetics / wardrobe, settings ---- */
.ic.cosic { box-shadow: inset 0 0 0 2px var(--cc), 0 0 8px var(--cc) !important; }
.wardrow { display: flex; flex-wrap: wrap; gap: 6px; }
#pbody .wardrow button.on { background: linear-gradient(#8fe0a0, #3fbf5f); }
.setgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.bindgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 4px 14px; }
.bindrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 6px; background: rgba(255, 246, 226, 0.5); font-size: 13px; }
.coinrow { margin-top: 8px; align-items: center; }
.rec small .y { color: #1f6b2f; } .rec small .n { color: #b8321f; }
/* Locked backpack slots: a padlock, and on the next one a coin price tag under it. */
.slot.locked { gap: 1px; }
.slot.locked .lkic img.emo { width: 20px; height: 20px; opacity: 0.75; }
.slot.locked.next .lkic img.emo { width: 18px; height: 18px; opacity: 1; }
.slot.locked .lkp { display: inline-flex; align-items: center; gap: 2px; padding: 0 5px; border-radius: 8px; background: rgba(42, 23, 12, 0.85); color: #ffe08a; font-size: 10px; font-weight: 700; line-height: 15px; white-space: nowrap; }
.slot.locked .lkp img.emo { width: 11px; height: 11px; vertical-align: middle; }

/* Seasons, Diamonds, leaderboards, market */
#dgbox .dgrow.se { margin-top: 3px; padding-top: 4px; border-top: 1px solid rgba(255, 243, 220, 0.18); }
#dgbox .dgrow.se span { color: #8fe8ff; }
#dgbox .dgrow.se.soon span { color: #ff9a8a; font-weight: 700; }
.tabs.wrap button { padding: 5px 9px !important; font-size: 13px !important; }
.sebar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.sebar > div { background: #3a2214; color: var(--cream); border-radius: 8px; padding: 6px 8px; text-align: center; }
.sebar b { display: block; font-size: 16px; color: #8fe8ff; }
.sebar small { font-size: 11px; opacity: 0.8; }
.skhead.dia { background: linear-gradient(135deg, #d6f4ff, #b8e6ff); border: 2px solid #5fb8e0; }
.skhead.dia b { font-size: 18px; color: #135a7a; }
.dtree { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.dtree .sknode { margin: 0; border-color: #7fc8e8; }
.dtree .sknode.done { background: #d6f4ff; border-color: #2a9ad0; }
.dtree .sknode.part { background: #eef9ff; }
.dtree .sknode.can { box-shadow: 0 0 0 2px #5fd0ff; }
.dtree .sknode button { width: 100%; margin-top: 2px; background: #6fd0f4 !important; }
@media (max-width: 520px) { .dtree { grid-template-columns: 1fr; } }
.seres { text-align: center; padding: 12px; background: #3a2214; color: var(--cream); border-radius: 10px; }
.seres .serank { font-size: 44px; font-weight: 700; color: var(--gold); line-height: 1.1; }
.seres .serank img.emo { width: 56px; height: 56px; }
.seres b { display: block; font-size: 18px; }
.seres small { opacity: 0.8; }
.lb.acct .lbrow { gap: 6px; font-size: 12px; padding: 4px 8px; }
.lb.acct .lbrow span { width: 62px; text-align: right; flex-shrink: 0; white-space: nowrap; overflow: hidden; }
.lb.acct .lbrow span:nth-of-type(1) { width: 26px; }
.lb.acct .lbrow.head { background: var(--wood); color: var(--cream); font-weight: 700; }
#panel[data-p="board"], #panel[data-p="dtree"] { width: min(640px, calc(100vw - 20px)); }

/* Soft vignette and a little extra colour over the 3D view */
#vig { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse 120% 105% at 50% 46%, rgba(8, 14, 30, 0) 58%, rgba(8, 14, 30, 0.2) 82%, rgba(8, 14, 30, 0.42) 100%); }
@media (pointer: fine) { canvas#c { filter: saturate(1.16) contrast(1.05); } }

/* Rotate button (touch screens, while holding something placeable) */
#rotbtn { right: calc(34px + env(safe-area-inset-right)); bottom: calc(190px + env(safe-area-inset-bottom)); width: 50px; height: 50px; font-size: 24px; font-weight: 700; }
@media (pointer: fine) { #rotbtn { display: none !important; } }

/* Chest colour swatches and the bigger chests' grid */
.chcols { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin-bottom: 8px; }
.chcols .dim { margin-right: 4px; font-size: 13px; }
#pbody .chcols button.sw { width: 24px; height: 24px; padding: 0; border-radius: 6px; border: 2px solid var(--edge); box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
#pbody .chcols button.sw.on { outline: 3px solid var(--gold); outline-offset: 1px; }
/* Chest menu, Minecraft style: the chest's rows on top, then the backpack's rows, then the hotbar, all
   8 slots wide in a normal-sized panel. */
#panel[data-p="cont"] #pbody .grid.chestgrid, #panel[data-p="cont"] #pbody .grid.g6 { grid-template-columns: repeat(8, 46px); gap: 4px; justify-content: center; }
#panel[data-p="cont"] #pbody .grid.g5 { grid-template-columns: repeat(5, 46px); gap: 4px; justify-content: center; }
#panel[data-p="cont"] #pbody .grid .slot { height: 46px; }
#panel[data-p="cont"] #pbody h4 { margin: 6px 0 4px; }
.chesth { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 6px; }
.chesth b { color: var(--wood); font-size: 15px; }
.chesth .chcols { margin: 0; gap: 3px; }
#pbody .chesth .chcols button.sw { width: 18px; height: 18px; border-width: 2px; border-radius: 5px; }
@media (max-width: 520px) { #panel[data-p="cont"] #pbody .grid.chestgrid, #panel[data-p="cont"] #pbody .grid.g6 { grid-template-columns: repeat(8, 1fr); gap: 3px; } #panel[data-p="cont"] #pbody .grid .slot { height: auto; aspect-ratio: 1; } .chesth { flex-direction: column; align-items: flex-start; } }

/* ===================================================================
   Menus, refreshed: a rounder, easier-to-read font (Nunito) with Fredoka for titles,
   softer cards and clearer states. The HUD keeps its pixel font.
   =================================================================== */
:root { --menu: 'Nums', 'Nunito', system-ui, sans-serif; --head: 'Fredoka', 'Nunito', system-ui, sans-serif; }
#panel, #tip, #prompt, #bossres, #classpick, #login .lbox { font-family: var(--menu); }
#panel button, #panel input, #prompt button, #classpick button { font-family: var(--menu); }
#pbody { font-size: 15px; font-weight: 600; line-height: 1.35; color: #3a2214; }
.ph #ptitle, #pbody h4, #tip .tth b, .card b, #classpick h2, #login h1 { font-family: var(--head); letter-spacing: 0.2px; }
.ph #ptitle { font-weight: 700; font-size: 21px; }
#pbody h4 { font-size: 16px; font-weight: 600; color: #5a3217; margin: 14px 0 7px; border-bottom: 2px solid rgba(107, 63, 34, 0.15); }
#pbody .hint { font-weight: 600; font-size: 13.5px; color: #6b4a33; }
#pbody b { font-weight: 800; }
#pbody small { font-weight: 600; }
.ph button, #pbody button { font-weight: 800; letter-spacing: 0.2px; border-radius: 9px; }
#pbody button:disabled { filter: grayscale(0.4); }
#pbody input { font-weight: 700; border-radius: 9px; border: 2px solid #6b4128; background: #fffaf0; box-shadow: inset 0 2px 0 rgba(0,0,0,.06); }
#pbody input:focus { outline: 3px solid rgba(255, 207, 85, 0.6); outline-offset: 0; }
#tip { font-weight: 600; }
#tip .tth small { font-weight: 700; }

/* Backpack: 8 columns, with the level each locked slot opens at. */
#pbody .grid.g8 { display: grid; grid-template-columns: repeat(8, 50px); gap: 5px; justify-content: center; }
#pbody .invright .grid.g8 { grid-template-columns: repeat(8, 44px); justify-content: start; gap: 4px; }
#pbody .invright .grid.g8 .slot, #pbody .grid.g8 .slot { height: 44px; }
#pbody .invright .grid.g8 .slot .ic, #pbody .grid.g8 .slot .ic { width: 34px; height: 34px; }
#panel[data-p="cont"] #pbody .grid.g8 { grid-template-columns: repeat(8, 46px); gap: 4px; justify-content: center; }
#panel[data-p="cont"] #pbody .grid.g8 .slot { height: 46px; }
@media (max-width: 560px) { #pbody .grid.g8, #pbody .invright .grid.g8 { grid-template-columns: repeat(8, 1fr); } #pbody .grid.g8 .slot { height: auto; aspect-ratio: 1; } }
.slot.locked { position: relative; }
.slot.locked .lkp { font-family: var(--menu); font-weight: 800; font-size: 10px; }
.packh .bagn { font-family: var(--menu); font-size: 12px; color: #8a5a35; margin-left: 4px; }
/* Rolled gear: a small gem in the corner shows the roll's quality. */
.slot .qd { position: absolute; left: 3px; top: 3px; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid rgba(0,0,0,.55); z-index: 2; pointer-events: none; }

/* Crafting: a search box and names under every recipe. */
.csearch { margin: 6px 0 8px; display: flex; }
#pbody .csearch input { flex: 1; padding: 8px 11px; font-size: 14px; }
.cgrid.named { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 6px; }
#pbody .cgrid.named .ctile { height: 84px; flex-direction: column; gap: 3px; padding: 6px 4px 5px; border-radius: 10px; }
#pbody .cgrid.named .ctile em { font-style: normal; font-size: 11px; font-weight: 800; line-height: 1.1; color: #3a2214; text-align: center; max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#pbody .cgrid.named .ctile .ic { width: 38px; height: 38px; flex-shrink: 0; }
#pbody .cgrid.named .ctile .n { top: 2px; bottom: auto; right: 4px; }
#pbody .cgrid.named .ctile.ok em { color: #1f5a2c; }
#pbody .ctabs button { border-radius: 9px; font-weight: 800; }

/* Zone banner: a warning when your weapon is below the area's tier. */
#zone .weak { color: #ffb36a; margin-left: 6px; font-size: 0.92em; }

/* The Tower's menu */
.twtop { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.twstat { background: linear-gradient(180deg, #4e3a78, #34265a); color: #ffe9a8; border: 2px solid #1e1009; border-radius: 12px; padding: 8px 6px; text-align: center; box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.twstat b { display: block; font-family: var(--head); font-size: 26px; color: #fff3c4; }
.twstat small { font-size: 12px; color: #d8c8ff; }
.twrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.twrow > span { display: flex; gap: 6px; align-items: center; }
.twrow.inv { background: #fff3c4; border: 2px solid #c98a3c; border-radius: 10px; padding: 6px 8px; }
.twparty { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.twm { background: rgba(255, 250, 238, 0.75); border: 2px solid rgba(107, 63, 34, 0.35); border-radius: 10px; padding: 6px 9px; display: flex; flex-direction: column; }
.twm.off { opacity: 0.55; }
.twm small { color: #6b4a33; font-size: 12px; }
.twstart { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
#pbody .twstart button { font-size: 16px; padding: 11px; }
#pbody .twstart button.gold { background: linear-gradient(180deg, #ffe08a, #e0a83a); }
.twboard { display: flex; flex-direction: column; gap: 3px; }
.twb { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 8px; align-items: center; background: rgba(255, 250, 238, 0.6); border-radius: 8px; padding: 4px 8px; }
.twb.me { background: #fff0b8; box-shadow: inset 0 0 0 2px #e0a83a; }
.twb span { text-align: center; font-weight: 900; }
.twb em { font-style: normal; font-weight: 900; color: #5a3f8a; }
.twb small { color: #8a6a4a; }

/* In-Tower status, and the spectating banner */
#twhud { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 5; padding: 7px 16px; font-size: 17px; display: flex; gap: 14px; align-items: center; background: rgba(36, 24, 60, 0.88); border: 2px solid #ffd36a; border-radius: 12px; color: #fff3dc; white-space: nowrap; }
#twhud b { color: #ffd36a; }
#twhud .hot { color: #ff7a6a; animation: blink 0.5s infinite alternate; }
#specbar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 30; padding: 8px 18px; background: rgba(120, 40, 140, 0.9); border: 2px solid #ffb3ff; border-radius: 12px; color: #fff; font-family: var(--menu); font-weight: 700; font-size: 15px; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
#specbar code { background: rgba(0,0,0,.3); padding: 1px 6px; border-radius: 5px; }
