/* ============================================================
   Ashfall — RuneScape-like interface theme
   Stone panels, parchment insets, gold accents.
   ============================================================ */
:root {
  --stone:      #2b2620;
  --stone-2:    #3a342b;
  --stone-lt:   #4a4236;
  --parch:      #cdbb92;
  --parch-2:    #b9a678;
  --ink:        #241d12;
  --gold:       #e7c65a;
  --gold-2:     #b8942f;
  --accent:     #c8873a;
  --danger:     #c0392b;
  --good:       #4caf50;
  --text:       #e8dcc0;
  --text-dim:   #b3a888;
  --border:     #14100a;
  --shadow:     0 6px 20px rgba(0,0,0,.5);
  --font:       "Trebuchet MS", "Segoe UI", system-ui, sans-serif;

  /* ---- unified HUD chrome (one visual language for every floating panel) ---- */
  --radius-lg:  12px;   /* panels, docks, modals */
  --radius-md:  9px;    /* slots, cells, buttons */
  --radius-sm:  6px;    /* bars, chips, small insets */
  --hud-bg:     linear-gradient(180deg, rgba(48,42,33,.94), rgba(26,22,17,.93));
  --hud-edge:   rgba(231,198,90,.20);  /* gold hairline inset — the signature trim */
  --hud-shadow: 0 8px 24px rgba(0,0,0,.55);
  --inset-bg:   rgba(0,0,0,.26);       /* recessed sub-panels (stat boxes, notes) */
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(circle at 50% -10%, #3a3226 0%, #191510 60%, #0d0b07 100%);
  color: var(--text);
  overflow: hidden;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- shared buttons ---------- */
.btn {
  background: linear-gradient(#5a5040, #3a332a);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 7px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: .3px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 2px 4px rgba(0,0,0,.4);
  transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: translateY(1px); }
.btn-gold {
  background: linear-gradient(#f0d97a, #c69a2e);
  color: #3a2c08;
  border-color: #6e5311;
  text-shadow: 0 1px 0 rgba(255,255,255,.3);
}

/* ============================================================
   TITLE / OVERLAY SCREENS
   ============================================================ */
.overlay-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(40,32,20,.6), rgba(6,5,3,.94));
}
.title-card {
  text-align: center;
  padding: 40px 46px;
  background: linear-gradient(180deg, var(--stone-2), var(--stone));
  border: 3px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(231,198,90,.18);
  max-width: 560px;
}
.title-crest { font-size: 52px; filter: drop-shadow(0 3px 5px rgba(0,0,0,.6)); }
.title-name {
  font-size: 68px; letter-spacing: 8px; margin: 6px 0 2px;
  color: var(--gold);
  text-shadow: 0 2px 0 #6e5311, 0 4px 14px rgba(0,0,0,.6);
  font-family: "Georgia", serif;
}
.title-sub { color: var(--text-dim); font-size: 15px; margin-bottom: 24px; }
.title-buttons { display: flex; gap: 14px; justify-content: center; margin-bottom: 22px; }
.title-buttons .btn { padding: 12px 26px; font-size: 16px; }
.title-tips {
  list-style: none; text-align: left; font-size: 12.5px; color: var(--text-dim);
  background: rgba(0,0,0,.25); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px 12px 30px;
}
.title-tips li { margin: 5px 0; position: relative; }
.title-tips li::before { content: "◆"; color: var(--gold-2); position: absolute; left: -18px; }
.title-tips b { color: var(--parch); }

.death-card {
  text-align: center; padding: 40px 50px;
  background: linear-gradient(180deg, #3a2020, #241414);
  border: 3px solid #5a2020; border-radius: 16px; box-shadow: var(--shadow);
}
.death-skull { font-size: 60px; }
.death-card h2 { color: #e88; margin: 10px 0; font-size: 28px; }
.death-card p { color: var(--text-dim); margin-bottom: 22px; }

/* ============================================================
   GAME SHELL LAYOUT — fullscreen canvas + floating HUD overlays
   ============================================================ */
#game {
  position: fixed; inset: 0;
  overflow: hidden;
}
/* World fills the entire viewport; all UI floats on top of it */
#game-canvas {
  position: absolute; inset: 0;
  display: block; width: 100vw; height: 100vh;
  image-rendering: auto; cursor: pointer;
  background: #1a1a1a;
}

/* ---- SHARED HUD CHROME — one look for every floating panel ---- */
#topbar, #sidebar, #chatbar, #action-bar, #style-bar, #cast-bar, .unit-frame {
  background: var(--hud-bg);
  border: 2px solid var(--hud-border, var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--hud-shadow), inset 0 0 0 1px var(--hud-edge);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* ---------- minimap (WoW-style circular, top-right corner) ---------- */
#minimap {
  position: absolute; top: 12px; right: 12px; z-index: 22;
  width: 156px; height: 156px; border-radius: 50%;
  background: #10130d;
  border: 3px solid #1a140a;
  box-shadow:
    0 0 0 2px var(--gold-2),
    0 0 0 5px #14100a,
    inset 0 0 14px rgba(0,0,0,.7),
    var(--hud-shadow);
}
#minimap-canvas {
  position: absolute; inset: 0; width: 156px; height: 156px; border-radius: 50%;
  display: block;
}
.mm-zone {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  z-index: 3; white-space: nowrap;
  padding: 2px 12px; font-size: 11.5px; font-weight: bold; color: var(--gold);
  letter-spacing: .3px; border-radius: 8px;
  background: linear-gradient(180deg, #3a3225, #201a11);
  border: 1px solid var(--gold-2);
  box-shadow: 0 2px 5px rgba(0,0,0,.6);
}
#mm-coords {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  z-index: 3; font-size: 10px; font-weight: bold; color: var(--parch);
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000;
  background: rgba(0,0,0,.5); padding: 0 6px; border-radius: 5px;
}

/* ---------- top stats (compact cluster, under minimap) ---------- */
#topbar {
  position: absolute; top: 180px; right: 12px; left: auto; z-index: 22;
  width: 156px; display: flex; align-items: stretch; justify-content: center; gap: 0;
  padding: 3px; overflow: hidden;
}
.chip {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
  font-size: 12px; padding: 4px 6px; color: var(--text);
  border-left: 1px solid rgba(0,0,0,.5);
  box-shadow: inset 1px 0 0 rgba(231,198,90,.07);
}
.chip:first-child { border-left: none; box-shadow: none; }
.chip b { color: var(--gold); font-variant-numeric: tabular-nums; }

/* ---------- HP orb (floating bottom-left) ---------- */
#orbs { position: absolute; left: 14px; bottom: 14px; z-index: 20; display: flex; gap: 8px; }
.orb {
  position: relative; width: 52px; height: 52px; border-radius: 50%;
  background: #201a12; border: 3px solid var(--border);
  overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.6);
}
.orb-fill {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, #d34a3a, #7a1f1a);
  transition: height .25s;
}
.orb-val {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 16px; color: #fff; text-shadow: 0 1px 2px #000;
}
#action-hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 20;
  background: rgba(0,0,0,.72); color: var(--parch); padding: 5px 14px;
  border-radius: 6px; font-size: 13px; border: 1px solid var(--border);
  pointer-events: none;
}

/* ---------- sidebar (floating panel, top-right) ---------- */
#sidebar {
  position: absolute; top: 214px; right: 12px; z-index: 20;
  width: 268px; max-height: calc(100vh - 300px);
  display: flex; flex-direction: column; overflow: hidden;
}
#tabs {
  display: flex; background: rgba(0,0,0,.32); border-bottom: 2px solid var(--border);
  border-radius: calc(var(--radius-lg) - 2px) calc(var(--radius-lg) - 2px) 0 0;
}
.tab {
  flex: 1; padding: 10px 0; font-size: 19px; background: transparent;
  border: none; border-right: 1px solid rgba(0,0,0,.4); position: relative;
  filter: grayscale(.5) brightness(.8); transition: background .12s, filter .12s;
}
.tab:last-child { border-right: none; }
.tab:hover { background: rgba(231,198,90,.1); filter: none; }
.tab.active {
  background: linear-gradient(180deg, rgba(231,198,90,.24), rgba(231,198,90,.04));
  filter: none;
}
.tab.active::after {
  content: ""; position: absolute; left: 14%; right: 14%; bottom: 0; height: 3px;
  background: var(--gold); border-radius: 3px 3px 0 0; box-shadow: 0 0 8px rgba(231,198,90,.7);
}
#panel { flex: 1; overflow-y: auto; padding: 12px; }
#panel::-webkit-scrollbar { width: 9px; }
#panel::-webkit-scrollbar-thumb { background: var(--stone-lt); border-radius: 5px; }

.panel-title {
  font-size: 15px; color: var(--gold); font-weight: bold; letter-spacing: .5px;
  margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- inventory grid ---------- */
.inv-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px;
}
.inv-cell {
  position: relative; aspect-ratio: 1; border-radius: 6px;
  background: radial-gradient(circle at 40% 35%, #4a4236, #2a251d);
  border: 1px solid #14100a;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; transition: background .1s;
}
.inv-cell.filled { cursor: pointer; }
.inv-cell.filled:hover { background: radial-gradient(circle at 40% 35%, #6a5f48, #38311f); }
.inv-cell .qty {
  position: absolute; top: 1px; left: 3px; font-size: 11px; font-weight: bold;
  color: var(--gold); text-shadow: 0 1px 2px #000, 0 0 2px #000;
}
.inv-cell .emoji { filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.inv-note { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 10px; }

/* ---------- skills grid ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.skill-cell {
  background: linear-gradient(160deg, #46b562 0%, #2f7a42 60%);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 6px; display: flex; align-items: center; gap: 5px; cursor: help;
  position: relative; overflow: hidden;
}
.skill-cell .sk-ico { font-size: 16px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.5)); }
.skill-cell .sk-lvl { margin-left: auto; font-weight: bold; color: #fff; text-shadow: 0 1px 2px #000; font-size: 13px; }
.skill-cell .sk-lvl small { color: rgba(255,255,255,.7); font-weight: normal; }
.skill-cell .sk-bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold); }
.skills-total {
  margin-top: 8px; text-align: center; font-size: 13px; color: var(--parch);
  background: var(--inset-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 6px;
}

/* ---------- equipment ---------- */
.equip-wrap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.equip-slot {
  aspect-ratio: 1; border-radius: 6px; background: rgba(0,0,0,.28);
  border: 1px dashed #5a5040; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 22px; position: relative;
}
.equip-slot.filled { border-style: solid; border-color: var(--border);
  background: radial-gradient(circle at 40% 35%, #4a4236, #2a251d); cursor: pointer; }
.equip-slot.filled:hover { filter: brightness(1.2); }
.equip-slot .slot-label { position: absolute; bottom: 2px; font-size: 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .3px; }
.equip-slot.empty .emoji { opacity: .28; }
.bonus-box { background: var(--inset-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px; font-size: 12.5px; }
.bonus-box h4 { color: var(--gold); margin-bottom: 6px; font-size: 12px; }
.bonus-row { display: flex; justify-content: space-between; padding: 2px 0; color: var(--text); }
.bonus-row span:last-child { color: var(--gold); font-weight: bold; }

/* ---------- combat panel ---------- */
.styles-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.style-btn {
  padding: 10px 4px; border-radius: 6px; border: 2px solid var(--border);
  background: linear-gradient(#4a4236, #322c22); color: var(--text);
  font-size: 12px; text-align: center; line-height: 1.35;
}
.style-btn b { display: block; font-size: 13px; color: var(--parch); }
.style-btn.active { background: linear-gradient(#7a5a2a, #5a3f18); border-color: var(--gold-2); box-shadow: inset 0 0 0 1px var(--gold); }
.style-btn small { color: var(--text-dim); font-size: 10px; }
.combat-info { background: var(--inset-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px; font-size: 13px; }
.combat-info .row { display: flex; justify-content: space-between; padding: 3px 0; }
.combat-info .row b { color: var(--gold); }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; margin-top: 10px;
  padding: 8px 10px; background: var(--inset-bg); border: 1px solid var(--border); border-radius: var(--radius-md); font-size: 13px;
}
.switch { width: 42px; height: 22px; border-radius: 12px; background: #3a332a; border: 1px solid var(--border); position: relative; cursor: pointer; transition: background .15s; }
.switch.on { background: var(--good); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #eee; transition: left .15s; }
.switch.on::after { left: 22px; }

/* ---------- quests ---------- */
.quest-item { background: var(--inset-bg); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px; }
.quest-item h4 { color: var(--gold); font-size: 14px; margin-bottom: 8px; }
.quest-step { font-size: 12.5px; padding: 4px 0 4px 22px; position: relative; color: var(--text-dim); }
.quest-step.done { color: var(--good); }
.quest-step.active { color: var(--parch); }
.quest-step::before { content: "○"; position: absolute; left: 4px; }
.quest-step.done::before { content: "✔"; color: var(--good); }
.quest-step.active::before { content: "➤"; color: var(--gold); }
.quest-reward { margin-top: 10px; font-size: 12px; color: var(--text-dim); }

/* ---------- settings ---------- */
.settings-list { display: flex; flex-direction: column; gap: 8px; }
.settings-list .btn { width: 100%; }

/* ============================================================
   CHAT LOG
   ============================================================ */
#chatbar {
  position: absolute; left: 14px; bottom: 16px; z-index: 20;
  width: min(42vw, 440px);
  padding: 8px 12px;
}
#chat-log {
  height: 104px; overflow-y: auto; font-size: 13.5px; line-height: 1.5;
  color: var(--parch); font-family: "Consolas", "Courier New", monospace;
}
#chat-log::-webkit-scrollbar { width: 8px; }
#chat-log::-webkit-scrollbar-thumb { background: var(--stone-lt); border-radius: 4px; }
#chat-log .line { padding: 1px 0; }
#chat-log .line.sys { color: #d0b968; }
#chat-log .line.good { color: #7bd67b; }
#chat-log .line.warn { color: #e0a44a; }
#chat-log .line.bad { color: #e07a6a; }
#chat-log .line b { color: var(--gold); }

/* ============================================================
   CONTEXT MENU
   ============================================================ */
#context-menu {
  position: fixed; z-index: 60; min-width: 150px;
  background: linear-gradient(180deg, var(--stone-2), var(--stone));
  border: 2px solid var(--border); border-radius: 6px; box-shadow: var(--shadow);
  padding: 3px; overflow: hidden;
}
#context-menu .cm-head {
  font-size: 11px; color: var(--gold); padding: 4px 10px; border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .5px;
}
#context-menu .cm-item {
  padding: 7px 12px; font-size: 13px; color: var(--text); border-radius: 4px; cursor: pointer;
}
#context-menu .cm-item:hover { background: var(--accent); color: #fff; }
#context-menu .cm-item .cm-sub { color: var(--text-dim); }
#context-menu .cm-item:hover .cm-sub { color: #ffe; }

/* ============================================================
   TOOLTIP
   ============================================================ */
#tooltip {
  position: fixed; z-index: 70; max-width: 220px; pointer-events: none;
  background: rgba(20,16,10,.96); border: 1px solid var(--gold-2); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; color: var(--text); box-shadow: var(--shadow);
}
#tooltip .tt-name { color: var(--gold); font-weight: bold; margin-bottom: 3px; }
#tooltip .tt-desc { color: var(--text-dim); font-style: italic; margin-bottom: 4px; }
#tooltip .tt-stat { color: var(--good); }

/* ============================================================
   MODAL (shop / bank / smith)
   ============================================================ */
#modal-root {
  position: fixed; inset: 0; z-index: 55; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.6);
}
#modal-box {
  width: 560px; max-width: 92vw; max-height: 84vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--stone-2), var(--stone));
  border: 3px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
#modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 2px solid var(--border);
  background: linear-gradient(180deg, var(--stone-lt), var(--stone-2)); border-radius: 9px 9px 0 0;
}
#modal-title { font-size: 17px; color: var(--gold); font-weight: bold; }
#modal-close { background: transparent; border: none; color: var(--text); font-size: 18px; }
#modal-close:hover { color: var(--danger); }
#modal-body { padding: 16px; overflow-y: auto; }

.shop-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.shop-cell {
  background: radial-gradient(circle at 40% 35%, #4a4236, #2a251d);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 4px; text-align: center; cursor: pointer;
  transition: filter .1s;
}
.shop-cell:hover { filter: brightness(1.2); }
.shop-cell .em { font-size: 26px; }
.shop-cell .nm { font-size: 10.5px; color: var(--text-dim); margin: 3px 0 2px; height: 26px; line-height: 1.15; overflow: hidden; }
.shop-cell .pr { font-size: 12px; color: var(--gold); font-weight: bold; }
.modal-note { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.modal-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.modal-tabs .mt { flex: 1; padding: 7px; border-radius: 6px; border: 2px solid var(--border); background: #322c22; color: var(--text); font-size: 13px; font-weight: bold; }
.modal-tabs .mt.active { background: linear-gradient(#7a5a2a, #5a3f18); border-color: var(--gold-2); }

.craft-row {
  display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 6px;
  background: rgba(0,0,0,.25); border: 1px solid var(--border); border-radius: 8px;
}
.craft-row .em { font-size: 26px; }
.craft-row .info { flex: 1; }
.craft-row .info .t { font-size: 13px; color: var(--parch); font-weight: bold; }
.craft-row .info .s { font-size: 11px; color: var(--text-dim); }
.craft-row.locked { opacity: .5; }
.craft-row button { padding: 6px 14px; }

/* ============================================================
   LEVEL-UP TOAST
   ============================================================ */
#levelup-toast {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%) scale(.9); z-index: 80;
  background: linear-gradient(180deg, #f0d97a, #c69a2e);
  color: #3a2c08; text-align: center; padding: 16px 30px; border-radius: 12px;
  border: 3px solid #6e5311; box-shadow: var(--shadow);
  animation: pop 2.6s ease forwards; pointer-events: none;
}
#levelup-toast .lu-ico { font-size: 34px; }
#levelup-toast .lu-title { font-size: 15px; font-weight: bold; letter-spacing: .5px; }
#levelup-toast .lu-lvl { font-size: 22px; font-weight: bold; }
@keyframes pop {
  0% { opacity: 0; transform: translateX(-50%) scale(.6); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.05); }
  20% { transform: translateX(-50%) scale(1); }
  82% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
}

/* ============================================================
   WOW-STYLE COMBAT HUD — unit frames, cast bar, action bar
   ============================================================ */
#unit-frames {
  position: absolute; top: 12px; left: 14px; z-index: 20;
  display: flex; flex-direction: row; align-items: flex-start; gap: 10px;
}
.unit-frame {
  display: flex; align-items: center; gap: 9px;
  width: 250px; padding: 7px 11px 7px 7px;
  animation: uf-pop .18s ease;
}
.unit-frame.enemy {
  border-color: #5a2420;
  box-shadow: var(--hud-shadow), inset 0 0 0 1px rgba(226,80,62,.22);
}
@keyframes uf-pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.uf-portrait {
  width: 48px; height: 48px; flex: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: radial-gradient(circle at 50% 35%, #4a4234, #241d14);
  border: 2px solid var(--gold-2);
  box-shadow: 0 0 0 2px #14100a, inset 0 0 8px rgba(0,0,0,.7);
}
.unit-frame.enemy .uf-portrait {
  background: radial-gradient(circle at 50% 35%, #5a2c26, #2a1310);
  border-color: #7a2a22; box-shadow: 0 0 0 2px #14100a, inset 0 0 8px rgba(0,0,0,.7);
}
.uf-main { flex: 1; min-width: 0; }
.uf-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; gap: 8px; }
.uf-name {
  font-size: 13.5px; font-weight: bold; color: var(--parch);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unit-frame.enemy .uf-name { color: #f0b6a0; }
.uf-level { font-size: 11px; color: var(--gold); font-weight: bold; flex: none; }
.uf-bar {
  position: relative; height: 17px; border-radius: 5px; overflow: hidden;
  background: #14100a; border: 1px solid var(--border);
}
.uf-bar.mana { height: 11px; margin-top: 4px; }
.uf-fill { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: width .18s ease; }
.uf-fill::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 45%;
  background: linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,0));
  pointer-events: none;
}
.uf-fill.hp { background: linear-gradient(180deg, #5ed24a, #2f9a2a); }
.uf-fill.mp { background: linear-gradient(180deg, #4aa6f0, #2050b8); }
.uf-fill.enemyhp { background: linear-gradient(180deg, #e2503e, #a01f18); }
.uf-bartext {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: bold; color: #fff; text-shadow: 0 1px 2px #000; letter-spacing: .3px;
}
.uf-bar.mana .uf-bartext { font-size: 9.5px; }
/* buff pips + fortify glow */
.uf-buffs { display: flex; flex-direction: column; gap: 4px; flex: none; }
.buff-pip {
  font-size: 11px; font-weight: bold; color: #cfe0ff; white-space: nowrap;
  padding: 2px 5px; border-radius: 6px; border: 1px solid #4a6ea0;
  background: linear-gradient(180deg, rgba(60,90,140,.5), rgba(30,45,80,.5));
}
#player-frame.fortified { border-color: #6a90c8; box-shadow: 0 0 14px rgba(90,140,220,.5), var(--shadow); }

/* ---------- cast bar ---------- */
#cast-bar {
  position: absolute; left: 50%; bottom: 104px; transform: translateX(-50%); z-index: 21;
  display: flex; align-items: center; gap: 10px;
  width: 340px; padding: 7px 12px 7px 8px;
}
.cast-icon {
  width: 34px; height: 34px; flex: none; border-radius: 7px; font-size: 21px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, #4a4234, #241d14); border: 2px solid var(--border);
}
.cast-main { flex: 1; }
.cast-name { font-size: 13px; font-weight: bold; color: var(--parch); margin-bottom: 4px; }
.cast-track { position: relative; height: 12px; border-radius: 5px; background: #14100a; border: 1px solid var(--border); overflow: hidden; }
/* spell-queue window marker near the end of the cast */
.cast-tick {
  position: absolute; top: -1px; bottom: -1px; width: 2px;
  background: rgba(255,255,255,.55); box-shadow: 0 0 4px rgba(255,255,255,.5);
  transform: translateX(-1px); pointer-events: none; z-index: 2;
}
.cast-fill {
  height: 100%; width: 0%; background: var(--gold);
  box-shadow: 0 0 8px rgba(231,198,90,.6); transition: width .05s linear;
}

/* ---------- action bar (two rows) ---------- */
#action-bar {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 21;
  display: flex; flex-direction: column; gap: 6px; padding: 8px;
}
.ab-row { display: flex; gap: 8px; justify-content: center; }
.ability {
  position: relative; width: 54px; height: 54px; border-radius: var(--radius-md);
  background: linear-gradient(180deg, #4a4234, #2a2419);
  border: 2px solid var(--border); cursor: pointer; overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
  transition: filter .1s, transform .06s;
}
.ability:hover { filter: brightness(1.2); }
.ability:active { transform: translateY(1px); }
.ability.casting { border-color: var(--gold); box-shadow: 0 0 12px rgba(231,198,90,.75); }
/* queued: the next ability, primed to auto-fire the instant you're free */
.ability.queued { border-color: #8ad0ff; box-shadow: 0 0 12px rgba(120,200,255,.8); animation: ab-queue-pulse .6s ease-in-out infinite; }
@keyframes ab-queue-pulse { 0%,100% { box-shadow: 0 0 8px rgba(120,200,255,.55); } 50% { box-shadow: 0 0 15px rgba(120,200,255,.95); } }
.ab-icon {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 27px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); transition: filter .12s;
}
.ab-key {
  position: absolute; top: 2px; left: 4px; font-size: 11px; font-weight: bold;
  color: var(--gold); text-shadow: 0 1px 2px #000; z-index: 3;
}
.ab-cd {
  position: absolute; left: 0; right: 0; top: 0; height: 0%;
  background: rgba(8,6,4,.72); z-index: 2; pointer-events: none;
}
.ab-cdnum {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: bold; color: #fff; text-shadow: 0 1px 3px #000; z-index: 3;
  pointer-events: none;
}
.ability.cooling .ab-icon { filter: grayscale(.7) brightness(.55); }
/* shared global-cooldown sweep — subtle, above the icon but below the cd number */
.ab-gcd {
  position: absolute; left: 0; right: 0; top: 0; height: 0%;
  background: rgba(120,150,210,.28); z-index: 2; pointer-events: none;
}
/* mana cost label + not-enough-mana state */
.ab-mana {
  position: absolute; bottom: 1px; right: 4px; font-size: 10px; font-weight: bold;
  color: #8ec2ff; text-shadow: 0 1px 2px #000; z-index: 3; pointer-events: none;
}
.ability.no-mana .ab-icon { filter: grayscale(.85) brightness(.5); }
.ability.no-mana { border-color: #3a4a66; }

/* ---------- combat style bar (bottom-right, keybound) ---------- */
#style-bar {
  position: absolute; right: 12px; bottom: 16px; z-index: 21;
  display: flex; gap: 6px; padding: 7px;
}
.style-slot {
  position: relative; min-width: 78px; padding: 8px 9px 6px; border-radius: var(--radius-md);
  background: linear-gradient(180deg, #4a4236, #2a2419);
  border: 2px solid var(--border); cursor: pointer; text-align: center;
  transition: filter .1s, transform .06s;
}
.style-slot:hover { filter: brightness(1.18); }
.style-slot:active { transform: translateY(1px); }
.style-slot b { display: block; font-size: 12px; color: var(--parch); line-height: 1.25; }
.style-slot small { font-size: 9.5px; color: var(--text-dim); }
.ss-key {
  position: absolute; top: 2px; left: 5px; font-size: 10px; font-weight: bold;
  color: var(--gold); text-shadow: 0 1px 2px #000;
}
.style-slot.active {
  background: linear-gradient(#7a5a2a, #5a3f18);
  border-color: var(--gold-2); box-shadow: inset 0 0 0 1px var(--gold);
}
.style-slot.active b { color: #fff; }
.style-slot.toggle { border-left: 2px solid var(--border); }
.style-slot.toggle.on { background: linear-gradient(#2f6a33, #1f4a22); border-color: var(--good); }
.style-slot.toggle.on b, .style-slot.toggle.on small { color: #cfeecb; }

/* ---------- XP bar (WoW-style, spans the very bottom edge) ---------- */
#xp-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 19;
  height: 15px; overflow: hidden;
  background: linear-gradient(180deg, #241d12, #16110a);
  border-top: 2px solid #14100a;
  box-shadow: inset 0 1px 0 rgba(231,198,90,.12);
}
#xp-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(180deg, #b57ee0, #7a3fb0);
  box-shadow: 0 0 8px rgba(150,90,210,.6);
  border-right: 1px solid rgba(255,255,255,.35);
  transition: width .3s ease;
}
#xp-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: bold; color: #f0e8d6; letter-spacing: .4px;
  text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums;
}

@media (max-width: 1000px) {
  #sidebar { width: 240px; }
  #minimap, #minimap-canvas { width: 128px; height: 128px; }
  #topbar { top: 150px; width: 128px; }
  #sidebar { top: 184px; max-height: calc(100vh - 260px); }
  .unit-frame { width: 210px; }
  #cast-bar { width: 300px; }
  .ability { width: 48px; height: 48px; }
  .ab-icon { font-size: 23px; }
  .style-slot { min-width: 64px; padding: 6px 6px 5px; }
  .style-slot b { font-size: 11px; }
}
