:root {
  --gold: #e8c27a;
  --gold-dim: #b9985a;
  --ink: #0c0d12;
  --panel: rgba(14, 16, 24, 0.82);
  --panel-edge: rgba(232, 194, 122, 0.35);
  --hp: linear-gradient(180deg, #57d36a, #2e9c44);
  --hp-enemy: linear-gradient(180deg, #e0564f, #a3271f);
  --shadow: 0 6px 24px rgba(0,0,0,0.55);
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #05060a; font-family: var(--font); color: #f1e9d6; }
body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; }

#game { display: block; width: 100vw; height: 100vh; outline: none; cursor: default; }
#game.looking { cursor: none; }

.hidden { display: none !important; }

/* ---------- Title / character select ---------- */
#title { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; transition: opacity 0.6s ease; }
#title.fade { opacity: 0; pointer-events: none; }
.title-bg { position: absolute; inset: 0; background:
  radial-gradient(circle at 50% 28%, #28324f 0%, #0a0d18 70%),
  linear-gradient(180deg, #0b1020, #05060c); }
.title-bg::after { content: ""; position: absolute; inset: 0; background-image:
  radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.7), transparent),
  radial-gradient(1px 1px at 70% 20%, rgba(255,255,255,.6), transparent),
  radial-gradient(1px 1px at 40% 60%, rgba(255,255,255,.5), transparent),
  radial-gradient(1.5px 1.5px at 85% 50%, rgba(255,255,255,.8), transparent),
  radial-gradient(1px 1px at 15% 75%, rgba(255,255,255,.6), transparent),
  radial-gradient(1px 1px at 60% 80%, rgba(255,255,255,.5), transparent);
  opacity: .7; }
.title-inner { position: relative; width: min(720px, 92vw); text-align: center; }
.title-logo { font-size: 76px; font-weight: 800; letter-spacing: 7px; color: #f4ead2; text-shadow: 0 6px 40px rgba(232,194,122,0.35); }
.title-logo span { color: var(--gold); }
.title-tag { margin-top: 4px; color: #9fb0c8; letter-spacing: 1px; font-size: 14px; }
.title-tag em { color: var(--gold-dim); }
#account-bar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; font-size: 13px; color: #9fb0c8; }
#account-bar .ab-status b { color: var(--gold); }
#account-bar .ab-tip { color: #6f7c92; font-style: italic; }
#account-bar .ab-link { font-family: var(--font); font-size: 13px; font-weight: 700; cursor: pointer; color: #1a1306; background: linear-gradient(180deg, var(--gold), var(--gold-dim)); border: 1px solid var(--gold); border-radius: 6px; padding: 4px 12px; transition: filter .12s; }
#account-bar .ab-link:hover { filter: brightness(1.15); }
#auth-form { margin-top: 22px; }
#auth-form input { width: 100%; padding: 12px 14px; font-family: var(--font); font-size: 15px; color: #f3ead4; text-align: center; background: #11151f; border: 1px solid var(--panel-edge); border-radius: 9px; margin-bottom: 12px; }
#auth-form input:focus { outline: none; border-color: var(--gold); }
#auth-error { color: #ff9b90; font-size: 13px; min-height: 18px; margin-bottom: 4px; }
.cs-loading { text-align: center; color: #6f7c92; padding: 16px; letter-spacing: 4px; }
.cs-head { font-size: 14px; letter-spacing: 3px; text-transform: uppercase; color: var(--gold); margin: 22px 0 14px; font-weight: 700; }
#char-list { display: flex; flex-direction: column; gap: 10px; max-height: 38vh; overflow-y: auto; padding: 2px; }
.char-card { display: flex; align-items: center; gap: 14px; padding: 12px 16px; cursor: pointer; text-align: left;
  background: linear-gradient(180deg, rgba(28,34,50,0.9), rgba(16,20,30,0.9)); border: 1px solid var(--panel-edge);
  border-radius: 10px; box-shadow: var(--shadow); transition: transform .1s, border-color .15s, filter .15s; }
.char-card:hover { transform: translateY(-2px); border-color: var(--gold); filter: brightness(1.12); }
.char-card .cc-emblem { width: 46px; height: 46px; flex: 0 0 46px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 26px; background: radial-gradient(circle at 40% 30%, #39435c, #161a26); border: 1px solid var(--panel-edge); }
.char-card .cc-info { flex: 1; min-width: 0; }
.char-card .cc-cname { font-size: 17px; font-weight: 800; color: #f4ecd6; }
.char-card .cc-meta { font-size: 12px; color: #93a0b8; margin-top: 2px; }
.char-card .cc-play { color: var(--gold); font-weight: 800; font-size: 13px; letter-spacing: 1px; }
.char-card .cc-del { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 6px; border: 1px solid #5a3a3a; background: #2a1c1c; color: #ff9b90; font-weight: 800; cursor: pointer; }
.char-card .cc-del:hover { background: #4a2424; }
.cs-bigbtn, .cs-primary, .cc-actions button { font-family: var(--font); cursor: pointer; border-radius: 9px; font-weight: 700; transition: filter .12s, transform .1s; }
.cs-bigbtn { margin-top: 14px; width: 100%; padding: 13px; font-size: 15px; color: #f3e8cf; background: linear-gradient(180deg, #28303f, #181d28); border: 1px dashed var(--panel-edge); }
.cs-bigbtn:hover { filter: brightness(1.2); border-style: solid; }
#cc-name { width: 100%; padding: 12px 14px; font-family: var(--font); font-size: 16px; color: #f3ead4; text-align: center;
  background: #11151f; border: 1px solid var(--panel-edge); border-radius: 9px; margin-bottom: 16px; }
#cc-name:focus { outline: none; border-color: var(--gold); }
#cc-classes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.class-card { padding: 16px 12px; cursor: pointer; border-radius: 11px; text-align: center;
  background: linear-gradient(180deg, rgba(28,34,50,0.9), rgba(16,20,30,0.9)); border: 2px solid #2c3447; transition: all .14s; }
.class-card:hover { border-color: var(--gold-dim); transform: translateY(-3px); }
.class-card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(232,194,122,0.35), var(--shadow); }
.class-card .cl-emblem { font-size: 34px; }
.class-card .cl-name { font-size: 17px; font-weight: 800; color: #f4ecd6; margin: 4px 0; }
.class-card .cl-stats { font-size: 11px; color: var(--gold-dim); font-variant-numeric: tabular-nums; }
.class-card .cl-blurb { font-size: 11.5px; color: #9aa6bb; line-height: 1.4; margin-top: 6px; min-height: 46px; }
.cc-actions { display: flex; gap: 12px; margin-top: 18px; }
.cc-actions button { flex: 1; padding: 12px; font-size: 14px; }
#cc-back { color: #c8d2e4; background: #1b2230; border: 1px solid #33405a; }
.cs-primary { color: #1a1306; background: linear-gradient(180deg, var(--gold), var(--gold-dim)); border: 1px solid var(--gold); }
.cs-primary:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.cs-primary:not(:disabled):hover { filter: brightness(1.15); }
.title-foot { margin-top: 26px; font-size: 12px; color: #6f7c92; font-style: italic; }

/* ---------- Loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, #1a2236, #06070c 75%);
  transition: opacity 0.8s ease;
}
#loader.fade { opacity: 0; pointer-events: none; }
.loader-inner { text-align: center; }
.loader-title { font-size: 72px; font-weight: 800; letter-spacing: 6px; color: #f4ead2; text-shadow: 0 4px 30px rgba(232,194,122,0.4); }
.loader-title span { color: var(--gold); }
.loader-sub { margin-top: 6px; font-style: italic; color: #9fb0c8; letter-spacing: 1px; }
.loader-barwrap { width: 320px; height: 6px; margin: 28px auto 10px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; }
#loader-bar { width: 0%; height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold)); transition: width 0.3s ease; }
#loader-status { font-size: 13px; color: #7e8aa0; letter-spacing: 1px; }

/* ---------- HUD generic ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }

/* ---------- Unit frames ---------- */
#player-frame { position: absolute; top: 18px; left: 18px; }
/* party frames */
#party-frames { position: absolute; top: 92px; left: 18px; width: 230px; background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px; box-shadow: var(--shadow); backdrop-filter: blur(4px); padding: 8px 10px; }
.pf-head { font-size: 11px; letter-spacing: 2px; color: var(--gold); font-weight: 700; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
#pf-leave { font-family: var(--font); font-size: 10px; font-weight: 700; cursor: pointer; color: #ffb4ab; background: #2a1c1c; border: 1px solid #5a3a3a; border-radius: 5px; padding: 2px 7px; }
#pf-leave:hover { filter: brightness(1.3); }
.pf-member { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.pf-emblem { font-size: 16px; }
.pf-info { flex: 1; min-width: 0; }
.pf-name { font-size: 12px; font-weight: 700; color: #f0e8d4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pf-member.me .pf-name { color: #ffe08a; }
.pf-name .pf-leader { color: var(--gold); }
.pf-barwrap { height: 9px; margin-top: 2px; background: #11141d; border: 1px solid rgba(0,0,0,0.6); border-radius: 4px; overflow: hidden; }
.pf-bar { height: 100%; background: var(--hp); transition: width .3s; }
/* party invite popup */
#party-invite { position: absolute; top: 30%; left: 50%; transform: translateX(-50%); background: linear-gradient(180deg, rgba(18,21,31,0.97), rgba(10,12,18,0.97)); border: 1px solid var(--gold); border-radius: 12px; box-shadow: 0 10px 50px rgba(0,0,0,0.7); padding: 16px 20px; text-align: center; z-index: 30; }
.pi-text { font-size: 15px; color: #f1e9d6; margin-bottom: 14px; }
.pi-text b { color: var(--gold); }
.pi-actions { display: flex; gap: 10px; justify-content: center; }
.pi-actions button { font-family: var(--font); font-size: 13px; font-weight: 700; cursor: pointer; padding: 8px 18px; border-radius: 8px; color: #f3e8cf; background: linear-gradient(180deg, #2c3447, #1a2030); border: 1px solid var(--panel-edge); }
.pi-actions button:hover { filter: brightness(1.2); }
.roster-invite { font-family: var(--font); font-size: 10px; font-weight: 700; cursor: pointer; color: #1a1306; background: var(--gold); border: none; border-radius: 5px; padding: 3px 8px; margin-left: auto; }
.roster-invite:hover { filter: brightness(1.15); }
#chat-feed .cm.party .cm-name { color: #9af0c8; }
#chat-feed .cm.party .cm-text { color: #cfeede; }

#target-frame { position: absolute; top: 92px; left: 18px; }
body.has-party #target-frame { top: 286px; }
.unit-frame {
  display: flex; gap: 10px; width: 320px; padding: 10px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px;
  box-shadow: var(--shadow); backdrop-filter: blur(4px);
}
.uf-portrait {
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: radial-gradient(circle at 40% 30%, #39435c, #161a26);
  border: 1px solid var(--panel-edge); color: var(--gold);
}
.uf-body { flex: 1; min-width: 0; }
.uf-name { font-weight: 700; font-size: 15px; color: #f6efdc; text-shadow: 0 1px 2px #000; }
.uf-barwrap { position: relative; height: 18px; margin: 4px 0 3px; background: #11141d; border: 1px solid rgba(0,0,0,0.6); border-radius: 5px; overflow: hidden; }
.uf-bar { height: 100%; width: 100%; transition: width 0.45s cubic-bezier(.2,.8,.2,1); }
.uf-bar.hp { background: var(--hp); }
#target-hp-bar { background: var(--hp-enemy); }
.uf-bartext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; letter-spacing: .5px; }
.uf-level { font-size: 11px; color: #93a0b8; font-style: italic; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uf-lv { font-size: 11px; font-weight: 800; color: #1a1306; background: var(--gold); padding: 1px 6px; border-radius: 4px; vertical-align: middle; }
.uf-xpwrap { position: relative; height: 9px; margin-top: 4px; background: #11141d; border: 1px solid rgba(0,0,0,0.6); border-radius: 4px; overflow: hidden; }
.uf-xp { height: 100%; width: 0%; background: linear-gradient(180deg, #b06bff, #7a3fd6); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.uf-xptext { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: #e9ddff; text-shadow: 0 1px 2px #000; letter-spacing: .4px; }

/* ---------- Quest tracker ---------- */
#quest-tracker { margin-top: 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 10px; box-shadow: var(--shadow); backdrop-filter: blur(4px); }
.qt-head { font-size: 11px; letter-spacing: 2px; color: var(--gold); font-weight: 700; margin-bottom: 6px; }
.qt-quest { margin-bottom: 8px; }
.qt-quest:last-child { margin-bottom: 0; }
.qt-name { font-size: 13px; font-weight: 700; color: #f0e8d4; text-shadow: 0 1px 2px #000; }
.qt-obj { font-size: 12px; color: #b6c2d6; margin-top: 1px; display: flex; align-items: center; gap: 6px; }
.qt-obj .qt-count { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.qt-obj.done { color: #7ee68a; }
.qt-obj.done .qt-count { color: #7ee68a; }
.qt-ready { font-size: 11px; color: #ffe08a; font-style: italic; margin-top: 2px; }

/* ---------- Generic panels (inventory / quest log) ---------- */
.panel {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: linear-gradient(180deg, rgba(18,21,31,0.97), rgba(10,12,18,0.97));
  border: 1px solid var(--panel-edge); border-radius: 12px; box-shadow: 0 10px 50px rgba(0,0,0,0.7);
  padding: 16px 18px; z-index: 20;
}
#inventory { right: 26px; width: 320px; }
#quest-log { left: 26px; width: 380px; max-height: 76vh; overflow-y: auto; }
.panel-title { font-size: 17px; font-weight: 800; color: var(--gold); letter-spacing: .5px; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel-sub { font-size: 13px; color: #ffe08a; font-weight: 700; margin-left: auto; }
.panel-x { cursor: pointer; color: #889; font-weight: 700; margin-left: 8px; }
.panel-x:hover { color: #fff; }
.panel-note { margin-top: 12px; font-size: 11.5px; color: #7e8aa0; font-style: italic; line-height: 1.5; }

/* inventory grid */
#inv-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.inv-slot {
  position: relative; aspect-ratio: 1; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 26px; background: linear-gradient(180deg, #1c2230, #12161f); border: 1px solid #2c3447;
}
.inv-slot.has { border-color: var(--gold-dim); cursor: default; }
.inv-slot.use { cursor: pointer; }
.inv-slot.use:hover { border-color: var(--gold); filter: brightness(1.2); }
.inv-slot.relic { border-color: #b06bff; box-shadow: inset 0 0 12px rgba(176,107,255,0.25); }
.inv-qty { position: absolute; bottom: 2px; right: 4px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }

/* item tooltip */
#item-tooltip {
  position: absolute; z-index: 40; max-width: 220px; padding: 8px 10px; pointer-events: none;
  background: rgba(8,10,16,0.96); border: 1px solid var(--panel-edge); border-radius: 8px; box-shadow: var(--shadow);
}
#item-tooltip .it-name { font-weight: 800; font-size: 14px; }
#item-tooltip .it-kind { font-size: 11px; color: #8aa; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
#item-tooltip .it-desc { font-size: 12.5px; color: #cdd5e4; line-height: 1.45; }
#item-tooltip .it-effect { font-size: 12px; color: #7ee68a; margin-top: 4px; }

/* codex / lore */
#codex { left: 26px; width: 420px; max-height: 80vh; overflow-y: auto; }
.codex-entry { padding: 11px 12px; border-radius: 10px; background: rgba(255,225,150,0.05); border: 1px solid rgba(232,194,122,0.18); margin-bottom: 10px; }
.codex-entry.locked { background: rgba(255,255,255,0.02); border-color: rgba(255,255,255,0.06); opacity: 0.7; }
.cx-title { font-size: 14px; font-weight: 800; color: var(--gold); margin-bottom: 5px; }
.codex-entry.locked .cx-title { color: #6f7c92; }
.cx-text { font-size: 13px; line-height: 1.55; color: #d8d0bf; font-style: italic; }
.codex-entry.locked .cx-text { color: #6f7c92; }

/* quest log entries */
.ql-quest { padding: 12px; border-radius: 10px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07); margin-bottom: 12px; }
.ql-quest.turnedin { opacity: 0.6; }
.ql-qhead { display: flex; align-items: center; justify-content: space-between; }
.ql-qname { font-size: 15px; font-weight: 800; color: #f3ead4; }
.ql-qstate { font-size: 10px; font-weight: 800; letter-spacing: 1px; padding: 2px 7px; border-radius: 4px; }
.ql-qstate.active { background: var(--gold); color: #1a1306; }
.ql-qstate.ready { background: #5ad36a; color: #06210c; }
.ql-qstate.done { background: #3a4356; color: #aeb9cd; }
.ql-qsummary { font-size: 13px; color: #c2ccdd; margin: 6px 0; line-height: 1.5; }
.ql-qobj { font-size: 13px; color: #b6c2d6; }
.ql-qobj .qt-count { color: var(--gold); font-weight: 700; }
.ql-qobj.done { color: #7ee68a; } .ql-qobj.done .qt-count { color: #7ee68a; }
.ql-qreward { font-size: 12px; color: #93a0b8; margin-top: 6px; }
.ql-qreward b { color: #e8c27a; }
.ql-empty { font-size: 13px; color: #8693a8; font-style: italic; text-align: center; padding: 20px; }

/* dialogue action buttons */
#dlg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-right: auto; }
#dlg-actions button { font-family: var(--font); font-size: 13px; font-weight: 700; cursor: pointer; padding: 7px 14px; border-radius: 7px; transition: filter .12s;
  color: #f3e8cf; background: linear-gradient(180deg, #2c3447, #1a2030); border: 1px solid var(--panel-edge); }
#dlg-actions .accept { color: #1a1306; background: linear-gradient(180deg, var(--gold), var(--gold-dim)); border: 1px solid var(--gold); }
#dlg-actions .complete { color: #06210c; background: linear-gradient(180deg, #5ad36a, #2e9c44); border: 1px solid #5ad36a; }
#dlg-actions button:hover { filter: brightness(1.2); }

/* action slot item count badge */
.slot .slot-qty { position: absolute; bottom: 2px; right: 4px; font-size: 12px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.slot.no-charges { opacity: 0.55; }

/* ability slots: level lock + cooldown */
.slot.locked-lvl { filter: grayscale(0.8) brightness(0.6); cursor: not-allowed; }
.slot.locked-lvl:hover { transform: none; }
.slot .lock-lvl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 800; color: #cdd5e4; text-shadow: 0 1px 3px #000; }
.slot .lock-lvl::before { content: "🔒"; margin-right: 3px; font-size: 12px; }

/* ---------- Equipment / character panel ---------- */
#equipment-panel { left: 26px; width: 340px; }
#eq-slots { display: flex; flex-direction: column; gap: 9px; }
.eq-row { display: flex; align-items: center; gap: 10px; }
.eq-sloticon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 22px; background: #11151f; border: 1px solid var(--panel-edge); }
.eq-sloticon.empty { opacity: 0.5; border-style: dashed; }
.eq-item { flex: 1; display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); min-height: 42px; }
.eq-item.empty { color: #6f7c92; font-style: italic; font-size: 13px; }
.eq-itemicon { font-size: 22px; }
.eq-itemname { font-size: 14px; font-weight: 700; color: #f1e9d6; }
.eq-itembonus { font-size: 11px; color: #8ad6a0; }
.eq-unequip { width: 26px; height: 26px; flex: 0 0 26px; border-radius: 6px; border: 1px solid #5a3a3a; background: #2a1c1c; color: #ff9b90; font-weight: 800; cursor: pointer; }
.eq-unequip:hover { background: #4a2424; }
#eq-stats { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.eq-stat { display: flex; justify-content: space-between; font-size: 13px; color: #b6c2d6; }
.eq-stat b { color: #f3e7c8; }
.eq-stat.warded { grid-column: 1 / -1; }
.eq-stat.warded b { color: #8ad6ff; }
#item-tooltip .it-hint { font-size: 11px; color: var(--gold); margin-top: 6px; font-weight: 700; }

/* ---------- Forge / crafting panel ---------- */
#forge-panel { right: 26px; width: 380px; max-height: 80vh; overflow-y: auto; }
.forge-qhead { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; }
#forge-queue { margin-bottom: 12px; }
.forge-qrow { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: rgba(232,194,122,0.08); border: 1px solid rgba(232,194,122,0.25); margin-bottom: 6px; }
.forge-qicon { font-size: 20px; }
.forge-qname { flex: 1; font-size: 13px; font-weight: 700; color: #f1e9d6; }
.forge-qticks { font-size: 12px; color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.forge-recipe { display: flex; align-items: center; gap: 11px; padding: 10px; border-radius: 10px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.08); margin-bottom: 9px; }
.forge-recipe.poor { opacity: 0.72; }
.forge-out { position: relative; width: 44px; height: 44px; flex: 0 0 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 24px; background: #11151f; border: 1px solid var(--panel-edge); }
.forge-outqty { position: absolute; bottom: 1px; right: 3px; font-size: 11px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000; }
.forge-mid { flex: 1; min-width: 0; }
.forge-rname { font-size: 14px; font-weight: 800; color: #f3ead4; }
.forge-rticks { font-size: 11px; color: var(--gold-dim); font-weight: 700; }
.forge-rblurb { font-size: 11.5px; color: #9aa6bb; margin: 2px 0 5px; }
.forge-costs { display: flex; flex-wrap: wrap; gap: 8px; }
.forge-cost { font-size: 12px; color: #b6c2d6; }
.forge-cost small { color: #6f7c92; }
.forge-cost.ok { color: #8ad6a0; } .forge-cost.ok small { color: #5e8a6e; }
.forge-cost.lack { color: #ff9b90; } .forge-cost.lack small { color: #a36a64; }
.forge-btn { font-family: var(--font); font-size: 13px; font-weight: 800; cursor: pointer; padding: 9px 14px; border-radius: 8px; color: #1a1306; background: linear-gradient(180deg, var(--gold), var(--gold-dim)); border: 1px solid var(--gold); align-self: center; transition: filter .12s; }
.forge-btn:hover:not(:disabled) { filter: brightness(1.15); }
.forge-btn:disabled { opacity: 0.35; cursor: not-allowed; background: #333a48; color: #8693a8; border-color: #3a4356; }

/* level-up flourish */
.float-num.levelup { color: #ffe066; font-size: 30px; text-shadow: 0 0 12px rgba(255,210,80,0.9), 0 2px 4px #000; }

/* ---------- Top-right: tick clock + minimap ---------- */
#top-right { position: absolute; top: 18px; right: 18px; width: 200px; }
#tick-clock {
  padding: 10px 12px; background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 10px; box-shadow: var(--shadow); backdrop-filter: blur(4px); margin-bottom: 10px;
}
.tc-row { display: flex; justify-content: space-between; align-items: center; }
.tc-label { font-size: 11px; letter-spacing: 2px; color: var(--gold); font-weight: 700; }
.tc-mode { font-size: 10px; font-weight: 800; letter-spacing: 1px; padding: 2px 6px; border-radius: 4px; background: #5a2; color: #06120a; }
.tc-mode.prod { background: var(--gold); color: #1a1306; }
.tc-mode.dev { background: #4fc3f7; color: #062032; }
.tc-mode.live { background: #4ade80; color: #06210c; }
#online-badge { margin-top: 7px; font-size: 11px; font-weight: 700; color: #8affc0; letter-spacing: .4px; text-align: center; }
.tc-time { font-size: 14px; margin-top: 5px; color: #f3e7c8; font-weight: 700; letter-spacing: .3px; display: flex; align-items: center; gap: 5px; }
.tc-time #tc-phase { font-size: 11px; color: #9fb0c8; font-weight: 600; margin-left: auto; }
#tick-clock.night { box-shadow: var(--shadow), inset 0 0 22px rgba(80,110,220,0.18); }
#tick-clock.night .tc-time { color: #bcd0ff; }
.tc-count { font-size: 13px; margin-top: 4px; color: #d8e0ee; }
.tc-count span { font-weight: 700; color: #fff; }
.tc-next { font-size: 12px; color: #9fb0c8; margin-top: 2px; }
.tc-next span { color: #f3e7c8; font-variant-numeric: tabular-nums; }
.tc-barwrap { height: 5px; margin-top: 7px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
#tc-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--gold-dim), var(--gold)); }

#minimap-wrap { position: relative; width: 200px; height: 200px; }
#minimap {
  width: 200px; height: 200px; border-radius: 50%;
  border: 3px solid var(--panel-edge); box-shadow: var(--shadow), inset 0 0 30px rgba(0,0,0,0.6);
  background: #0a1a12;
}
#minimap-label { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 11px; letter-spacing: 1px; color: var(--gold); text-shadow: 0 1px 3px #000; font-weight: 700; }

/* ---------- Combat log ---------- */
#log {
  position: absolute; left: 18px; bottom: 150px; width: 380px; max-height: 190px;
  overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
  font-size: 13px; line-height: 1.45; pointer-events: none;
}
#log .line { opacity: 0; animation: logIn 0.3s forwards; text-shadow: 0 1px 3px #000; padding: 1px 0; }
#log .line.fade { animation: logOut 1s forwards; }
.log-dmg { color: #ffd36b; } .log-dmg b { color: #ff8a5b; }
.log-heal { color: #7ee68a; }
.log-info { color: #aeb9cd; }
.log-tick { color: var(--gold); font-style: italic; }
.log-death { color: #ff7b6e; font-weight: 700; }
@keyframes logIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
@keyframes logOut { to { opacity: 0; } }

/* ---------- Chat ---------- */
#chat { position: absolute; left: 18px; bottom: 76px; width: 380px; display: flex; flex-direction: column; gap: 5px; }
#chat-feed { max-height: 150px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; font-size: 13px; line-height: 1.4; pointer-events: none; }
#chat-feed .cm { opacity: 0; animation: logIn 0.25s forwards; text-shadow: 0 1px 3px #000, 0 0 4px #000; padding: 1px 0; }
#chat-feed .cm.fade { animation: logOut 1.2s forwards; }
#chat-feed .cm .cm-name { font-weight: 800; }
#chat-feed .cm .cm-text { color: #ece3cf; }
#chat-feed .cm.system .cm-text { color: #8fb0c8; font-style: italic; }
#chat-feed .cm.me .cm-name { color: #ffe08a; }
#chat-inputwrap { display: flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--gold); border-radius: 8px; padding: 5px 9px; box-shadow: var(--shadow); }
.chat-prompt { font-size: 12px; font-weight: 800; color: var(--gold); }
#chat-input { flex: 1; background: transparent; border: none; outline: none; color: #f3ead4; font-family: var(--font); font-size: 14px; }
#emote-bar { display: flex; gap: 5px; }
.emote-btn { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--panel-edge); background: var(--panel); cursor: pointer; font-size: 16px; line-height: 1; transition: transform .08s, filter .12s; pointer-events: auto; }
.emote-btn:hover { transform: translateY(-2px); filter: brightness(1.3); }

/* speech / emote bubbles over avatars */
.bubble { position: absolute; transform: translate(-50%, -100%); z-index: 11; pointer-events: none;
  background: rgba(248, 246, 238, 0.96); color: #1a1c22; font-size: 13px; font-weight: 600; line-height: 1.3;
  padding: 6px 11px; border-radius: 12px; max-width: 220px; text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  animation: bubbleIn 0.18s ease; }
.bubble::after { content: ""; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: rgba(248,246,238,0.96); border-bottom: 0; }
.bubble.emote { background: none; box-shadow: none; font-size: 40px; padding: 0; }
.bubble.emote::after { display: none; }
@keyframes bubbleIn { from { opacity: 0; transform: translate(-50%, -85%); } to { opacity: 1; transform: translate(-50%, -100%); } }

/* online roster */
#roster { position: absolute; top: 78px; left: 50%; transform: translateX(-50%); width: 300px;
  background: linear-gradient(180deg, rgba(18,21,31,0.97), rgba(10,12,18,0.97)); border: 1px solid var(--panel-edge);
  border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px; z-index: 22; }
.roster-head { font-size: 13px; letter-spacing: 1px; color: var(--gold); font-weight: 800; margin-bottom: 10px; display: flex; justify-content: space-between; }
.roster-row { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; }
.roster-row .r-emblem { font-size: 18px; }
.roster-row .r-name { font-weight: 700; color: #f1e9d6; }
.roster-row .r-meta { margin-left: auto; font-size: 11px; color: #93a0b8; }
.roster-row.me .r-name { color: #ffe08a; }
.roster-empty { font-size: 12px; color: #8693a8; font-style: italic; text-align: center; padding: 8px; }

/* ---------- Settings gear, FPS, panel ---------- */
#settings-btn { position: absolute; top: 18px; right: 230px; width: 36px; height: 36px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--panel-edge); color: var(--gold); font-size: 19px; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .12s, filter .12s; pointer-events: auto; }
#settings-btn:hover { transform: rotate(35deg); filter: brightness(1.25); }
#fps { position: absolute; top: 92px; right: 18px; font-size: 12px; font-weight: 700; color: #8affc0; background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 6px; padding: 2px 8px; box-shadow: var(--shadow); }

#settings-panel { top: 50%; left: 50%; transform: translate(-50%, -50%); width: 460px; max-height: 82vh; overflow-y: auto; }
.settings-group { margin-bottom: 16px; }
.settings-group:last-of-type { margin-bottom: 6px; }
.settings-gname { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); font-weight: 800; margin-bottom: 8px; border-bottom: 1px solid rgba(232,194,122,0.18); padding-bottom: 4px; }
.setting { display: flex; align-items: center; gap: 12px; padding: 8px 2px; }
.setting .s-main { flex: 1; min-width: 0; }
.setting .s-label { font-size: 14px; color: #f1e9d6; font-weight: 600; }
.setting .s-help { font-size: 11.5px; color: #8693a8; margin-top: 1px; line-height: 1.35; }
.setting .s-control { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
/* toggle switch */
.s-toggle { width: 46px; height: 26px; border-radius: 14px; background: #2a3142; border: 1px solid #3a4356; position: relative; cursor: pointer; transition: background .15s; }
.s-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #aeb9cd; transition: left .15s, background .15s; }
.s-toggle.on { background: linear-gradient(180deg, var(--gold), var(--gold-dim)); border-color: var(--gold); }
.s-toggle.on::after { left: 22px; background: #1a1306; }
/* slider */
.s-slider { width: 130px; accent-color: var(--gold); }
.s-val { font-size: 12px; font-weight: 700; color: #f3e7c8; min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.settings-foot { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); text-align: center; }
#settings-reset { font-family: var(--font); font-size: 13px; font-weight: 700; cursor: pointer; color: #ffb4ab; background: #251818; border: 1px solid #a3433a; border-radius: 7px; padding: 8px 16px; transition: filter .12s; }
#settings-reset:hover { filter: brightness(1.25); }

/* reduce motion — calm the animations */
body.reduce-motion .float-num { animation-duration: 0.5s !important; }
body.reduce-motion .bubble, body.reduce-motion #toast .t, body.reduce-motion .slot.queued { animation: none !important; }
body.reduce-motion .uf-bar, body.reduce-motion .uf-xp, body.reduce-motion .np-hp-fill { transition: none !important; }

/* ---------- Toast ---------- */
#toast { position: absolute; top: 26%; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; }
#toast .t {
  display: inline-block; margin-top: 8px; padding: 8px 20px; font-size: 20px; font-weight: 700;
  color: #fff; background: rgba(12,14,22,0.7); border: 1px solid var(--panel-edge); border-radius: 8px;
  text-shadow: 0 2px 8px #000; animation: toastIn 0.4s ease, toastOut 0.5s ease 2.2s forwards;
}
#toast .t.big { font-size: 30px; color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }

/* ---------- Floating combat text (in-world, screen-projected) ---------- */
.float-num {
  position: absolute; font-weight: 800; font-size: 22px; pointer-events: none; z-index: 12;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0,0,0,0.7); transform: translate(-50%, -50%);
  animation: floatUp 1.1s ease-out forwards; will-change: transform, opacity;
}
.float-num.dmg { color: #ffd84d; }
.float-num.dmg-player { color: #ff6a5a; }
.float-num.heal { color: #8cf07f; }
.float-num.miss { color: #cfd6e2; font-size: 18px; }
.float-num.crit { color: #ff8a2a; font-size: 32px; text-shadow: 0 0 10px rgba(255,140,40,0.8), 0 2px 4px #000; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, -90%) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -190%) scale(1); } }

/* ---------- World nameplates ---------- */
.nameplate {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none; z-index: 9;
  text-align: center; transition: opacity .2s;
}
.nameplate .np-name {
  display: inline-block; font-size: 13px; font-weight: 700; padding: 1px 8px; border-radius: 5px;
  text-shadow: 0 1px 3px #000, 0 0 4px #000; white-space: nowrap;
  background: rgba(8,10,16,0.55); border: 1px solid rgba(255,255,255,0.12);
}
.nameplate.friendly .np-name { color: #8ad6ff; }
.nameplate.hostile .np-name { color: #ff8c80; }
.nameplate.remote .np-name { color: #8affc0; }
.nameplate.boss .np-name { font-size: 16px; color: #ff6a4d; padding: 3px 12px; border-color: rgba(255,106,77,0.5); letter-spacing: .5px; box-shadow: 0 0 14px rgba(255,80,50,0.4); }
.nameplate.boss .np-hp { width: 140px; height: 7px; }
.nameplate.remote .np-class { display: block; font-size: 10px; color: #9fb0c8; margin-top: 1px; text-shadow: 0 1px 2px #000; }
.nameplate .np-hp { width: 84px; height: 5px; margin: 3px auto 0; background: #20140f; border: 1px solid rgba(0,0,0,0.6); border-radius: 3px; overflow: hidden; }
.nameplate .np-hp-fill { height: 100%; width: 100%; background: var(--hp-enemy); transition: width .4s; }

/* ---------- Interact prompt ---------- */
#interact-prompt {
  position: absolute; bottom: 210px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 24px;
  padding: 8px 18px; font-size: 15px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px;
}
.key { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px;
  background: var(--gold); color: #1a1306; font-weight: 800; border-radius: 5px; font-size: 13px; box-shadow: 0 2px 0 #8a6d3a; }

/* ---------- Action bar ---------- */
#action-bar { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.slot {
  position: relative; width: 56px; height: 56px; border-radius: 9px;
  background: linear-gradient(180deg, #232a3a, #141925); border: 2px solid #3a4356;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  box-shadow: var(--shadow), inset 0 0 8px rgba(0,0,0,0.5); cursor: pointer; transition: transform .08s, border-color .15s;
}
.slot:hover { transform: translateY(-3px); }
.slot.filled { border-color: var(--gold-dim); }
.slot.filled:hover { border-color: var(--gold); }
.slot.empty { opacity: 0.5; cursor: default; }
.slot.empty:hover { transform: none; }
.slot.locked::after { content: "🔒"; position: absolute; font-size: 16px; opacity: .5; }
.slot .key-bind { position: absolute; top: 2px; left: 4px; font-size: 11px; color: #aeb9cd; font-weight: 700; text-shadow: 0 1px 2px #000; }
.slot .slot-name { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 10px; color: #cdd5e4; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.slot.queued { border-color: var(--gold); animation: pulse 1.1s infinite; }
.slot .cd-fill { position: absolute; inset: 0; background: rgba(232,194,122,0.22); transform-origin: bottom; transform: scaleY(0); border-radius: 7px; }
.slot.active-stance { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(232,194,122,0.6); border-color: var(--gold); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(232,194,122,0.5); } 50% { box-shadow: 0 0 0 5px rgba(232,194,122,0); } }
.slot .gcd { position: absolute; inset: 0; border-radius: 7px; background: conic-gradient(rgba(0,0,0,0.55) var(--a, 0deg), transparent 0deg); }

/* ---------- Hints ---------- */
#hints { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; font-size: 11px; color: #8693a8; pointer-events: none; }
#hints b { color: #d7c290; }

/* ---------- Dialogue ---------- */
#dialogue {
  position: absolute; bottom: 110px; left: 50%; transform: translateX(-50%); width: min(620px, 86vw);
  background: linear-gradient(180deg, rgba(18,21,31,0.96), rgba(10,12,18,0.96));
  border: 1px solid var(--panel-edge); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px;
}
.dlg-name { color: var(--gold); font-weight: 800; font-size: 17px; letter-spacing: .5px; margin-bottom: 6px; }
.dlg-text { font-size: 15.5px; line-height: 1.55; color: #ece3cf; min-height: 60px; }
.dlg-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 12px; }
.dlg-footer button {
  font-family: var(--font); font-size: 13px; font-weight: 700; cursor: pointer; color: #f3e8cf;
  background: linear-gradient(180deg, #2c3447, #1a2030); border: 1px solid var(--panel-edge);
  padding: 7px 14px; border-radius: 7px; transition: filter .12s;
}
.dlg-footer button:hover { filter: brightness(1.25); }
#dlg-next { color: #1a1306; background: linear-gradient(180deg, var(--gold), var(--gold-dim)); border-color: var(--gold); }

/* ---------- Dev panel ---------- */
#dev-panel {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 420px;
  background: linear-gradient(180deg, rgba(16,20,30,0.97), rgba(9,11,17,0.97));
  border: 1px solid #4fc3f7; border-radius: 12px; box-shadow: 0 10px 50px rgba(0,0,0,0.7); padding: 16px 18px;
}
.dev-title { font-size: 17px; font-weight: 800; color: #4fc3f7; letter-spacing: 1px; margin-bottom: 14px; display: flex; justify-content: space-between; }
.dev-x { cursor: pointer; color: #889; font-weight: 700; }
.dev-x:hover { color: #fff; }
.dev-row { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; font-size: 13px; color: #c8d2e4; }
.seg { display: flex; gap: 6px; }
.seg-btn { font-family: var(--font); font-size: 12px; font-weight: 700; cursor: pointer; padding: 7px 10px; border-radius: 7px;
  background: #1b2230; color: #aeb9cd; border: 1px solid #33405a; transition: all .12s; }
.seg-btn:hover { filter: brightness(1.3); }
.seg-btn.on { background: #4fc3f7; color: #06212f; border-color: #4fc3f7; }
#dev-tickrate { width: 90px; font-family: var(--font); background: #11151f; border: 1px solid #33405a; color: #e8eef8; border-radius: 6px; padding: 5px 8px; font-size: 13px; }
.dev-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.dev-actions button { font-family: var(--font); font-size: 13px; font-weight: 700; cursor: pointer; padding: 9px; border-radius: 7px;
  background: linear-gradient(180deg, #28303f, #181d28); color: #e6ddc8; border: 1px solid #3a4356; transition: filter .12s; }
.dev-actions button:hover { filter: brightness(1.3); }
#dev-reset { border-color: #a3433a !important; color: #ffb4ab !important; }
.dev-note { margin-top: 12px; font-size: 11.5px; color: #7e8aa0; line-height: 1.5; font-style: italic; }
