/* Dungeons: gothic HUD around a full-bleed canvas. */
:root {
  --void: #060509; --plate: #151019; --rim: #4a3a2c; --rim-hi: #8a6a3e; --bone: #eadfc8; --muted: #9a8f9e; --dim: #6f6573;
  --ember: #e0662b; --blood: #c01c30; --mana: #3566dd; --gold: #d9a640; --gold-hi: #f2d35b;
  --display: "Cinzel", "Palatino Linotype", Georgia, serif;
  --body: "Alegreya Sans", "Segoe UI", system-ui, sans-serif;
  --stone: linear-gradient(180deg, #2a2226 0%, #1a1418 45%, #120d10 100%);
  --frame: 0 0 0 1px #0a0709, 0 0 0 2px #5a4530, 0 0 0 3px #1a120c, 0 8px 24px rgba(0,0,0,.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--void); color: var(--bone); font-family: var(--body); overflow: hidden;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.g { color: var(--gold); }
.muted { color: var(--muted); }

#game { position: fixed; inset: 0; overflow: hidden; background: var(--void); }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M3 3l9 22 3-9 9-3z' fill='%23d9a640' stroke='%23140c06' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") 3 3, default; }
#cv.attack { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' viewBox='0 0 30 30'%3E%3Cpath d='M3 3l15 15M3 3h4l15 15-4 4L3 7z' fill='%23e0303f' stroke='%23140606' stroke-width='1.5' stroke-linejoin='round'/%3E%3Cpath d='M17 23l6-6M20 20l6 6' stroke='%23c9a24a' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E") 3 3, crosshair; }
#cv.grab { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M3 3l9 22 3-9 9-3z' fill='%23f2d35b' stroke='%23140c06' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") 3 3, pointer; }
#vignette { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 75% 70% at 50% 48%, rgba(0,0,0,0) 55%, rgba(0,0,0,.55) 100%); }
#hurt { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 45%, rgba(160,10,20,.55) 100%); }
#lowhp { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s;
  box-shadow: inset 0 0 120px 30px rgba(150,0,15,.65); }

/* ---------- top HUD ---------- */
.top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0; pointer-events: none; }
.plate { background: linear-gradient(180deg, rgba(30,22,28,.9), rgba(10,8,12,.9)); box-shadow: var(--frame); border-radius: 2px; }
.stats { padding: 8px 14px 9px; }
.zone { font-family: var(--display); font-weight: 700; font-size: 15px; letter-spacing: .04em; color: #e9d9b8;
  text-shadow: 0 0 12px rgba(224,102,43,.35), 0 1px 0 #000; margin-bottom: 4px; }
.statrow { display: flex; gap: 16px; }
.stat { display: flex; flex-direction: column; line-height: 1.1; }
.lab { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.val { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.miniframe { padding: 4px; background: rgba(6,5,9,.75); box-shadow: var(--frame); border-radius: 50% / 34%; overflow: hidden; }
#mini { width: 168px; height: 112px; display: block; border-radius: 50% / 34%; image-rendering: pixelated; }

#toasts { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 128px); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; width: min(560px, calc(100% - 32px)); z-index: 3; }
.toast { font-family: var(--display); font-weight: 700; font-size: 17px; text-align: center; text-shadow: 0 2px 6px #000, 0 0 2px #000;
  transition: opacity .5s, transform .5s; color: var(--bone); }
.toast.big { font-size: 24px; letter-spacing: .03em; }
.toast.out { opacity: 0; transform: translateY(-8px); }

#bossbar, #target { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 14px); left: 50%; transform: translateX(-50%);
  width: min(460px, calc(100% - 420px)); min-width: 220px; text-align: center; pointer-events: none; }
#bossbar .bn { font-family: var(--display); font-weight: 700; font-size: 19px; color: #f0d9b0; letter-spacing: .04em;
  text-shadow: 0 0 14px rgba(224,60,40,.45), 0 2px 4px #000; }
#bossbar .bb, #target .tb { height: 12px; margin-top: 4px; background: #140a0c; box-shadow: var(--frame); position: relative; overflow: hidden; }
#bossfill, #tfill { display: block; height: 100%; width: 100%; background: linear-gradient(#e0303f, #7a0c18); transition: width .15s; }
#target { top: calc(env(safe-area-inset-top, 0px) + 18px); width: min(300px, calc(100% - 420px)); }
#bossbar:not([hidden]) ~ #target { top: calc(env(safe-area-inset-top, 0px) + 70px); }
#target .tn { font-family: var(--display); font-weight: 700; font-size: 14px; text-shadow: 0 2px 4px #000; }
#target .tb { height: 8px; }
#target .ta { font-size: 11px; color: #8fb0ff; margin-top: 3px; text-shadow: 0 1px 2px #000; min-height: 1em; }

/* ---------- bottom HUD ---------- */
.hud { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 0;
  padding: 0 8px calc(env(safe-area-inset-bottom, 0px) + 8px); pointer-events: none; }
.orb { --s: 108px; width: var(--s); height: var(--s); border-radius: 50%; position: relative; overflow: hidden; flex: none; z-index: 2;
  background: radial-gradient(circle at 50% 40%, #1d1418, #050405 70%);
  box-shadow: 0 0 0 2px #0a0709, 0 0 0 5px #6b5338, 0 0 0 6px #2a1e14, 0 0 0 9px #3a2c1f, 0 0 0 10px #0a0709, inset 0 0 24px #000, 0 8px 22px rgba(0,0,0,.7); }
.orb i { position: absolute; left: 0; right: 0; bottom: 0; height: 100%; transition: height .12s linear; }
.orb.hp i { background: radial-gradient(circle at 40% 25%, #ff6a6a, #b0101f 48%, #3c040b); }
.orb.mp i { background: radial-gradient(circle at 40% 25%, #7fb0ff, #2449b8 48%, #08133f); }
.orb i::after { content: ""; position: absolute; left: -10%; right: -10%; top: -3px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,.18); animation: slosh 3s ease-in-out infinite alternate; }
@keyframes slosh { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }
.orb::after { content: ""; position: absolute; left: 16%; top: 8%; width: 44%; height: 26%; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,.38), rgba(255,255,255,0) 70%); pointer-events: none; }
.orb span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 12px;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px #000, 0 0 2px #000; opacity: .85; }
.orb.hp { margin-right: -14px; } .orb.mp { margin-left: -14px; }
.bar { position: relative; margin-bottom: 4px; padding: 8px 26px 8px; background: var(--stone); box-shadow: var(--frame);
  border-radius: 3px 3px 2px 2px; }
.bar::before { content: ""; position: absolute; inset: 3px; border: 1px solid rgba(201,162,74,.18); pointer-events: none; border-radius: 2px; }
.xp { height: 5px; margin: 0 0 7px; background: #0d0a0c; box-shadow: 0 0 0 1px #3a2c1f; }
.xp i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8a6a2a, #f0cf68); box-shadow: 0 0 6px rgba(240,207,104,.5); }
.bar-inner { display: flex; align-items: center; gap: 14px; }
.skills { display: flex; gap: 7px; }
.sk { --c: var(--bone); pointer-events: auto; position: relative; width: 56px; height: 56px; padding: 0; cursor: pointer; color: var(--c);
  background: radial-gradient(circle at 50% 35%, #2a2030, #0d0a10); border: 1px solid #7a5c3a; border-radius: 3px;
  box-shadow: 0 0 0 2px #0a0709, inset 0 0 14px rgba(0,0,0,.85); overflow: hidden; touch-action: none; transition: transform .08s; }
.sk:active { transform: scale(.95); }
.sk:hover { border-color: #c9a24a; }
.sk svg { width: 30px; height: 30px; display: block; margin: auto; filter: drop-shadow(0 0 6px currentColor); }
.sk .key { position: absolute; left: 4px; top: 2px; font: 800 10px var(--body); color: var(--muted); }
.sk .cost { position: absolute; right: 4px; bottom: 2px; font: 800 10px var(--body); color: #9db6ff; font-variant-numeric: tabular-nums; }
.sk .cost.n { color: var(--bone); }
.sk .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,.72); pointer-events: none; }
.sk .lock { display: none; position: absolute; inset: 0; place-items: center; font: 800 11px var(--body); color: var(--bone); background: rgba(0,0,0,.6); }
.sk.locked .lock { display: grid; }
.sk.low { filter: grayscale(.8) brightness(.6); }
.sk.fire { --c: #ff8a3a; } .sk.frost { --c: #9fd8ff; } .sk.pot { --c: #ff5266; margin-left: 8px; }
.menubtns { display: grid; grid-template-columns: repeat(2, 30px); gap: 5px; }
.mb { pointer-events: auto; width: 30px; height: 25px; padding: 0; cursor: pointer; color: #c9b48a; display: grid; place-items: center;
  background: linear-gradient(#2a2024, #120d10); border: 1px solid #5a4530; border-radius: 2px; }
.mb:hover { color: var(--gold-hi); border-color: #c9a24a; }
.mb svg { width: 15px; height: 15px; }
.sk:focus-visible, .mb:focus-visible, .btn:focus-visible, .islot:focus-visible, .mini-btn:focus-visible, .tabs button:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold-hi); outline-offset: 2px; }

/* ---------- side panels ---------- */
.panel-win { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); left: 16px; width: 340px; max-height: calc(100% - 170px);
  overflow: auto; z-index: 4; padding: 0 16px 16px; background: linear-gradient(180deg, rgba(26,19,22,.97), rgba(12,9,11,.97));
  box-shadow: var(--frame); border-radius: 3px; touch-action: auto; }
.panel-win.side-r { left: auto; right: 16px; }
.panel-win header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 0 8px;
  margin-bottom: 8px; background: linear-gradient(180deg, rgba(26,19,22,1) 70%, rgba(26,19,22,0)); border-bottom: 1px solid #3a2c1f; }
.panel-win h2, .mbox h2 { font-family: var(--display); font-weight: 700; font-size: 20px; margin: 0; letter-spacing: .05em; color: #ead6ad; }
.panel-win h3 { font-family: var(--display); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; }
.x { width: 30px; height: 30px; border: 1px solid #5a4530; background: #120d10; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; border-radius: 2px; }
.x:hover { color: var(--bone); border-color: #c9a24a; }
.cstats { display: grid; gap: 2px; }
.crow { display: flex; justify-content: space-between; gap: 12px; padding: 5px 8px; font-size: 14px; background: rgba(255,255,255,.025); }
.crow:nth-child(odd) { background: rgba(255,255,255,.045); }
.crow span { color: var(--muted); } .crow b { font-variant-numeric: tabular-nums; }

.doll { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-areas: "helm amulet ring" "weapon armor gloves" ". boots ."; gap: 8px; }
.dslot { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.ds-weapon { grid-area: weapon; } .ds-helm { grid-area: helm; } .ds-armor { grid-area: armor; } .ds-gloves { grid-area: gloves; }
.ds-boots { grid-area: boots; } .ds-ring { grid-area: ring; } .ds-amulet { grid-area: amulet; }
.dlabel { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.dslot .islot { width: 58px; height: 58px; }
.invbar { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.invgrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.islot { aspect-ratio: 1; width: 100%; padding: 4px; display: grid; place-items: center; cursor: pointer; border-radius: 2px;
  background: radial-gradient(circle at 50% 40%, #1d161b, #0b080a); border: 1px solid #2e2329; color: var(--bone); }
.islot svg { width: 80%; height: 80%; }
.islot.empty { cursor: default; }
.islot.ghost { color: #3a3036; }
.islot.r0 { color: #cfc6b4; } .islot.r1 { color: #7f9cff; border-color: #2c3560; background: radial-gradient(circle at 50% 40%, #1a1d33, #0b080a); }
.islot.r2 { color: #f2d35b; border-color: #5a4a20; background: radial-gradient(circle at 50% 40%, #2c2512, #0b080a); }
.islot.r3 { color: #ff8a2a; border-color: #6a3610; background: radial-gradient(circle at 50% 40%, #33190a, #0b080a); box-shadow: inset 0 0 10px rgba(255,138,42,.25); }
.islot:not(.empty):hover { border-color: #c9a24a; filter: brightness(1.2); }
.invact { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.mini-btn { font: 700 12px var(--body); padding: 7px 10px; cursor: pointer; color: #e9d9b8; background: linear-gradient(#2e2226, #150f12);
  border: 1px solid #5a4530; border-radius: 2px; }
.mini-btn:hover { border-color: #c9a24a; color: var(--gold-hi); }

#tip { position: fixed; z-index: 10; display: flex; flex-direction: column; gap: 6px; max-width: 290px; pointer-events: auto; }
.tip-card { padding: 10px 12px; background: rgba(8,6,9,.97); border: 1px solid color-mix(in srgb, var(--rc) 45%, #000); box-shadow: 0 6px 20px rgba(0,0,0,.7);
  text-align: center; }
.tip-eq { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.tip-name { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--rc); }
.tip-type { font-size: 12px; color: var(--muted); margin: 2px 0 6px; }
.tip-lines .base { color: var(--bone); font-weight: 700; }
.tip-lines .aff { color: #8fa8ff; font-size: 14px; }
.tip-hint { font-size: 11px; color: var(--dim); text-align: center; padding: 4px; background: rgba(8,6,9,.9); }
.tip-actions { display: flex; gap: 6px; justify-content: center; }

/* ---------- overlays & menus ---------- */
.ov { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 6; overflow: auto; touch-action: auto;
  background: radial-gradient(ellipse at 50% 75%, rgba(110,32,12,.42), rgba(4,3,6,.88) 70%); }
.ov.dim { background: rgba(4,3,6,.72); }
.titlecard { width: min(440px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.titlecard.small { width: min(340px, 100%); }
.crest { width: 74px; height: 74px; margin-bottom: -6px;
  background: radial-gradient(circle, rgba(224,102,43,.55), rgba(224,102,43,0) 65%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M32 6c3 10 14 15 14 30a14 14 0 0 1-28 0c0-8 5-11 6-19 5 3 7 7 7 13 2-5 2-12 1-24z' fill='%23ff8a3a'/%3E%3Cpath d='M32 30c1 4 6 6 6 12a6 6 0 0 1-12 0c0-3 2-5 3-8 1 2 2 3 2 5 1-3 1-5 1-9z' fill='%23ffe2a0'/%3E%3C/svg%3E") center/48px no-repeat;
  filter: drop-shadow(0 0 18px rgba(255,120,40,.6)); animation: flicker 2.6s infinite alternate; }
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: .82; } 70% { opacity: .95; } }
h1, .titlecard h2 { font-family: var(--display); font-weight: 900; margin: 0; line-height: .95; color: #efe2c6; letter-spacing: .06em;
  text-shadow: 0 0 30px rgba(224,102,43,.55), 0 3px 0 #000, 0 0 2px #000; }
h1 { font-size: clamp(52px, 13vw, 92px); text-transform: uppercase;
  background: linear-gradient(180deg, #fff1d0 10%, #d9a640 55%, #8a5a20 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #000) drop-shadow(0 0 22px rgba(224,102,43,.45)); text-shadow: none; }
.titlecard h2 { font-size: clamp(36px, 9vw, 56px); color: #e4a0a0; text-shadow: 0 0 28px rgba(192,28,48,.6), 0 3px 0 #000; }
.titlecard.small h2 { color: #efe2c6; text-shadow: 0 0 20px rgba(224,102,43,.4), 0 3px 0 #000; }
.tag { font-family: var(--display); font-size: 15px; letter-spacing: .3em; text-transform: uppercase; color: var(--muted); margin: 0; }
.tag span { color: var(--ember); }
.eyebrow { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--ember); }
.acct { min-height: 44px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.acct-name { font-family: var(--display); font-weight: 700; font-size: 17px; color: #ead6ad; }
.acct-stats { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.acct-stats b { color: var(--bone); }
.menu { display: flex; flex-direction: column; gap: 8px; width: min(300px, 100%); }
.btn { font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: .06em; padding: 11px 22px; cursor: pointer; color: #e9d9b8;
  background: linear-gradient(#2c2125, #140e11); border: 1px solid #6a5034; border-radius: 2px;
  box-shadow: 0 0 0 1px #0a0605, inset 0 1px 0 rgba(255,230,190,.08); transition: color .15s, border-color .15s, background .15s; }
.btn:hover { color: var(--gold-hi); border-color: #c9a24a; background: linear-gradient(#36292d, #1a1215); }
.btn.primary { font-size: 21px; color: #f6e3bd; background: linear-gradient(#6a1e15, #2a0b08); border-color: #b07a3a;
  box-shadow: 0 0 0 2px #0a0605, 0 0 26px rgba(224,102,43,.35); }
.btn.primary:hover { background: linear-gradient(#83281b, #360e0a); color: #fff2d6; }
.btn.danger:hover { color: #ff8a80; border-color: #a03030; }
.btn:disabled { opacity: .5; cursor: wait; }
.note { font-size: 13px; color: var(--muted); max-width: 40ch; margin: 0; line-height: 1.45; }
.deadstats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; width: min(360px, 100%); }
.deadstats div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid #2a2024; font-size: 14px; }
.deadstats span { color: var(--muted); } .deadstats b { font-variant-numeric: tabular-nums; }
.bank { font-size: 14px; color: #cfc3b2; margin: 0; min-height: 1.4em; max-width: 44ch; line-height: 1.5; }

.modal { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; padding: 16px; background: rgba(3,2,5,.7); touch-action: auto; overflow: auto; }
.mbox { position: relative; width: min(380px, 100%); padding: 22px 22px 18px; background: linear-gradient(180deg, #1c1519, #0e0a0c);
  box-shadow: var(--frame), 0 20px 60px rgba(0,0,0,.7); border-radius: 3px; display: flex; flex-direction: column; gap: 12px; }
.mbox.wide { width: min(520px, 100%); }
.mbox > .x { position: absolute; top: 12px; right: 12px; }
.mbox p { margin: 0; font-size: 14px; line-height: 1.55; color: #cfc3b2; }
form { display: flex; flex-direction: column; gap: 10px; }
form.inline { flex-direction: row; align-items: flex-end; } form.inline label { flex: 1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
input { font: 500 16px var(--body); padding: 10px 12px; color: var(--bone); background: #0b080a; border: 1px solid #4a3a2c; border-radius: 2px;
  text-transform: none; letter-spacing: normal; user-select: text; -webkit-user-select: text; }
input:focus { border-color: #c9a24a; outline: none; }
.err { color: #ff8a80 !important; min-height: 1.2em; font-size: 13px !important; }
.swap { font-size: 13px !important; color: var(--muted) !important; text-align: center; }
.swap a, .mbox a { color: var(--gold-hi); }
.social { display: flex; flex-direction: column; gap: 8px; }
.sbtn { display: block; text-align: center; padding: 10px; font-weight: 700; font-size: 15px; text-decoration: none; border-radius: 2px; color: #fff; border: 1px solid rgba(255,255,255,.15); }
.s-google { background: #2b2b2f; } .s-google:hover { background: #38383d; }
.s-discord { background: #4752c4; } .s-discord:hover { background: #5865f2; }
.or { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: .14em; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: #3a2c1f; }
.acctsum { line-height: 1.7 !important; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid #3a2c1f; }
.tabs button { flex: 1; font-family: var(--display); font-weight: 700; font-size: 14px; padding: 9px; cursor: pointer; color: var(--muted);
  background: transparent; border: 1px solid transparent; border-bottom: none; border-radius: 2px 2px 0 0; }
.tabs button[aria-selected="true"] { color: var(--gold-hi); background: #1a1316; border-color: #3a2c1f; }
.lb { list-style: none; margin: 0; padding: 0; max-height: min(52vh, 460px); overflow: auto; }
.lb li { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 7px 10px; font-size: 15px; }
.lb li:nth-child(odd) { background: rgba(255,255,255,.03); }
.lb li.me { background: rgba(217,166,64,.12); box-shadow: inset 2px 0 0 var(--gold); }
.lb .rk { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.lb .top1 .rk { color: #f2d35b; } .lb .top2 .rk { color: #d0d4dc; } .lb .top3 .rk { color: #d08a52; }
.lb .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .vl { font-variant-numeric: tabular-nums; color: #cfc3b2; }
.lb li.empty { display: block; text-align: center; color: var(--muted); padding: 24px; }
.lbme { text-align: center; font-size: 14px !important; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; text-align: left; font-size: 14px; color: #cfc3b2;
  padding: 12px 14px; border: 1px solid #3a2c1f; background: rgba(10,7,12,.6); }
.keys b { color: var(--gold); font-weight: 800; white-space: nowrap; }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  #bossbar, #target { width: calc(100% - 32px); top: calc(env(safe-area-inset-top, 0px) + 92px); }
  #bossbar:not([hidden]) ~ #target { top: calc(env(safe-area-inset-top, 0px) + 140px); }
  #toasts { top: calc(env(safe-area-inset-top, 0px) + 150px); }
  .panel-win, .panel-win.side-r { left: 8px; right: 8px; width: auto; top: auto; bottom: 130px; max-height: calc(100% - 150px); }
}
@media (max-width: 560px) {
  .orb { --s: 78px; } .orb span { font-size: 10px; }
  .orb.hp { margin-right: -10px; } .orb.mp { margin-left: -10px; }
  .bar { padding: 6px 14px; }
  .sk { width: 44px; height: 44px; } .sk svg { width: 24px; height: 24px; } .skills { gap: 4px; } .sk.pot { margin-left: 3px; }
  .bar-inner { gap: 6px; }
  .menubtns { grid-template-columns: repeat(2, 26px); gap: 3px; } .mb { width: 26px; height: 21px; }
  #mini { width: 120px; height: 80px; }
  .stats { padding: 6px 10px; } .zone { font-size: 13px; } .statrow { gap: 10px; } .val { font-size: 14px; }
  .toast { font-size: 15px; } .toast.big { font-size: 19px; }
}
@media (max-width: 400px) {
  .orb { --s: 66px; } .sk { width: 40px; height: 40px; } .menubtns { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .crest, .orb i::after { animation: none; }
}

/* ---------- town update ---------- */
body.menu .ingame, body.menu #castbar, body.menu #target, body.menu #bossbar { display: none !important; }
.orb.mp[data-res="fury"] i { background: radial-gradient(circle at 40% 25%, #ffb36a, #c4501a 48%, #4a1406); }
.orb.mp[data-res="energy"] i { background: radial-gradient(circle at 40% 25%, #f4ff9a, #8aa82a 48%, #263a08); }
.sk.tp { --c: #9fd8ff; margin-left: 2px; }
.sk.active { border-color: #9fd8ff; box-shadow: 0 0 0 2px #0a0709, 0 0 14px rgba(120,200,255,.6), inset 0 0 14px rgba(0,0,0,.85); }

#castbar { position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); transform: translateX(-50%);
  width: min(300px, calc(100% - 32px)); text-align: center; pointer-events: none; z-index: 3; }
#castbar .cn { font-family: var(--display); font-weight: 700; font-size: 14px; color: #cfeaff; text-shadow: 0 2px 4px #000; margin-bottom: 4px; }
#castbar .cb { height: 10px; background: #0b0d14; box-shadow: var(--frame); overflow: hidden; }
#castfill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #2a6ad8, #9fd8ff); }

.charhead { margin: -2px 0 10px; }
.ch-name { font-family: var(--display); font-weight: 700; font-size: 18px; color: #ead6ad; }
.ch-sub { font-size: 13px; color: var(--muted); }
.tip-val { margin-top: 6px; font-size: 12px; color: var(--muted); }
.tip-val b { color: var(--gold); }
#invpanel.selling { box-shadow: var(--frame), 0 0 0 1px rgba(217,166,64,.35), 0 0 30px rgba(217,166,64,.15); }
#merchpanel .quote { font-style: italic; color: #cfc3b2; margin: 4px 0 14px; line-height: 1.5; }
.merch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; background: rgba(255,255,255,.04); border: 1px solid #2e2329; }
.merch-row b { color: var(--bone); }
#merchpanel .note { margin-top: 12px; }
.mini-btn:disabled { opacity: .45; cursor: default; }

.townwin { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; pointer-events: none; }
.tw-inner { position: relative; pointer-events: auto; width: min(680px, 100%); max-height: calc(100% - 150px); overflow: auto; touch-action: auto;
  padding: 22px 22px 18px; background: linear-gradient(180deg, rgba(28,21,25,.97), rgba(12,9,11,.97)); box-shadow: var(--frame), 0 20px 60px rgba(0,0,0,.7); border-radius: 3px; }
.tw-inner > .x { position: absolute; top: 12px; right: 12px; }
.tw-inner h2 { font-family: var(--display); font-weight: 700; font-size: 24px; margin: 0; color: #ead6ad; letter-spacing: .04em; }
.tw-sub { margin: 4px 40px 16px 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.empty-note { color: var(--muted); text-align: center; padding: 24px; }

.upgrades { display: grid; gap: 8px; }
.upg { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: rgba(255,255,255,.035); border: 1px solid #2e2329; }
.upg.maxed { border-color: #5a4a20; }
.upg-main { flex: 1; min-width: 0; }
.upg-name { font-family: var(--display); font-weight: 700; font-size: 15px; color: #e6c8ff; }
.upg-rank { font-family: var(--body); font-size: 12px; color: var(--muted); margin-left: 6px; }
.upg-desc { font-size: 13px; color: #cfc3b2; margin: 2px 0 6px; }
.pips { display: flex; gap: 3px; }
.pips i { width: 14px; height: 5px; background: #2a2024; }
.pips i.on { background: linear-gradient(90deg, #a05cd8, #e6c8ff); box-shadow: 0 0 6px rgba(200,140,255,.5); }
.mini-btn.buy { min-width: 112px; }

.crypt { list-style: none; margin: 0; padding: 0; }
.crypt li { display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; align-items: center; padding: 9px 10px; border-bottom: 1px solid #2a2024; }
.crypt li:nth-child(odd) { background: rgba(255,255,255,.025); }
.crypt .rk { font-weight: 800; color: var(--muted); text-align: right; }
.crypt .cname { font-family: var(--display); font-weight: 700; color: #ead6ad; }
.crypt small { display: block; font-family: var(--body); font-weight: 500; font-size: 12px; color: var(--muted); }
.crypt .cause { font-size: 13px; color: #cfc3b2; }

.gates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.gate { padding: 14px; border: 1px solid #3a2c1f; background: linear-gradient(160deg, var(--g1), var(--g2)); display: flex; flex-direction: column; gap: 6px; }
.gate.g0 { --g1: #2a2230; --g2: #120e15; } .gate.g1 { --g1: #252a1e; --g2: #0f110c; }
.gate.g2 { --g1: #331e18; --g2: #130a08; } .gate.g3 { --g1: #1e2233; --g2: #0a0b12; }
.gate.locked { opacity: .55; filter: grayscale(.6); }
.gate-name { font-family: var(--display); font-weight: 700; font-size: 17px; color: #ead6ad; }
.gate-info { font-size: 13px; color: #cfc3b2; }
.gate-diff { font-size: 12px; color: #e0662b; letter-spacing: .1em; }
.gate-go { display: flex; gap: 8px; margin-top: 6px; }
.gate-go select { flex: 1; font: 600 14px var(--body); color: var(--bone); background: #0b080a; border: 1px solid #4a3a2c; padding: 6px 8px; border-radius: 2px; }
.btn.small { font-size: 15px; padding: 7px 14px; }

.titlecard.wide { width: min(760px, 100%); }
.classes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.ccard { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px 12px; text-align: left; cursor: pointer;
  text-transform: none; letter-spacing: normal; color: var(--bone); background: linear-gradient(180deg, #1c1519, #0e0a0c); border: 1px solid #3a2c1f; border-radius: 3px; }
.ccard input { position: absolute; opacity: 0; pointer-events: none; }
.ccard:has(input:checked) { border-color: #c9a24a; box-shadow: 0 0 0 1px #c9a24a, 0 0 24px rgba(217,166,64,.25); }
.ccard:has(input:focus-visible) { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.ccard-name { font-family: var(--display); font-weight: 900; font-size: 20px; }
.c-warrior .ccard-name { color: #ffb070; } .c-mage .ccard-name { color: #9fc4ff; } .c-rogue .ccard-name { color: #b8e07a; }
.ccard-blurb { font-size: 13px; line-height: 1.45; color: #cfc3b2; }
.ccard-skills { font-size: 12px; color: var(--muted); }
.ccard-skills b { color: var(--gold); font-weight: 700; }
.namefield { width: min(320px, 100%); text-align: left; }
.menu.row { flex-direction: row; justify-content: center; }
.menu.row .btn { flex: 1; }
.cause { margin: -4px 0 0; color: #d8a0a0; font-size: 15px; }
.acct-hero { font-size: 13px; color: #cfc3b2; }

@media (max-width: 760px) {
  .classes { grid-template-columns: 1fr; }
  .gates { grid-template-columns: 1fr; }
  #merchpanel { top: calc(env(safe-area-inset-top, 0px) + 12px); bottom: auto; max-height: 30%; }
  .crypt li { grid-template-columns: 24px 1fr; } .crypt .cause { grid-column: 2; }
}
@media (max-width: 560px) {
  #castbar { bottom: calc(env(safe-area-inset-bottom, 0px) + 120px); }
}

/* ---------- story & activities update ---------- */
.quest { max-width: 280px; margin-top: 7px; padding-top: 6px; border-top: 1px solid #2e2329; font-size: 12px; line-height: 1.35; color: #cfc3b2; }
.quest::before { content: "Bounty · "; color: var(--gold); font-weight: 800; }
.quest.done { color: var(--gold-hi); }
.buffs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.buffs:empty { display: none; }
.buff { font-size: 11px; font-weight: 700; padding: 2px 7px; color: var(--bc); border: 1px solid color-mix(in srgb, var(--bc) 50%, #000);
  background: color-mix(in srgb, var(--bc) 12%, #0b080a); border-radius: 2px; }
.buff b { color: var(--bone); font-variant-numeric: tabular-nums; }
.islot { position: relative; }
.islot .tmp { position: absolute; right: 2px; bottom: 1px; font: 800 9px var(--body); color: var(--gold-hi); text-shadow: 0 1px 2px #000; }

.tw-tabs { margin: 0 0 14px; }
.tw-inner .quote { font-style: italic; color: #cfc3b2; margin: 0 0 12px; line-height: 1.5; }
.tw-inner .note { max-width: none; margin: 10px 0; }
.chapters { display: grid; gap: 10px; margin-bottom: 12px; }
.chapter { padding: 10px 14px; border-left: 2px solid #5a4530; background: rgba(255,255,255,.025); }
.chapter h3, .page h3 { font-family: var(--display); font-size: 15px; margin: 0 0 4px; color: #ead6ad; }
.chapter p, .page p { margin: 0; font-size: 14px; line-height: 1.55; color: #cfc3b2; }
.chapter.latest { border-left-color: var(--ember); background: rgba(224,102,43,.07); }
.chapter.locked { opacity: .6; border-left-style: dashed; }
.bounty { padding: 12px; border: 1px solid #2e2329; background: rgba(255,255,255,.035); display: grid; gap: 8px; }
.bounty.done { border-color: #8a6a24; box-shadow: 0 0 18px rgba(217,166,64,.15); }
.offers { display: grid; gap: 8px; }
.offers .bounty { grid-template-columns: 1fr auto; align-items: center; }
.b-text { font-size: 15px; color: var(--bone); }
.b-bar { height: 8px; background: #140a0c; box-shadow: var(--frame); }
.b-bar i { display: block; height: 100%; background: linear-gradient(90deg, #8a5a20, #f2d35b); }
.b-meta { font-size: 13px; color: var(--muted); }
.journal { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.page { padding: 10px 12px; background: linear-gradient(180deg, rgba(230,216,176,.08), rgba(230,216,176,.03)); border: 1px solid #3a2c1f; }
.page.missing { opacity: .45; }
.smith { display: grid; gap: 8px; }
.srow { display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: rgba(255,255,255,.035); border: 1px solid #2e2329; }
.srow .islot { width: 44px; height: 44px; flex: none; }
.s-main { flex: 1; min-width: 0; }
.s-name { font-family: var(--display); font-weight: 700; font-size: 15px; }
.s-stat { font-size: 13px; color: #cfc3b2; margin: 2px 0 5px; }
.s-stat b { color: #9fe6a0; }
.rumor .quote { font-size: 17px; }
.dice { display: flex; justify-content: center; gap: 28px; margin: 6px 0; }
.dice > div { display: flex; align-items: center; gap: 8px; }
.dlab { font-family: var(--display); font-weight: 700; color: var(--muted); margin-right: 4px; }
.die { width: 40px; height: 40px; padding: 5px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: #e8dfcc; border-radius: 6px;
  box-shadow: inset 0 -3px 0 #b8ab90, 0 3px 8px rgba(0,0,0,.5); }
.die i { border-radius: 50%; }
.die i.on { background: #2a1a14; }
.dice-msg { text-align: center; font-family: var(--display); font-size: 16px; color: var(--gold-hi); margin: 8px 0; }
.bets { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.gamble { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.gbtn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; cursor: pointer; color: #e9d9b8;
  font: 700 13px var(--body); background: linear-gradient(#2e2226, #150f12); border: 1px solid #4a3a2c; border-radius: 2px; }
.gbtn svg { width: 28px; height: 28px; color: #b9a0ff; }
.gbtn:hover:not(:disabled) { border-color: #c9a24a; color: var(--gold-hi); }
.gbtn:disabled { opacity: .45; cursor: default; }
.gresult { display: flex; justify-content: center; margin-top: 8px; }
.gresult .tip-card { min-width: 240px; }
.sh { font-family: var(--display); font-size: 14px; letter-spacing: .08em; color: var(--muted); margin: 12px 0 6px; display: flex; justify-content: space-between; }
.sh span { font-family: var(--body); font-size: 12px; }
.tw-inner .invgrid .islot.empty { display: block; }
.mbox.story { width: min(560px, 100%); }
.storytext p { margin: 0 0 12px; font-size: 16px; line-height: 1.65; color: #d8ccb8; }
.storytext p:first-letter { font-family: var(--display); font-size: 1.25em; color: var(--gold-hi); }
@media (max-width: 760px) {
  .journal { grid-template-columns: 1fr; }
  .gamble { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dice { gap: 14px; } .die { width: 32px; height: 32px; padding: 4px; }
  .quest { max-width: 200px; }
}
