/* Ashvale UI - stone & wood panels in a classic MMO style (original art). */
:root {
  --stone-1: #4f4639;
  --stone-2: #3d352b;
  --stone-dark: #1c1813;
  --stone-light: #6e604c;
  --text: #ff981f;
  --text-yellow: #ffff00;
  --text-white: #ffffff;
  --parchment: rgba(214, 196, 158, 0.86);
  --font: 600 12px/1.25 Verdana, "Trebuchet MS", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text); font: var(--font); user-select: none; }
button { font: inherit; cursor: pointer; }
button:focus { outline: none; }
img { -webkit-user-drag: none; image-rendering: auto; }

#game-root { position: fixed; inset: 0; overflow: hidden; }
#viewport { position: absolute; inset: 0; }
#game-canvas { display: block; width: 100%; height: 100%; }

.shadow-text, #hover-text, .orb-num, .xp-drop, #wild-level, #area-popup, .ov, .cm-row, .qty, .tab-content, .iface, #fps {
  text-shadow: 1px 1px 0 #000;
}

/* ---- panels ---------------------------------------------------------------------------- */
.panel {
  background: linear-gradient(180deg, var(--stone-1), var(--stone-2));
  border: 2px solid var(--stone-dark);
  box-shadow: inset 0 0 0 1px var(--stone-light), inset 0 0 0 3px #2b241c, 0 2px 10px rgba(0,0,0,0.5);
  border-radius: 5px;
}
.btn {
  background: linear-gradient(#5d5244, #463d31);
  border: 1px solid #1a1611;
  box-shadow: inset 0 0 0 1px #7a6a52;
  color: var(--text);
  padding: 4px 8px;
  border-radius: 3px;
  margin: 3px;
  text-shadow: 1px 1px 0 #000;
}
.btn:hover { filter: brightness(1.15); }
.btn.active, .btn.on { background: linear-gradient(#7a3a2a, #5a2a1e); color: #fff; }
.btn.danger { color: #ff6b5b; }
.muted { color: #b8a888; font-weight: 400; }
.pad { padding: 6px; }
.hidden { display: none !important; }

/* ---- hover / tooltips / menus ---------------------------------------------------------- */
#hover-text { position: absolute; top: 6px; left: 8px; color: #fff; pointer-events: none; font-size: 13px; z-index: 20; }
#hover-text .more { color: #fff; }
#tooltip {
  position: fixed; display: none; z-index: 100; pointer-events: none; max-width: 240px;
  background: #ffffa0; color: #000; border: 1px solid #000; padding: 3px 5px; font-weight: 400; text-shadow: none;
}
#tooltip b { font-weight: 700; }
#tooltip .muted { color: #444; }
#context-menu {
  position: fixed; display: none; z-index: 90; min-width: 120px;
  background: #5d5447; border: 1px solid #000; box-shadow: inset 0 0 0 1px #000;
}
.cm-head { background: #000; color: #5d5447; padding: 2px 5px; font-weight: 700; }
.cm-row { padding: 2px 6px; color: #fff; white-space: nowrap; cursor: default; }
.cm-row:hover { color: var(--text-yellow); background: rgba(0,0,0,0.1); }
.cm-row:hover .cm-opt { color: var(--text-yellow); }

#click-cross { position: absolute; inset: 0; pointer-events: none; z-index: 15; }
.cross { position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; animation: cross 0.42s steps(4) forwards; }
.cross::before, .cross::after { content: ""; position: absolute; left: 7px; top: 0; width: 3px; height: 16px; border: 1px solid #000; }
.cross::before { transform: rotate(45deg); } .cross::after { transform: rotate(-45deg); }
.cross-yellow::before, .cross-yellow::after { background: #ffff00; }
.cross-red::before, .cross-red::after { background: #ff0000; }
@keyframes cross { from { transform: scale(1.1); opacity: 1; } to { transform: scale(0.3); opacity: 0.6; } }

/* ---- world overlays -------------------------------------------------------------------- */
#overlays { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.ov { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.ov > * { position: absolute; left: 0; transform: translateX(-50%); white-space: nowrap; }
.ov-name { top: -30px; color: #fff; font-size: 11px; }
.ov-text { top: -46px; color: #ffff00; font-size: 13px; }
.ov-hp { top: -14px; width: 32px; height: 5px; background: #e00000; border: 1px solid #000; }
.ov-hp-fill { height: 100%; background: #00e000; }
.ov-splats { top: 0; width: 0; height: 0; transform: none; }
.splat {
  position: absolute; width: 26px; height: 22px; line-height: 22px; text-align: center; color: #fff; font-weight: 700; font-size: 12px;
  border-radius: 50% 50% 46% 46% / 55% 55% 45% 45%; border: 1px solid #000; animation: splat 0.25s ease-out;
}
.splat-damage { background: radial-gradient(circle at 40% 35%, #ff4a3a, #b80c0c 70%); }
.splat-block { background: radial-gradient(circle at 40% 35%, #6aa8ff, #1c4ac0 70%); }
.splat-poison { background: radial-gradient(circle at 40% 35%, #6ae06a, #1a8a1a 70%); }
.splat-venom { background: radial-gradient(circle at 40% 35%, #4ac0a0, #0a5a4a 70%); }
.splat-heal { background: radial-gradient(circle at 40% 35%, #e070e0, #8a1a8a 70%); }
@keyframes splat { from { scale: 1.4; } to { scale: 1; } }

/* ---- top right HUD --------------------------------------------------------------------- */
#hud-topright { position: absolute; top: 4px; right: 4px; display: flex; gap: 2px; z-index: 10; }
.minimap-wrap { position: relative; width: 172px; height: 172px; border-radius: 50%; background: #2a241c; border: 3px solid #1a1611; box-shadow: inset 0 0 0 2px #6e604c, 0 2px 10px rgba(0,0,0,0.6); }
.minimap { position: absolute; left: 1px; top: 1px; width: 164px; height: 164px; border-radius: 50%; cursor: pointer; }
.compass { position: absolute; left: -6px; top: -6px; width: 36px; height: 36px; border-radius: 50%; background: radial-gradient(#5a5044, #2a241c); border: 2px solid #1a1611; cursor: pointer; box-shadow: inset 0 0 0 1px #8a7a60; }
.compass-needle { position: absolute; inset: 0; }
.compass-needle span { position: absolute; left: 50%; top: 1px; transform: translateX(-50%); color: #e8c040; font-size: 11px; font-weight: 700; }
.compass-needle::after { content: ""; position: absolute; left: 50%; top: 13px; margin-left: -3px; border: 3px solid transparent; border-bottom: 9px solid #c03020; }
.orbs { display: flex; flex-direction: column; gap: 4px; padding-top: 18px; }
.orb { display: flex; align-items: center; gap: 2px; cursor: pointer; flex-direction: row; }
.orb-num { min-width: 28px; text-align: right; font-size: 12px; color: #0f0; white-space: nowrap; }
.orb-ball { position: relative; width: 30px; height: 30px; border-radius: 50%; background: #111; border: 2px solid #1a1611; box-shadow: inset 0 0 0 1px #6e604c; overflow: hidden; }
.orb-fill { position: absolute; left: 0; right: 0; bottom: 0; transition: height 0.3s; }
.orb-hp .orb-fill { background: radial-gradient(circle at 50% 30%, #ff5a4a, #9a1010); }
.orb-prayer .orb-fill { background: radial-gradient(circle at 50% 30%, #8ae0ff, #1a6aa0); }
.orb-run .orb-fill { background: radial-gradient(circle at 50% 30%, #ffe26a, #a07a10); }
.orb-spec .orb-fill { background: radial-gradient(circle at 50% 30%, #8aff8a, #1a7a3a); }
.orb.on .orb-ball { box-shadow: inset 0 0 0 1px #6e604c, 0 0 6px 2px rgba(255,240,120,0.8); }
.orb-glyph { position: absolute; inset: 5px; pointer-events: none; }
.orb-glyph svg { width: 100%; height: 100%; display: block; fill: rgba(255,255,255,0.92); stroke: rgba(20,14,8,0.85); stroke-width: 1.3; stroke-linejoin: round; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.5)); }
.orb-run:not(.on) .orb-glyph svg { fill: rgba(255,255,255,0.55); }

#xp-drops { position: absolute; top: 40px; right: 262px; width: 120px; height: 120px; pointer-events: none; z-index: 9; }
.xp-drop { position: absolute; right: 0; bottom: 0; display: flex; align-items: center; gap: 3px; color: #fff; font-size: 13px; animation: xpup 1.8s linear forwards; }
.xp-drop img { width: 20px; height: 18px; }
@keyframes xpup { from { transform: translateY(0); opacity: 1; } 85% { opacity: 1; } to { transform: translateY(-110px); opacity: 0; } }

#wild-level { position: absolute; right: 12px; bottom: 356px; color: #ffff00; font-size: 13px; text-align: center; z-index: 8; }
#wild-level .skull { width: 26px; height: 22px; margin: 0 auto 2px; background: radial-gradient(circle at 50% 40%, #fff 45%, transparent 47%); position: relative; }
#wild-level .skull::after { content: ""; position: absolute; left: 7px; top: 6px; width: 4px; height: 4px; background: #000; border-radius: 50%; box-shadow: 8px 0 0 #000; }
#fps { position: absolute; top: 6px; right: 250px; color: #ff0; z-index: 9; }

#area-popup { position: absolute; top: 70px; left: 0; right: 250px; text-align: center; color: #ffde72; font-size: 22px; font-family: Georgia, serif; font-weight: 700; letter-spacing: 1px; opacity: 0; pointer-events: none; z-index: 8; text-shadow: 2px 2px 0 #000; }
#area-popup.show { animation: area 3.2s ease forwards; }
@keyframes area { 0% { opacity: 0; transform: translateY(6px); } 15% { opacity: 1; transform: none; } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ---- chatbox --------------------------------------------------------------------------- */
#chatbox { position: absolute; left: 4px; bottom: 4px; width: 519px; height: 172px; padding: 5px 5px 0; z-index: 10; display: flex; flex-direction: column; }
.chat-body, .chat-overlay { flex: 1; min-height: 0; background: var(--parchment); border: 1px solid #2a241c; display: flex; flex-direction: column; }
.chat-log { flex: 1; overflow-y: auto; padding: 2px 5px; color: #000; font-weight: 400; scrollbar-width: thin; }
.chat-line { white-space: pre-wrap; word-break: break-word; }
.chat-public .chat-text { color: #0000ff; }
.chat-from { color: #000; font-weight: 700; }
.chat-input-row { display: flex; align-items: center; border-top: 1px solid rgba(0,0,0,0.4); padding: 1px 5px; color: #000; }
.chat-name { font-weight: 700; margin-right: 4px; }
.chat-input { flex: 1; background: transparent; border: 0; outline: 0; color: #0000ff; font: inherit; font-weight: 400; }
.chat-tabs { display: flex; gap: 2px; height: 24px; padding: 2px 0; }
.chat-tab { background: linear-gradient(#5d5244, #463d31); border: 1px solid #1a1611; color: var(--text); padding: 0 12px; border-radius: 3px 3px 0 0; text-shadow: 1px 1px 0 #000; }
.chat-tab.active { color: #fff; background: linear-gradient(#7a6a52, #5d5244); }
.chat-overlay { color: #000; text-align: center; justify-content: center; padding: 4px 10px; font-weight: 400; }
.dlg-name { color: #800000; font-weight: 700; margin-bottom: 4px; }
.dlg-text { font-size: 13px; }
.dlg-continue, .dlg-option { color: #0000ff; cursor: pointer; margin-top: 6px; }
.dlg-continue:hover, .dlg-option:hover { color: #fff; text-shadow: 1px 1px 0 #000; }
.dlg-title { color: #800000; font-weight: 700; margin-bottom: 4px; }
.mx-items { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.mx-item { display: flex; flex-direction: column; align-items: center; width: 74px; padding: 3px; border: 1px solid rgba(0,0,0,0.3); border-radius: 3px; cursor: pointer; position: relative; font-size: 11px; }
.mx-item:hover { background: rgba(255,255,255,0.3); }
.mx-item img { width: 36px; height: 32px; }
.mx-item small { position: absolute; top: 1px; left: 3px; color: #555; }
.mx-qty { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.mx-q { background: #5d5244; color: var(--text); border: 1px solid #000; border-radius: 3px; padding: 1px 8px; text-shadow: 1px 1px 0 #000; }
.mx-q.active { color: #fff; background: #7a3a2a; }
.mx-input, .prompt-input { width: 120px; font: inherit; text-align: center; border: 1px solid #000; background: #fffbe8; }

/* ---- side panel ------------------------------------------------------------------------ */
#sidepanel { position: absolute; right: 4px; bottom: 4px; width: 246px; height: 346px; z-index: 10; display: flex; flex-direction: column; padding: 4px; }
.tab-bar { display: grid; grid-template-columns: repeat(9, 1fr); gap: 1px; margin-bottom: 3px; }
.tab-btn { height: 32px; padding: 0; background: linear-gradient(#5d5244, #3d352b); border: 1px solid #1a1611; border-radius: 3px 3px 0 0; display: flex; align-items: center; justify-content: center; }
.tab-btn img { width: 24px; height: 21px; }
.tab-btn.active { background: linear-gradient(#8a3a2a, #5a2218); box-shadow: inset 0 0 0 1px #c05a3a; }
.tab-content { flex: 1; min-height: 0; background: rgba(0,0,0,0.18); border: 1px solid #1a1611; overflow: hidden; position: relative; }
.tab-pane { position: absolute; inset: 0; overflow-y: auto; padding: 4px; scrollbar-width: thin; }
.tab-title { color: var(--text); text-align: center; font-size: 13px; margin: 2px 0 6px; }

.inv-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 37px; gap: 2px; }
.inv-slot, .bank-slot, .equip-slot { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.inv-slot img, .bank-slot img, .equip-slot img { width: 36px; height: 32px; pointer-events: none; }
.inv-slot.selected { outline: 1px solid #fff; background: rgba(255,255,255,0.12); }
.qty { position: absolute; top: 0; left: 2px; font-size: 11px; color: #ffff00; pointer-events: none; }
.qty-k { color: #fff; } .qty-m { color: #00ff80; }

.equip-grid { display: grid; grid-template-columns: repeat(3, 40px); grid-auto-rows: 40px; gap: 6px 14px; justify-content: center; padding: 8px 0; }
.equip-slot { background: rgba(0,0,0,0.3); border: 1px solid #1a1611; border-radius: 3px; box-shadow: inset 0 0 0 1px #5a4e3e; }
.equip-slot img.ghost { opacity: 0.45; }
.bonus-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.bonus-cols h4 { margin: 0 0 4px; color: #ff981f; }
.bonus-row { display: flex; justify-content: space-between; color: #ffb83f; }

.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.skill-cell { height: 30px; background: linear-gradient(#4a4134, #3a3228); border: 1px solid #1a1611; border-radius: 2px; display: flex; align-items: center; padding: 0 3px; gap: 3px; cursor: default; }
.skill-cell img { width: 24px; height: 21px; }
.skill-cell .lv { flex: 1; display: flex; justify-content: flex-end; gap: 1px; color: #ffff00; }
.skill-cell .lv i { color: #ffff00; font-style: normal; }
.skill-cell.total { grid-column: span 1; flex-direction: column; justify-content: center; align-items: center; font-size: 10px; color: #ffff00; height: 30px; gap: 0; }

.combat-head { text-align: center; margin-bottom: 6px; }
.combat-head small { color: #ffb83f; }
.combat-styles { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.style-btn { background: linear-gradient(#5d5244, #463d31); border: 1px solid #1a1611; color: var(--text); padding: 6px 2px; border-radius: 3px; display: flex; flex-direction: column; text-shadow: 1px 1px 0 #000; }
.style-btn small { color: #c8b890; font-weight: 400; font-size: 10px; }
.style-btn.active { background: linear-gradient(#8a3a2a, #5a2218); color: #fff; }
.retaliate { width: calc(100% - 6px); margin-top: 8px; }
.spec-bar { position: relative; height: 20px; margin: 8px 3px; background: #200; border: 1px solid #000; cursor: pointer; }
.spec-bar.disabled { opacity: 0.5; }
.spec-fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#3ac03a, #1a7a1a); }
.spec-bar span { position: relative; display: block; text-align: center; line-height: 20px; color: #000; text-shadow: none; }

.quest-head { color: var(--text); text-align: center; margin-bottom: 6px; }
.quest-row { cursor: pointer; padding: 1px 4px; }
.quest-row:hover { text-decoration: underline; }
.q-new { color: #ff0000; } .q-started { color: #ffff00; } .q-done { color: #00ff00; }

.pray-head { text-align: center; margin-bottom: 6px; }
.icon-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.icon-cell { height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 4px; cursor: pointer; }
.icon-cell img { width: 34px; height: 30px; }
.icon-cell.locked { opacity: 0.3; filter: grayscale(1); }
.icon-cell.active { background: radial-gradient(rgba(255,240,180,0.6), rgba(255,240,180,0.05)); }
.set-row { display: flex; align-items: center; gap: 6px; padding: 3px 4px; color: var(--text); }
.set-row select { font: inherit; }

/* ---- interfaces ------------------------------------------------------------------------ */
#interface-layer { position: absolute; left: 0; right: 254px; top: 0; bottom: 184px; display: flex; align-items: center; justify-content: center; pointer-events: none; z-index: 30; }
.iface { pointer-events: auto; max-height: 100%; display: flex; flex-direction: column; background: linear-gradient(180deg, var(--stone-1), var(--stone-2)); border: 2px solid var(--stone-dark); box-shadow: inset 0 0 0 1px var(--stone-light), 0 6px 24px rgba(0,0,0,0.7); border-radius: 5px; min-width: 260px; }
.iface-head { display: flex; align-items: center; justify-content: center; position: relative; padding: 6px 30px; color: var(--text); font-size: 14px; border-bottom: 1px solid #1a1611; }
.iface-close { position: absolute; right: 4px; top: 3px; width: 22px; height: 22px; background: #7a2a1a; color: #fff; border: 1px solid #000; border-radius: 3px; padding: 0; }
.iface-body { padding: 8px; overflow-y: auto; min-height: 0; }
.bank-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.bank-search { font: inherit; background: #2a241c; color: #fff; border: 1px solid #000; padding: 2px 5px; width: 160px; }
.bank-grid, .shop-grid { display: grid; grid-template-columns: repeat(10, 44px); grid-auto-rows: 40px; gap: 2px; max-height: 360px; overflow-y: auto; background: rgba(0,0,0,0.2); padding: 4px; border: 1px solid #1a1611; }
.shop-grid { grid-template-columns: repeat(8, 48px); min-height: 120px; }
.bank-slot:hover { background: rgba(255,255,255,0.08); }
.bank-slot.empty img { opacity: 0.4; }
.bank-bottom { display: flex; justify-content: flex-end; margin-top: 6px; }
.journal .iface-body { background: #d8c49e; color: #000; text-shadow: none; font-weight: 400; }
.journal p { margin: 4px 0; }

/* ---- level up banner ------------------------------------------------------------------- */
.levelup { position: absolute; left: 4px; bottom: 182px; width: 519px; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--parchment); border: 2px solid #1a1611; color: #000; font-weight: 400; z-index: 25; animation: lvlin 0.3s ease; transition: opacity 0.8s; }
.levelup b { color: #000080; }
.levelup img { width: 40px; height: 36px; }
.levelup.fade { opacity: 0; }
@keyframes lvlin { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- character creation / loading ------------------------------------------------------ */
#charcreate { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: radial-gradient(rgba(10,8,6,0.55), rgba(0,0,0,0.85)); z-index: 60; }
.cc-panel { background: linear-gradient(180deg, var(--stone-1), var(--stone-2)); border: 2px solid var(--stone-dark); box-shadow: inset 0 0 0 1px var(--stone-light), 0 10px 40px rgba(0,0,0,0.8); border-radius: 8px; padding: 16px 20px; }
.cc-title { font-family: Georgia, serif; font-size: 26px; color: #ffde72; text-align: center; text-shadow: 2px 2px 0 #000; }
.cc-sub { text-align: center; color: #c8b890; margin-bottom: 10px; }
.cc-row { display: flex; gap: 16px; }
.cc-preview { width: 220px; height: 280px; background: radial-gradient(circle at 50% 40%, #6a5d4a, #2a241c); border: 1px solid #000; border-radius: 6px; }
.cc-opts { width: 270px; }
.cc-field { margin-bottom: 8px; }
.cc-field label { display: block; color: var(--text); margin-bottom: 3px; text-shadow: 1px 1px 0 #000; }
.cc-name { width: 100%; font: inherit; padding: 4px 6px; background: #2a241c; color: #fff; border: 1px solid #000; }
.cc-swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.cc-swatch { width: 24px; height: 20px; border: 2px solid #000; border-radius: 3px; cursor: pointer; }
.cc-swatch.active { border-color: #fff; box-shadow: 0 0 0 1px #000; }
.cc-toggle { display: flex; }
.cc-toggle .btn { margin: 0 4px 0 0; }
.cc-go { display: block; width: 100%; margin: 10px 0 0; padding: 8px; font-size: 15px; color: #fff; background: linear-gradient(#3a7a2a, #22501a); }
.cc-err { color: #ff6b5b; min-height: 14px; text-align: center; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #0c0a08; z-index: 80; transition: opacity 0.5s; }
#loading.done { opacity: 0; pointer-events: none; }
.loading-title { font-family: Georgia, serif; font-size: 40px; color: #ffde72; text-shadow: 3px 3px 0 #000; text-align: center; }
.loading-text { color: #c8b890; text-align: center; margin-top: 8px; }
.loading-bar { width: 260px; max-width: 70vw; height: 12px; margin: 14px auto 0; border: 1px solid #5a4a30; background: #1e1810; border-radius: 3px; overflow: hidden; }
.loading-fill { width: 0; height: 100%; background: linear-gradient(#e8b040, #a06818); transition: width 0.15s; }

@media (max-width: 900px) {
  #chatbox { width: calc(100vw - 260px); }
  .levelup { width: calc(100vw - 260px); }
}
/* phones / narrow portrait screens: chat full width at the bottom, side panel stacked above it */
@media (max-width: 600px) {
  #chatbox { width: calc(100vw - 8px); height: 128px; }
  .levelup { width: calc(100vw - 8px); }
  #sidepanel { bottom: 136px; transform: scale(0.82); transform-origin: bottom right; }
  #hud-topright { transform: scale(0.82); transform-origin: top right; }
  #interface-layer { right: 0; bottom: 424px; } /* above the side panel so the inventory stays usable */
  .iface { max-width: calc(100vw - 8px); min-width: 0; }
}
