:root {
  --gold: #e8b860; --gold2: #ffd890; --ember: #ff7a30; --ink: #f0e6d6; --dim: #a8988a; --bg: rgba(18, 12, 14, 0.92);
  --line: rgba(232, 184, 96, 0.35); --red: #e04040; --green: #5ad070; --blue: #50a8ff;
  --display: 'Cinzel', Georgia, serif; --body: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0c0809; color: var(--ink); font-family: var(--body); user-select: none; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: crosshair; }
button { font-family: var(--body); }

/* ---------- buttons ---------- */
.btn { background: linear-gradient(#3a2a26, #241818); color: var(--ink); border: 1px solid var(--line); padding: 9px 16px; border-radius: 6px; cursor: pointer; font-weight: 600; letter-spacing: .3px; transition: transform .08s, border-color .15s, background .15s; }
.btn:hover:not(:disabled) { border-color: var(--gold); background: linear-gradient(#4a342c, #2c1e1c); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.gold { background: linear-gradient(#b8742a, #7a4418); border-color: var(--gold2); color: #fff6e0; text-shadow: 0 1px 2px #0008; }
.btn.gold:hover:not(:disabled) { background: linear-gradient(#d08838, #8a5020); }
.btn.ghost { background: transparent; }
.btn.big { padding: 13px 22px; font-size: 16px; width: 100%; }
.btn.mini, button.mini { padding: 3px 9px; font-size: 12px; border-radius: 4px; background: #2a1e1e; color: var(--ink); border: 1px solid var(--line); cursor: pointer; }

/* ---------- title ---------- */
#title { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(10,6,8,.25), rgba(10,6,8,.85)); z-index: 50; transition: opacity .6s; }
#title.hidden { opacity: 0; pointer-events: none; }
.title-card { width: min(420px, 92vw); padding: 30px 28px; background: rgba(16, 10, 12, .82); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 0 60px #ff6a2033, inset 0 0 40px #00000080; display: flex; flex-direction: column; gap: 12px; backdrop-filter: blur(4px); }
.logo { font-family: var(--display); font-weight: 900; font-size: 44px; text-align: center; letter-spacing: 3px; color: #f0e0c8; text-shadow: 0 0 24px #ff6a2066; }
.logo .ember { color: var(--ember); text-shadow: 0 0 20px #ff6a20, 0 0 50px #ff3a10aa; }
.tagline { text-align: center; color: var(--dim); font-style: italic; margin-top: -8px; margin-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--dim); }
input { background: #120c0c; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font: inherit; outline: none; }
input:focus { border-color: var(--gold); }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 800; }
#title-err { color: #ff7060; min-height: 1em; font-size: 13px; text-align: center; }
#title-status { color: var(--gold); font-size: 13px; text-align: center; min-height: 1em; }
.how { font-size: 12px; color: var(--dim); line-height: 1.5; border-top: 1px solid #ffffff14; padding-top: 10px; }

/* ---------- hud ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 10; }
#vitals { position: absolute; left: 18px; bottom: 18px; display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
.portrait { width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--gold); background: radial-gradient(#3a2a2a, #140c0c); display: flex; align-items: center; justify-content: center; position: relative; box-shadow: 0 0 16px #000; }
.pclass { font-size: 30px; }
.plvl { position: absolute; bottom: -6px; right: -6px; background: #1a1010; border: 2px solid var(--gold); border-radius: 50%; width: 26px; height: 26px; font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.bars { display: flex; flex-direction: column; gap: 5px; width: 300px; }
.hpbar { position: relative; height: 22px; background: #200c0c; border: 1px solid #000; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.hp-fill, .hp-trail, .sh-fill { position: absolute; left: 0; top: 0; bottom: 0; }
.hp-trail { background: #f0d0a0; opacity: .5; z-index: 0; }
.hp-fill { background: linear-gradient(#e85050, #a02020); z-index: 1; transition: width .08s; }
.sh-fill { background: linear-gradient(#c8e8ff99, #6ab0ff99); z-index: 2; }
.hp-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; z-index: 3; text-shadow: 0 1px 2px #000; }
.xpbar { position: relative; height: 10px; background: #12100a; border: 1px solid #000; border-radius: 3px; overflow: hidden; }
.xp-fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #c08020, #ffd060); }
.xp-text { position: absolute; inset: 0; font-size: 9px; font-weight: 800; display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 1px #000; }
.dodges { display: flex; gap: 4px; }
.dodges .pip { width: 26px; height: 6px; border-radius: 3px; background: #2a2424; position: relative; overflow: hidden; }
.dodges .pip.full { background: #a0d8ff; box-shadow: 0 0 6px #60b0ff; }
.dodges .pip.filling::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--f) * 100%); background: #4a6a80; }
#abilities { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; }
.slot { width: 58px; height: 58px; border-radius: 8px; background: radial-gradient(#3a2c28, #1a1212); border: 2px solid #5a4a3a; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px #0008; }
.slot.ult { width: 66px; height: 66px; border-color: #b06020; }
.slot.ready { border-color: var(--gold); box-shadow: 0 0 12px #e8b86055, 0 4px 12px #0008; }
.slot.ult.ready { box-shadow: 0 0 22px #ff6a20aa; border-color: #ffa040; animation: pulse 1.6s infinite; }
.slot.empty, .slot.locked { opacity: .35; }
.slot .icon { font-size: 28px; filter: drop-shadow(0 2px 2px #000); }
.slot .cd { position: absolute; left: 0; right: 0; bottom: 0; background: #000b; }
.slot .cdnum { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; text-shadow: 0 1px 3px #000; }
.slot .key { position: absolute; right: 3px; bottom: 1px; font-size: 10px; font-weight: 800; color: var(--gold2); text-shadow: 0 1px 2px #000; }
@keyframes pulse { 50% { box-shadow: 0 0 34px #ff8a30; } }
#resources { position: absolute; right: 18px; bottom: 18px; display: flex; gap: 14px; font-weight: 800; font-size: 18px; text-shadow: 0 2px 4px #000; }
#resources .gold { color: #ffd050; } #resources .ember { color: #ff8a40; } #resources .kills { color: #c8b8b0; font-size: 15px; }
#relic-strip { position: absolute; right: 18px; bottom: 54px; display: flex; flex-wrap: wrap-reverse; gap: 4px; max-width: 46vw; justify-content: flex-end; pointer-events: auto; }
.relic { width: 32px; height: 32px; background: #1a1212e0; border: 2px solid #888; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.relic.set { border-color: var(--gold2); box-shadow: 0 0 10px #ffd08088; }
.relic.small { width: 30px; height: 30px; display: inline-flex; margin: 2px; }
#lvl-badge { position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%); background: linear-gradient(#b8742a, #7a4418); border: 1px solid var(--gold2); padding: 6px 14px; border-radius: 20px; font-weight: 800; font-size: 13px; pointer-events: auto; cursor: pointer; display: none; animation: pulse 1.4s infinite; }
#party-frames { position: absolute; left: 18px; top: 18px; display: flex; flex-direction: column; gap: 8px; }
.pf { display: flex; gap: 8px; align-items: center; background: #140c0cc0; border-left: 3px solid; padding: 6px 10px 6px 6px; border-radius: 4px; width: 210px; }
.pf.down { filter: grayscale(1); opacity: .7; }
.pf-icon { font-size: 22px; }
.pf-body { flex: 1; }
.pf-name { font-size: 12px; font-weight: 700; }
.pf-hp { position: relative; height: 8px; background: #2a1010; border-radius: 3px; overflow: hidden; margin-top: 3px; }
.pf-fill { position: absolute; left: 0; top: 0; bottom: 0; background: #d84040; }
.pf-sh { position: absolute; left: 0; top: 0; bottom: 0; background: #a0d0ff99; }

#bossbar { position: fixed; top: 22px; left: 50%; transform: translateX(-50%); width: min(720px, 80vw); text-align: center; z-index: 11; display: none; pointer-events: none; }
#bossbar.show { display: block; animation: drop .6s; }
#bossbar.phase .boss-track { box-shadow: 0 0 30px #ff4020; }
.boss-name { font-family: var(--display); font-size: 26px; font-weight: 900; letter-spacing: 2px; text-shadow: 0 0 14px #000, 0 0 30px #ff402066; }
.boss-title { font-size: 12px; color: var(--dim); letter-spacing: 3px; text-transform: uppercase; margin-bottom: 6px; }
.boss-track { position: relative; height: 16px; background: #1a0808; border: 1px solid #000; border-radius: 3px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); transition: box-shadow .3s; }
.boss-fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#e04030, #801010); z-index: 2; }
.boss-trail { position: absolute; left: 0; top: 0; bottom: 0; background: #ffd0a0; opacity: .6; z-index: 1; }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -20px); } }
#timer { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); font-family: var(--display); font-size: 24px; font-weight: 700; z-index: 11; display: none; color: #ffb060; text-shadow: 0 2px 6px #000; }
#banner { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); text-align: center; z-index: 12; opacity: 0; transition: opacity .5s; pointer-events: none; }
#banner.show { opacity: 1; }
.b-world { font-family: var(--display); letter-spacing: 6px; color: var(--gold); font-size: 16px; }
.b-title { font-family: var(--display); font-weight: 900; font-size: 54px; text-shadow: 0 0 30px #000, 0 0 60px #ff6a2044; }
.b-sub { font-family: var(--display); font-size: 20px; color: #e8d8c0; text-shadow: 0 2px 8px #000; }
.b-small { font-size: 13px; color: var(--dim); text-shadow: 0 1px 4px #000; }
#prompt { position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%); background: #120a0ad8; border: 1px solid var(--line); padding: 8px 16px; border-radius: 6px; font-weight: 600; z-index: 12; display: none; pointer-events: none; }
#toasts { position: fixed; top: 90px; right: 18px; display: flex; flex-direction: column; gap: 6px; z-index: 30; align-items: flex-end; pointer-events: none; }
.toast { background: #140c0ce8; border: 1px solid var(--line); border-left-width: 4px; padding: 8px 14px; border-radius: 4px; font-weight: 600; animation: slidein .3s; transition: opacity .5s, transform .5s; }
.toast.out { opacity: 0; transform: translateX(30px); }
@keyframes slidein { from { opacity: 0; transform: translateX(30px); } }
#party-info { position: fixed; top: 18px; right: 18px; background: #140c0cd0; border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; z-index: 20; display: none; font-size: 13px; min-width: 200px; }
body[data-phase="run"] #party-info { display: none !important; }
#party-info .code { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
#party-info .code b { letter-spacing: 3px; font-size: 18px; color: var(--gold2); }
#party-info .member { font-weight: 600; }
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .45s; z-index: 40; }
#fade.on { opacity: 1; }
#tooltip { position: fixed; display: none; max-width: 290px; background: #120a0af2; border: 1px solid var(--gold); padding: 9px 12px; border-radius: 6px; font-size: 13px; line-height: 1.45; z-index: 100; pointer-events: none; box-shadow: 0 6px 20px #000a; }
#tooltip small { color: var(--dim); }

/* floating combat text */
#floaters { position: fixed; inset: 0; pointer-events: none; z-index: 9; overflow: hidden; }
.floater { position: absolute; left: 0; top: 0; font-weight: 800; font-size: 17px; color: #fff4e0; text-shadow: 0 2px 0 #000, 0 0 6px #000; white-space: nowrap; will-change: transform; }
.floater.crit { color: #ffd030; font-size: 26px; text-shadow: 0 2px 0 #6a2000, 0 0 10px #ff8000; }
.floater.dot { font-size: 13px; opacity: .9; }
.floater.heal { color: #70ff90; font-size: 16px; }
.floater.big { font-family: var(--display); font-size: 22px; font-weight: 900; }

/* ---------- panels & modals ---------- */
#panels, #modals { position: fixed; inset: 0; pointer-events: none; z-index: 35; }
.panel { pointer-events: auto; position: absolute; right: 24px; top: 50%; transform: translateY(-50%); width: min(560px, 94vw); max-height: 86vh; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 60px #000c; animation: fadein .2s; }
.panel.wide { width: min(980px, 96vw); left: 50%; right: auto; transform: translate(-50%, -50%); }
@keyframes fadein { from { opacity: 0; } }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-family: var(--display); margin: 0; flex: 1; font-size: 22px; color: var(--gold2); }
.panel-head .embers { font-weight: 800; color: #ff9a50; }
.close { background: none; border: none; color: var(--dim); font-size: 20px; cursor: pointer; }
.panel-body { padding: 14px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.panel-body::-webkit-scrollbar { width: 8px; } .panel-body::-webkit-scrollbar-thumb { background: #4a3a30; border-radius: 4px; }
.modal-wrap { pointer-events: auto; position: absolute; inset: 0; background: radial-gradient(ellipse at center, #0008, #000c); display: flex; align-items: center; justify-content: center; animation: fadein .25s; }
.choice { width: min(1000px, 96vw); max-height: 92vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.choice h1, .choice h2 { font-family: var(--display); text-align: center; margin: 0; color: var(--gold2); text-shadow: 0 0 20px #ff6a2066; }
.choice h1 { font-size: 64px; }
.choice.runend.win h1 { color: #ffe080; }
.choice.pause { width: min(520px, 94vw); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.cards { display: flex; gap: 14px; flex-wrap: wrap; }
.cards.three { justify-content: center; }
.cards.three > .card { width: 270px; }
.card { background: linear-gradient(#24181a, #160e10); border: 1px solid #4a3a30; border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 6px; transition: transform .12s, border-color .12s, box-shadow .12s; }
.relic-card, .aug-card { cursor: pointer; align-items: center; text-align: center; border-width: 2px; padding: 22px 16px; }
.relic-card:hover, .aug-card:hover { transform: translateY(-6px); box-shadow: 0 10px 40px #ffa04044; border-color: var(--gold2); }
.aug-card.unique { border-color: #c070ff; box-shadow: 0 0 20px #c070ff33; }
.card.selected { border-color: var(--gold); box-shadow: 0 0 16px #e8b86033; }
.card.locked { opacity: .55; }
.big-icon { font-size: 54px; filter: drop-shadow(0 4px 8px #000); }
.card-title { font-weight: 800; font-size: 15px; }
.card-sub { color: #cdbdaa; font-size: 13px; line-height: 1.45; }
.card-sub.center { text-align: center; }
.card-meta { color: var(--dim); font-size: 12px; }
.rarity { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
.setnote { margin-top: 6px; color: var(--gold2); font-size: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row.center { justify-content: center; }
.maxed { color: var(--gold); font-weight: 800; text-align: center; padding: 8px; }
.tag { margin-left: 8px; font-size: 10px; font-weight: 800; background: #6a4418; color: #ffe0a0; padding: 2px 6px; border-radius: 3px; vertical-align: middle; }

.class-row { border: 1px solid #3a2c26; border-radius: 10px; padding: 12px; background: #1a1012; }
.class-head { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.class-head .role { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 2px; }
.class-head .clvl { margin-left: auto; color: var(--gold); font-weight: 800; }
.class-desc { color: #bfae9a; font-size: 13px; margin: 4px 0 10px; }
.cicon { font-size: 22px; } .cicon.big { font-size: 40px; }
.cards > .card.hero { width: calc(50% - 7px); min-width: 220px; }
.hero-swatch { height: 70px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 34px; box-shadow: inset 0 0 30px #0008; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.tab { background: none; border: none; color: var(--dim); padding: 8px 14px; cursor: pointer; font-weight: 700; border-bottom: 2px solid transparent; }
.tab.active { color: var(--gold2); border-bottom-color: var(--gold); }
.prof-head { display: flex; gap: 14px; align-items: center; }
.xpline { height: 6px; background: #2a2018; border-radius: 3px; width: 260px; overflow: hidden; margin-top: 4px; }
.xpline > div { height: 100%; background: linear-gradient(90deg, #c08020, #ffd060); }
.pts { display: flex; justify-content: space-between; align-items: center; font-weight: 800; color: var(--gold2); }
.trees { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tree { background: #160e10; border: 1px solid #3a2c26; border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.tree h3 { margin: 0; text-align: center; font-family: var(--display); color: var(--gold); }
.tier { display: flex; gap: 8px; justify-content: center; }
.tnode { flex: 1; max-width: 140px; background: #22181a; border: 2px solid #3a2e28; border-radius: 8px; padding: 8px 6px; text-align: center; cursor: pointer; transition: border-color .12s, transform .1s; }
.tnode.can:hover { transform: translateY(-2px); border-color: var(--gold2); }
.tnode.can { border-color: #8a6a3a; }
.tnode.has { border-color: var(--gold); background: #33231a; box-shadow: 0 0 10px #e8b86033; }
.tnode.locked { opacity: .35; cursor: default; }
.tnode.cap { border-style: double; border-width: 3px; }
.tname { font-size: 12px; font-weight: 700; }
.trank { font-size: 11px; color: var(--dim); }
.attr { display: grid; grid-template-columns: 150px 1fr 40px 40px; gap: 10px; align-items: center; background: #1a1012; border: 1px solid #3a2c26; padding: 10px; border-radius: 8px; }
.attr.primary { border-color: #8a6a3a; }
.aname { font-weight: 800; }
.adesc { font-size: 12px; color: var(--dim); }
.aval { font-size: 20px; font-weight: 800; text-align: center; color: var(--gold2); }
.statgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.stat { display: flex; justify-content: space-between; background: #1a1012; padding: 7px 10px; border-radius: 6px; font-size: 13px; }
.stat span { color: var(--dim); }
.abil-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.card.abil { cursor: default; }
.upg { display: flex; gap: 12px; align-items: center; background: #1a1012; border: 1px solid #3a2c26; border-radius: 8px; padding: 10px; }
.uicon { font-size: 28px; width: 40px; text-align: center; }
.ubody { flex: 1; }
.ulvl { color: var(--dim); font-size: 12px; }
.pips { display: flex; gap: 3px; margin-top: 4px; }
.pips .pip { width: 16px; height: 5px; background: #3a2c26; border-radius: 2px; }
.pips .pip.full { background: var(--gold); }
.kin { display: flex; gap: 12px; align-items: center; background: #1a1012; border: 1px solid #3a2c26; border-radius: 8px; padding: 10px; cursor: pointer; }
.kin.selected { border-color: var(--ember); box-shadow: 0 0 14px #ff6a2033; }
.kin.locked { opacity: .35; cursor: default; }
.klvl { width: 34px; height: 34px; border-radius: 50%; background: #3a1a10; border: 1px solid var(--ember); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #ffb070; }
.relic-row { display: flex; flex-wrap: wrap; }
.stat-line { color: #cdbdaa; }
.shopgrid { justify-content: center; }
.shopgrid .card { width: 210px; align-items: center; text-align: center; border-width: 2px; }
.shop-item.sold { opacity: .4; }
.rewards { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.rw { font-size: 20px; font-weight: 800; }
.rw.gold { color: var(--gold2); font-size: 15px; }
label.set { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
label.set input[type=range] { width: 220px; padding: 0; }
@media (max-width: 760px) { .trees { grid-template-columns: 1fr; } .bars { width: 200px; } .slot { width: 46px; height: 46px; } .slot.ult { width: 52px; height: 52px; } }

#world-overlay { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; }
.floater.hurt { color: #ff5040; font-size: 19px; text-shadow: 0 2px 0 #3a0000, 0 0 8px #ff2000; }
.floater.hurt.ally { font-size: 14px; opacity: .85; }
