:root {
  --stone: #3e3529;
  --stone-dark: #2b241b;
  --stone-light: #5a4d3b;
  --gold: #ff981f;
  --text: #ffff00;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; color: #fff; font-family: 'Verdana', 'Tahoma', sans-serif; font-size: 12px; overflow: hidden; user-select: none; }
button { font-family: inherit; }

/* Login */
#login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #3a3020 0%, #0d0a06 75%); }
.login-box { width: 340px; max-width: calc(100vw - 32px); padding: 28px; background: var(--stone); border: 3px solid #1a140d; box-shadow: inset 0 0 0 2px var(--stone-light), 0 10px 40px #000; text-align: center; }
.login-box h1 { margin: 0; font-family: Georgia, serif; font-size: 34px; color: var(--gold); text-shadow: 2px 2px 0 #000; letter-spacing: 1px; }
.login-box h1 span { color: #fff; font-size: 22px; }
.login-box .sub { color: #c8b99a; margin: 4px 0 18px; }
.login-box input { display: block; width: 100%; margin: 8px 0; padding: 10px; background: #1f1910; color: #fff; border: 2px solid #120e08; font-size: 14px; outline: none; }
.login-box input:focus { border-color: var(--gold); }
.login-box button { width: 100%; padding: 10px; margin-top: 8px; font-size: 16px; font-weight: bold; color: var(--gold); background: #4a3d2b; border: 2px solid #120e08; box-shadow: inset 0 0 0 1px #6b5a42; cursor: pointer; }
.login-box button:hover { background: #5a4a34; }
#l-err { color: #ff5a5a; min-height: 16px; margin: 10px 0 0; }
.hint { color: #8f826a; font-size: 11px; }

/* Layout */
#game { position: fixed; inset: 0; display: flex; }
#game[hidden] { display: none; }
#view-wrap { position: relative; flex: 1; overflow: hidden; }
#view { display: block; width: 100%; height: 100%; cursor: default; }
#side { width: 250px; background: var(--stone); border-left: 3px solid #1a140d; display: flex; flex-direction: column; box-shadow: inset 2px 0 0 var(--stone-light); }

#hover { position: absolute; left: 6px; top: 4px; font-weight: bold; text-shadow: 1px 1px 0 #000; pointer-events: none; font-size: 13px; }
#online { position: absolute; right: 8px; top: 6px; color: #c8b99a; text-shadow: 1px 1px 0 #000; pointer-events: none; }
#xpdrops { position: absolute; right: 10px; top: 28px; width: 160px; height: 220px; pointer-events: none; overflow: hidden; }
.xpdrop { position: absolute; right: 0; color: #fff; font-weight: bold; text-shadow: 1px 1px 0 #000; animation: xpup 1.8s linear forwards; white-space: nowrap; }
@keyframes xpup { from { top: 180px; opacity: 1; } 80% { opacity: 1; } to { top: 0; opacity: 0; } }
#levelup { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); pointer-events: none; text-align: center; font-family: Georgia, serif; font-size: 20px; color: var(--gold); text-shadow: 2px 2px 0 #000; opacity: 0; transition: opacity .4s; }
#levelup.show { opacity: 1; }

/* Chat */
#chatbox { position: absolute; left: 0; bottom: 0; width: min(520px, 100%); height: 160px; background: rgba(62, 53, 41, 0.82); border-top: 2px solid #1a140d; border-right: 2px solid #1a140d; display: flex; flex-direction: column; }
#chatlog { flex: 1; overflow-y: auto; padding: 4px 6px; font-size: 12px; line-height: 15px; text-shadow: 1px 1px 0 #000; }
#chatlog div { word-wrap: break-word; }
#chatlog .pn { color: #fff; }
#chatlog .pt { color: #9cf; }
#chatline { border-top: 1px solid #1a140d; padding: 3px 6px; display: flex; align-items: center; gap: 2px; }
#chatname { font-weight: bold; }
#chatinput { flex: 1; background: transparent; border: none; color: #9cf; font-family: inherit; font-size: 12px; outline: none; }
#chatinput::placeholder { color: #8f826a; }

/* Minimap */
#mini-wrap { position: relative; height: 190px; display: flex; justify-content: center; align-items: center; }
#minimap { border-radius: 50%; border: 3px solid #1a140d; box-shadow: 0 0 0 2px var(--stone-light); cursor: pointer; background: #000; }
.orb { position: absolute; left: 6px; width: 44px; height: 44px; border-radius: 50%; background: #1a140d; border: 2px solid #120e08; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.orb span { font-size: 15px; }
.orb b { font-size: 11px; color: #0f0; text-shadow: 1px 1px 0 #000; }
#orb-hp { top: 12px; }
#orb-run { top: 64px; cursor: pointer; }
#orb-run.on b { color: #ff0; }

/* Tabs */
#tabs { display: flex; gap: 2px; padding: 0 6px; }
#tabs button { flex: 1; height: 34px; font-size: 17px; background: #4a3d2b; border: 2px solid #1a140d; border-bottom: none; cursor: pointer; border-radius: 6px 6px 0 0; }
#tabs button.on { background: #7a2b20; }
#panel { flex: 1; margin: 0 6px 6px; background: var(--stone-dark); border: 2px solid #1a140d; padding: 8px; overflow-y: auto; }
.tab h3 { color: var(--gold); margin: 0 0 8px; font-size: 13px; text-align: center; }
#tab-help ul { padding-left: 16px; margin: 0; color: #e0d6c0; line-height: 1.5; }
#tab-help li { margin-bottom: 6px; }

/* Inventory */
#inv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.slot { position: relative; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 3px; }
.slot:hover { background: rgba(255, 255, 255, 0.07); }
.slot img { width: 36px; height: 36px; image-rendering: pixelated; pointer-events: none; }
.slot .cnt { position: absolute; left: 1px; top: -1px; font-size: 11px; color: #ff0; text-shadow: 1px 1px 0 #000; pointer-events: none; font-weight: bold; }
.slot.dragging { opacity: 0.3; }
.slot.sel { outline: 1px solid #fff; }

/* Skills */
#skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.skill { display: flex; align-items: center; gap: 3px; background: #3a3022; border: 1px solid #1a140d; padding: 4px 3px; border-radius: 3px; cursor: default; }
.skill .ic { font-size: 15px; }
.skill .lv { color: #ff0; font-weight: bold; text-shadow: 1px 1px 0 #000; font-size: 12px; }
.total { margin-top: 8px; text-align: center; color: #ff0; font-weight: bold; }
.xpbar { height: 4px; background: #000; margin-top: 2px; }
.xpbar i { display: block; height: 100%; background: #0c0; }

/* Combat & equip */
.styles button { display: block; width: 100%; margin: 4px 0; padding: 9px; background: #4a3d2b; color: #fff; border: 2px solid #1a140d; cursor: pointer; text-align: left; }
.styles button.on { background: #7a2b20; color: var(--gold); }
.styles button small { color: #c8b99a; }
.kv { display: flex; justify-content: space-between; color: #e0d6c0; padding: 2px 0; }
.kv b { color: #ff0; }
.equip-grid { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); gap: 6px; justify-content: center; margin-bottom: 12px; }
.eslot { background: #1a140d; border: 2px solid #4a3d2b; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; font-size: 10px; color: #6b5a42; }
.eslot img { width: 40px; height: 40px; }
.toggle { margin-top: 10px; display: flex; align-items: center; gap: 6px; color: #e0d6c0; cursor: pointer; }

/* Context menu */
#ctxmenu { position: fixed; z-index: 50; background: #5d5447; border: 1px solid #000; min-width: 140px; padding-bottom: 2px; font-size: 13px; }
#ctxmenu .head { background: #000; color: #5d5447; padding: 2px 4px; font-weight: bold; }
#ctxmenu .opt { padding: 2px 6px; color: #fff; cursor: pointer; white-space: nowrap; text-shadow: 1px 1px 0 #000; }
#ctxmenu .opt:hover { background: #6e6656; }

/* Modal */
#modal { position: fixed; inset: 0 250px 0 0; z-index: 40; display: flex; align-items: center; justify-content: center; pointer-events: none; }
#modal[hidden] { display: none; }
#modal-box { pointer-events: auto; background: var(--stone); border: 3px solid #1a140d; box-shadow: inset 0 0 0 2px var(--stone-light), 0 8px 30px #000; width: min(560px, calc(100% - 32px)); max-height: 80%; display: flex; flex-direction: column; }
#modal-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; color: var(--gold); font-weight: bold; font-size: 14px; border-bottom: 2px solid #1a140d; }
#modal-x { background: #7a2b20; color: #fff; border: 1px solid #000; cursor: pointer; width: 26px; height: 22px; }
#modal-body { padding: 10px; overflow-y: auto; }
.grid-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 4px; }
.gitem { position: relative; height: 48px; background: #2b241b; border: 1px solid #1a140d; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.gitem:hover { background: #3a3022; }
.gitem img { width: 38px; height: 38px; }
.gitem .cnt { position: absolute; left: 2px; top: 0; font-size: 11px; color: #ff0; text-shadow: 1px 1px 0 #000; font-weight: bold; }
.gitem .price { position: absolute; bottom: 0; right: 2px; font-size: 10px; color: #ff0; text-shadow: 1px 1px 0 #000; }
.bank-bar { display: flex; gap: 6px; margin-top: 10px; align-items: center; flex-wrap: wrap; color: #c8b99a; }
.bank-bar button, .menu-opt { background: #4a3d2b; color: #fff; border: 2px solid #1a140d; padding: 6px 10px; cursor: pointer; }
.bank-bar button.on { background: #7a2b20; color: var(--gold); }
.menu-opt { display: flex; align-items: center; gap: 8px; width: 100%; margin: 3px 0; text-align: left; font-size: 12px; }
.menu-opt img { width: 28px; height: 28px; }
.menu-opt:disabled { color: #8f826a; cursor: not-allowed; }
.menu-opt:not(:disabled):hover { background: #5a4a34; }
.note { color: #c8b99a; margin: 0 0 8px; }

#tooltip { position: fixed; z-index: 60; background: #ffffa0; color: #000; border: 1px solid #000; padding: 3px 6px; font-size: 11px; pointer-events: none; white-space: pre; }

@media (max-width: 760px) {
  #side { width: 200px; }
  #modal { inset: 0 200px 0 0; }
  #chatbox { height: 120px; }
}
