:root {
  --panel: rgba(18, 24, 36, 0.86);
  --line: rgba(230, 195, 106, 0.35);
  --gold: #e6c36a;
  --text: #e9edf5;
  --muted: #9aa6ba;
  --hp: #4ade6a; --sp: #5aa2ff; --exp: #c38bff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1118; color: var(--text);
  font: 14px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; user-select: none; touch-action: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: #ff8a7a; min-height: 1.2em; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 18px rgba(0,0,0,0.35); }
button { font: inherit; color: var(--text); background: #2a3550; border: 1px solid #44557a; border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover:not(:disabled) { background: #34426a; }
button:disabled { opacity: 0.45; cursor: default; }
button.big { width: 100%; padding: 11px; font-weight: 600; background: linear-gradient(#c79a3a, #a87a22); border-color: #e6c36a; color: #1a1205; }
button.big.on { background: linear-gradient(#5a6a8a, #3a4a6a); color: var(--text); border-color: #7a8aaa; }
button.sm { padding: 4px 9px; font-size: 13px; margin-left: 4px; }
button.link { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 4px; }
input { font: inherit; color: var(--text); background: #0f1420; border: 1px solid #44557a; border-radius: 8px; padding: 9px 10px; width: 100%; user-select: text; }
input[type=range] { padding: 0; }
input[type=checkbox] { width: auto; }
.badge { display: inline-block; background: var(--gold); color: #1a1205; border-radius: 99px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.badge.alt { background: #5aa2ff; }

/* ---------- HUD ---------- */
#pinfo { position: fixed; top: 10px; left: 10px; width: 230px; padding: 8px 10px; }
.prow { display: flex; justify-content: space-between; align-items: center; font-size: 15px; }
.bar { position: relative; height: 15px; background: rgba(0,0,0,0.55); border-radius: 4px; margin-top: 4px; overflow: hidden; }
.bar .fill { height: 100%; width: 0; transition: width 0.15s; }
.bar.hp .fill { background: linear-gradient(#6af08a, #2fb84e); }
.bar.sp .fill { background: linear-gradient(#8ac0ff, #3a7ae0); }
.bar.exp .fill { background: linear-gradient(#d8b0ff, #9a5ae0); }
.bar .txt { position: absolute; inset: 0; font-size: 11px; text-align: center; line-height: 15px; text-shadow: 0 1px 2px #000; }
.gold { margin-top: 5px; color: var(--gold); font-weight: 600; }

#mapinfo { position: fixed; top: 10px; right: 10px; padding: 6px; text-align: center; }
#mapname { font-size: 12px; color: var(--gold); margin-bottom: 4px; max-width: 150px; }
#minimap { display: block; border-radius: 6px; background: #000; }

#menu { position: fixed; right: 10px; top: 200px; display: flex; flex-direction: column; gap: 6px; }
#menu button { width: 42px; height: 42px; padding: 0; font-size: 20px; background: var(--panel); border-color: var(--line); }

#targetinfo { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); width: 240px; padding: 6px 10px; text-align: center; }
#targetinfo .tn { font-size: 13px; font-weight: 600; }
#autoflag { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); background: rgba(40, 160, 90, 0.85); padding: 3px 12px; border-radius: 99px; font-size: 12px; font-weight: 700; letter-spacing: 0.5px; animation: pulse 1.6s infinite; pointer-events: none; }
@keyframes pulse { 50% { opacity: 0.65; } }

#chat { position: fixed; left: 10px; bottom: 10px; width: 380px; padding: 6px; }
#chatlog { height: 150px; overflow-y: auto; font-size: 12.5px; padding: 2px 4px; user-select: text; }
#chatlog .msg { margin: 1px 0; }
.msg.sys { color: #c9d2e3; } .msg.tip { color: #9fd8ff; } .msg.level { color: #ffe27a; font-weight: 600; }
.msg.rare { color: #ffb84a; font-weight: 600; } .msg.boss { color: #ff9a6a; font-weight: 600; } .msg.death { color: #ff7a7a; }
.msg.loot { color: #a8f0a0; } .msg.map { color: #b8c4ff; } .msg.chat { color: #fff; } .msg.chat.me { color: #ffe9b0; }
#chatform input { margin-top: 4px; padding: 6px 8px; font-size: 13px; }
#chat-toggle { display: none; }

#hotbar { position: fixed; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.hb { position: relative; width: 54px; height: 54px; padding: 0; font-size: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.hb .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0,0,0,0.6); pointer-events: none; }
.hb .key { position: absolute; top: 1px; left: 4px; font-size: 10px; color: var(--muted); }
.hb .n { position: absolute; bottom: 1px; right: 4px; font-size: 11px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.hb.dim .ic { opacity: 0.4; }
.hb.auto.on { background: linear-gradient(#2fb84e, #1d7a33); border-color: #7af09a; }

#joystick { display: none; }

#toast { position: fixed; top: 92px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.8); padding: 7px 16px; border-radius: 99px; font-size: 13px; pointer-events: none; z-index: 30; white-space: nowrap; }
#toast.big { font-size: 17px; font-weight: 700; color: #ffcf5a; border: 1px solid #ffcf5a; }

/* ---------- janelas ---------- */
#window { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 20; }
.win { width: min(560px, 94vw); max-height: 86vh; display: flex; flex-direction: column; }
.win-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 700; color: var(--gold); }
.win-head button { padding: 2px 9px; }
#win-body { padding: 10px 14px 14px; overflow-y: auto; user-select: text; }
#win-body h4 { margin: 14px 0 6px; color: var(--gold); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
#win-body p { margin: 6px 0 10px; }
.row { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.row.me { background: rgba(230,195,106,0.12); }
.row .ico { width: 28px; text-align: center; font-size: 20px; flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row small { color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat { display: grid; grid-template-columns: 38px 52px 32px; align-items: center; gap: 4px; margin: 3px 0; }
.stat em { color: #7af09a; font-style: normal; font-size: 12px; }
.stat small { display: none; }
.kv { display: grid; grid-template-columns: auto auto; gap: 3px 12px; font-size: 13px; }
.kv span { color: var(--muted); }
.set { display: block; margin: 8px 0; }
.set input { margin-top: 4px; }
.chk { display: flex; gap: 8px; align-items: center; margin: 7px 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.tabs button.on { background: var(--gold); color: #1a1205; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.card { background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 8px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.card.has { border-color: var(--gold); }
.card .cimg { font-size: 28px; }
.card small { color: var(--muted); font-size: 11px; }

/* ---------- telas ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 40;
  background: radial-gradient(ellipse at top, #2a3a5a, #0d1118 70%); }
.box { width: min(380px, 92vw); padding: 22px; text-align: center; display: flex; flex-direction: column; gap: 9px; }
.logo { font-family: Georgia, "Times New Roman", serif; font-size: 32px; font-weight: 700; color: var(--gold); text-shadow: 0 2px 0 #6a4a10, 0 0 18px rgba(230,195,106,0.35); }
.logo.small { font-size: 24px; }
.sep { color: var(--muted); font-size: 12px; }
#login-form { display: flex; flex-direction: column; gap: 8px; }
.btns { display: flex; gap: 8px; }
.btns button { flex: 1; }
#c-preview { align-self: center; background: rgba(255,255,255,0.05); border-radius: 50%; }
.lbl { text-align: left; color: var(--muted); font-size: 12px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid transparent; }
.sw.on { border-color: #fff; box-shadow: 0 0 0 2px var(--gold); }

/* ---------- celular ---------- */
body.touch #joystick { display: block; position: fixed; left: 22px; bottom: 26px; width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.18); touch-action: none; }
#stick { position: absolute; left: 37px; top: 37px; width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,0.35); border: 2px solid rgba(255,255,255,0.5); }
body.touch #chat { display: none; top: 150px; bottom: auto; width: min(360px, 70vw); }
body.touch #chatlog { height: 110px; }
body.touch.chat-open #chat { display: block; }
body.touch #chat-toggle { display: block; position: fixed; left: 10px; bottom: 170px; width: 42px; height: 42px; padding: 0; font-size: 20px; background: var(--panel); border-color: var(--line); }
body.touch #hotbar { flex-wrap: wrap; width: 196px; justify-content: flex-end; }
body.touch .hb { width: 60px; height: 60px; }

@media (max-width: 700px) {
  #pinfo { width: 180px; padding: 6px 8px; font-size: 12px; }
  .prow { font-size: 13px; }
  .bar { height: 12px; } .bar .txt { font-size: 10px; line-height: 12px; }
  #minimap { width: 96px; height: 96px; }
  #mapname { max-width: 96px; font-size: 11px; }
  #menu { top: 168px; gap: 4px; }
  #menu button { width: 38px; height: 38px; font-size: 18px; }
  #targetinfo { top: auto; bottom: 182px; width: 200px; padding: 4px 8px; }
  #autoflag { top: auto; bottom: 150px; }
  #toast { top: auto; bottom: 236px; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-height: 500px) {
  #menu { top: 10px; right: 120px; flex-direction: row; }
  #minimap { width: 90px; height: 90px; }
  body.touch #chat-toggle { bottom: 160px; }
}
