:root {
  --gold: #e0b45a;
  --gold-dim: #8a6a2e;
  --panel: rgba(18, 14, 10, 0.92);
  --panel-2: rgba(40, 31, 22, 0.9);
  --text: #f1e6d0;
  --muted: #a8977a;
  --hp: #d23b2f;
  --mp: #2f7ee0;
  --fire: #ff6a2a;
  --ice: #5fd0ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0a08; color: var(--text);
  font-family: 'Noto Sans Georgian', system-ui, sans-serif; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
#login { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.15), rgba(0,0,0,0.75)); }
.login-box { width: min(560px, calc(100vw - 32px)); padding: 34px 30px; background: var(--panel); border: 1px solid var(--gold-dim);
  border-radius: 14px; box-shadow: 0 0 60px rgba(0,0,0,0.7), inset 0 0 40px rgba(224,180,90,0.06); text-align: center; }
.login-box h1 { margin: 0; font-family: 'Noto Serif Georgian', serif; font-size: 44px; font-weight: 900; letter-spacing: 1px;
  background: linear-gradient(90deg, var(--fire), var(--gold), var(--ice)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sub { margin: 4px 0 22px; color: var(--muted); }
#nameInput { width: 100%; padding: 12px 14px; font-size: 18px; font-family: inherit; border-radius: 8px; border: 1px solid var(--gold-dim);
  background: #0e0b08; color: var(--text); outline: none; text-align: center; }
#nameInput:focus { border-color: var(--gold); }
.login-box { width: min(760px, calc(100vw - 32px)) !important; }
.classes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 18px 0; }
.cls-card { padding: 12px 8px; border-radius: 10px; border: 2px solid #3a2f22; background: var(--panel-2); cursor: pointer; transition: .15s; }
.cls-card h3 { margin: 6px 0; font-size: 14px; }
.cls-card p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.4; }
.cls-icon { font-size: 32px; }
.cls-card.selected { border-color: var(--cc); box-shadow: 0 0 24px color-mix(in srgb, var(--cc) 45%, transparent); }
@media (max-width: 700px) { .classes { grid-template-columns: repeat(2, 1fr); } }
#mountBtn.on { border-color: #ff9a3a; background: rgba(80,40,10,0.92); }
#playBtn { width: 100%; padding: 14px; font-size: 18px; font-weight: 800; border: none; border-radius: 8px; color: #1b1206;
  background: linear-gradient(180deg, #f3cf7a, #c8903a); box-shadow: 0 4px 0 #7a5320; }
#playBtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #7a5320; }
#loginErr { color: #ff7b6b; min-height: 22px; margin-top: 10px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* ---------- hud ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.frame { position: absolute; background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 10px; padding: 10px 12px; }
#playerFrame { top: 14px; left: 14px; width: 270px; }
#targetFrame { top: 14px; left: 300px; width: 240px; }
.pf-top { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.lvl { color: var(--gold); }
.bar { position: relative; height: 18px; background: #1b1511; border-radius: 4px; overflow: hidden; margin-top: 4px; border: 1px solid #000; }
.bar .fill { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .15s; }
.bar.hp .fill { background: linear-gradient(180deg, #ef5a4c, #9e1f17); }
.bar.mp .fill { background: linear-gradient(180deg, #4f9cf5, #1b4fa6); }
.bar .fill.shield { background: repeating-linear-gradient(45deg, rgba(180,235,255,0.75) 0 6px, rgba(120,200,255,0.55) 6px 12px); width: 0; }
.bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; text-shadow: 0 1px 2px #000; }
#buffs, #tfStatus { display: flex; gap: 6px; margin-top: 6px; font-size: 13px; min-height: 4px; }
.buff { padding: 1px 6px; border-radius: 4px; background: #2a2017; border: 1px solid #4a3b28; }

#bossBar { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: min(560px, 60vw); text-align: center; }
#bossName { font-family: 'Noto Serif Georgian', serif; font-size: 20px; font-weight: 900; color: #ffcf6e; text-shadow: 0 0 10px #000, 0 2px 2px #000; }
.bar.boss { height: 22px; border: 1px solid var(--gold-dim); }
.bar.boss .fill { background: linear-gradient(180deg, #d9452f, #6d1209); }

#mapWrap { position: absolute; top: 14px; right: 14px; text-align: center; }
#minimap { width: 200px; height: 200px; border-radius: 50%; border: 3px solid var(--gold-dim); box-shadow: 0 0 20px rgba(0,0,0,0.7); background: #000; }
#zoneName { margin-top: 4px; font-weight: 700; color: var(--gold); text-shadow: 0 1px 3px #000; }

#zoneBanner { position: absolute; top: 22%; left: 0; right: 0; text-align: center; font-family: 'Noto Serif Georgian', serif; font-size: 46px;
  font-weight: 900; color: #fbe3ad; text-shadow: 0 0 20px #000, 0 3px 4px #000; opacity: 0; transition: opacity .8s; pointer-events: none; }
#zoneBanner small { display: block; font-size: 18px; color: var(--muted); font-family: 'Noto Sans Georgian', sans-serif; font-weight: 600; }
#zoneBanner.show { opacity: 1; }

#notifs { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.notif { padding: 6px 14px; background: rgba(0,0,0,0.6); border-radius: 6px; font-weight: 600; font-size: 15px; animation: notif 4s forwards; text-shadow: 0 1px 2px #000; }
.notif.bad { color: #ff8a7a; }
.notif.epic { color: #ffd36b; font-size: 18px; border: 1px solid var(--gold-dim); }
.notif.loot { color: #b8f0a0; }
@keyframes notif { 0% { opacity: 0; transform: translateY(8px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

#bottom { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); }
#actionBar { display: flex; gap: 8px; justify-content: center; padding: 8px; background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 12px; }
.slot { position: relative; width: 58px; height: 58px; border-radius: 8px; background: linear-gradient(180deg, #2c2219, #15100b); border: 2px solid #4a3a26;
  display: grid; place-items: center; font-size: 28px; cursor: pointer; }
.slot.empty { opacity: 0.35; }
.slot.nomana { filter: saturate(0.3) brightness(0.7); }
.slot .key { position: absolute; top: 1px; left: 4px; font-size: 11px; font-weight: 800; color: var(--gold); }
.slot .cnt { position: absolute; bottom: 1px; right: 4px; font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.slot .cd { position: absolute; inset: 0; border-radius: 6px; background: conic-gradient(rgba(0,0,0,0.75) var(--p, 0%), transparent 0); display: grid; place-items: center; font-size: 16px; font-weight: 800; }
.slot.sep { margin-left: 14px; }
.slot:hover { border-color: var(--gold); }
#xpBar { position: relative; margin-top: 6px; height: 12px; background: #120e0a; border: 1px solid #000; border-radius: 6px; overflow: hidden; }
#xpBar .fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #7b4fd6, #c88cff); }
#xpBar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 10px; font-weight: 700; text-shadow: 0 1px 2px #000; }

#menuBtns { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
#menuBtns button { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); color: var(--text);
  border: 1px solid var(--gold-dim); border-radius: 8px; font-size: 18px; }
#menuBtns button span { font-size: 13px; font-weight: 600; }
#menuBtns button:hover { border-color: var(--gold); }
#pointsBadge { position: absolute; top: -6px; right: -6px; background: #e0452f; color: #fff; border-radius: 10px; padding: 0 6px; font-size: 12px; }

#chat { position: absolute; left: 14px; bottom: 14px; width: 360px; }
#chatLog { max-height: 180px; overflow-y: auto; font-size: 13px; padding: 6px 8px; background: rgba(0,0,0,0.35); border-radius: 8px 8px 0 0; }
#chatLog div { margin: 2px 0; text-shadow: 0 1px 2px #000; }
#chatLog .sys { color: #c7b48c; }
#chatLog .epic { color: #ffd36b; }
#chatInput { width: 100%; padding: 7px 10px; font-family: inherit; background: rgba(0,0,0,0.6); border: 1px solid #3c2f20; color: var(--text); border-radius: 0 0 8px 8px; outline: none; }
#chatInput:focus { border-color: var(--gold); }

#interactHint { position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%); padding: 8px 16px; background: var(--panel); border: 1px solid var(--gold);
  border-radius: 8px; font-weight: 700; }
#interactHint b { color: var(--gold); }
#help { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%) translateY(100%); font-size: 11px; color: var(--muted); white-space: nowrap; }
#help { display: none; }

#death { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: radial-gradient(rgba(60,0,0,0.3), rgba(30,0,0,0.75)); pointer-events: none; }
#death h2 { font-family: 'Noto Serif Georgian', serif; font-size: 64px; margin: 0; color: #e8463a; text-shadow: 0 0 30px #000; }

#clock { font-size: 13px; font-weight: 700; color: #e8dcc0; text-shadow: 0 1px 3px #000; }
#questTracker { margin-top: 8px; width: 220px; text-align: left; font-size: 12px; pointer-events: none; }
#questTracker .qt { padding: 6px 8px; margin-bottom: 4px; background: rgba(0,0,0,0.45); border-left: 3px solid var(--gold); border-radius: 4px; text-shadow: 0 1px 2px #000; }
#questTracker .qt b { display: block; color: var(--gold); font-size: 12px; }
#questTracker .qt.ready { border-left-color: #8ee07a; }
#questTracker .qt.ready b { color: #8ee07a; }
#inviteBox { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); padding: 14px 18px; background: var(--panel); border: 1px solid var(--gold);
  border-radius: 10px; text-align: center; z-index: 30; box-shadow: 0 10px 40px rgba(0,0,0,0.7); }
#pvpBtn.on { border-color: #e0452f; background: rgba(90,15,10,0.92); }
.quest { padding: 10px 12px; background: #1b150f; border: 1px solid #33281c; border-radius: 8px; margin-bottom: 8px; }
.quest h3 { margin: 0 0 4px; font-size: 15px; color: var(--gold); }
.quest.ready h3 { color: #8ee07a; }
.quest p { margin: 4px 0; font-size: 13px; color: #d8ccb0; line-height: 1.5; }
.quest .prog { font-size: 12px; }
.quest .rew { font-size: 12px; color: #9fe08a; margin-top: 4px; }
.quest .row { margin-top: 8px; gap: 8px; }
.field { width: 100%; padding: 8px 10px; margin: 4px 0 8px; font-family: inherit; font-size: 14px; background: #0e0b08; color: var(--text); border: 1px solid var(--gold-dim); border-radius: 6px; outline: none; }
.member { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid #2a2117; font-size: 14px; }
.member .dot { width: 8px; height: 8px; border-radius: 50%; background: #555; }
.member .dot.on { background: #6ee06a; box-shadow: 0 0 6px #6ee06a; }
#chatLog .guild { color: #8ee07a; }
#chatLog .whisper { color: #f0a0e0; }
.label.player.pvp { color: #ff6a5a; }
.label .tag { color: #8ee07a; }

/* ---------- panels ---------- */
.panel { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 80px);
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 12px; box-shadow: 0 10px 60px rgba(0,0,0,0.8); z-index: 20; }
.panel.wide { width: min(780px, calc(100vw - 32px)); }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #3a2e1f; }
.panel-head h2 { margin: 0; font-family: 'Noto Serif Georgian', serif; font-size: 22px; color: var(--gold); }
.close { background: none; border: none; color: var(--muted); font-size: 20px; }
.close:hover { color: var(--text); }
.panel-body { padding: 14px 16px; overflow-y: auto; }
.section-title { font-weight: 800; color: var(--gold); margin: 12px 0 6px; font-size: 14px; }
.row { display: flex; gap: 14px; }
.equip-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.bag-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.islot { position: relative; aspect-ratio: 1; border-radius: 6px; background: #1a140f; border: 2px solid #3a2e22; display: grid; place-items: center; font-size: 22px; cursor: pointer; }
.islot.empty { opacity: 0.4; font-size: 18px; cursor: default; }
.islot:hover { filter: brightness(1.3); }
.islot .lbl { position: absolute; bottom: -1px; font-size: 9px; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; font-size: 14px; }
.stats b { color: var(--gold); float: right; }
.mats { display: flex; flex-wrap: wrap; gap: 6px; }
.mat { padding: 4px 8px; background: #1f1812; border: 1px solid #3a2e22; border-radius: 6px; font-size: 13px; }
.gold { color: #ffd36b; font-weight: 800; }
.btn { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--gold-dim); background: #2b2117; color: var(--text); font-weight: 700; }
.btn:hover:not(:disabled) { border-color: var(--gold); background: #3a2c1e; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #e9bf68, #b07d32); color: #1b1206; border: none; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: #1b150f; border: 1px solid #33281c; border-radius: 8px; margin-bottom: 6px; }
.list-item .grow { flex: 1; }
.list-item .ico { font-size: 26px; width: 34px; text-align: center; }
.req { font-size: 12px; color: var(--muted); }
.req .ok { color: #8ee07a; }
.req .no { color: #ff7b6b; }
.small { font-size: 12px; color: var(--muted); }

#tooltip { position: fixed; z-index: 60; max-width: 260px; padding: 10px 12px; background: rgba(10,8,6,0.97); border: 1px solid var(--gold-dim); border-radius: 8px;
  font-size: 13px; pointer-events: none; }
#tooltip .tt-name { font-weight: 800; font-size: 15px; }
#tooltip .tt-stat { color: #9fe08a; }

/* skill tree */
.tree { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 118px; gap: 0 10px; }
.tree svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.snode { position: relative; z-index: 1; align-self: center; justify-self: center; width: 200px; padding: 8px 10px; border-radius: 10px; background: #1b150f;
  border: 2px solid #3a2e22; text-align: center; }
.snode.learned { border-color: var(--gold); box-shadow: 0 0 14px rgba(224,180,90,0.3); }
.snode.locked { opacity: 0.55; }
.snode .sico { font-size: 26px; }
.snode .sname { font-weight: 800; font-size: 14px; }
.snode .srank { font-size: 12px; color: var(--gold); }
.snode .plus { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1; }
.snode .ptag { position: absolute; top: 8px; left: 8px; font-size: 10px; color: var(--muted); }

/* world labels */
#labels, #floaters { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.label { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); will-change: transform; text-align: center; white-space: nowrap; font-size: 12px; font-weight: 700; text-shadow: 0 1px 3px #000, 0 0 2px #000; }
.label .hpb { width: 70px; height: 6px; margin: 2px auto 0; background: #200; border: 1px solid #000; border-radius: 3px; overflow: hidden; }
.label .hpb i { display: block; height: 100%; background: #e03b2c; }
.label.player { color: #9fd3ff; }
.label.npc { color: #ffd36b; }
.label.npc .role { color: #e8dcc0; font-size: 11px; font-weight: 600; }
.label.npc .mark { font-size: 20px; color: #ffcf40; }
.label.npc.villager { color: #f2e6c8; }
.label .bubble { max-width: 260px; margin: 0 auto 6px; padding: 7px 11px; white-space: normal; font-size: 13px; font-weight: 500; line-height: 1.35;
  color: #2a2016; background: #fbf4e2; border-radius: 10px; text-shadow: none; box-shadow: 0 2px 8px #0008; position: relative; }
.label .bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fbf4e2; }
.label.mob { color: #ffb0a0; }

/* conversations */
.panel.talk { width: 420px; }
.talk-log { height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.talk-line { padding: 7px 10px; border-radius: 10px; line-height: 1.4; max-width: 88%; }
.talk-line.npc { background: #2c2418; border: 1px solid #5a4a30; align-self: flex-start; }
.talk-line.npc b { color: var(--gold); }
.talk-line.me { background: #1c2c40; border: 1px solid #36506e; align-self: flex-end; }
.talk-line.me b { color: #9fd3ff; }
.talk-line.sys { color: var(--muted); font-style: italic; align-self: center; text-align: center; }
.talk-typing { color: var(--muted); font-size: 12px; margin: 4px 2px; }
.talk-typing span { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.talk-form { display: flex; gap: 6px; margin-top: 8px; }
.talk-form input { flex: 1; padding: 8px 10px; background: #0d0b08; color: #eee; border: 1px solid #5a4a30; border-radius: 6px; font: inherit; }
.talk-btn { width: 100%; margin-bottom: 10px; }

/* ---------- accounts ---------- */
#authBox { max-width: 380px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
#authBox input, #nameInput { width: 100%; padding: 12px 14px; font-size: 17px; font-family: inherit; border-radius: 8px; border: 1px solid var(--gold-dim);
  background: #0e0b08; color: var(--text); outline: none; text-align: center; user-select: text; }
#authBox input:focus { border-color: var(--gold); }
.tabs { display: flex; gap: 6px; }
.tab { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid #3a2e22; background: #17120d; color: var(--muted); font-weight: 700; font-size: 15px; }
.tab.on { color: #1b1206; background: linear-gradient(180deg, #e9bf68, #b07d32); border-color: transparent; }
#authBtn { padding: 13px; font-size: 18px; font-weight: 800; border: none; border-radius: 8px; color: #1b1206;
  background: linear-gradient(180deg, #f3cf7a, #c8903a); box-shadow: 0 4px 0 #7a5320; }
.acc-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; color: var(--muted); }
.acc-row b { color: var(--gold); }
.linkbtn { background: none; border: none; color: var(--muted); text-decoration: underline; font-size: 13px; }
#charList { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin-bottom: 14px; }
.char-card { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; gap: 0 10px; align-items: center; text-align: left; padding: 10px 12px;
  border-radius: 10px; border: 2px solid color-mix(in srgb, var(--cc) 55%, #3a2f22); background: var(--panel-2); color: var(--text); }
.char-card:hover { box-shadow: 0 0 18px color-mix(in srgb, var(--cc) 45%, transparent); }
.char-card .ci { grid-row: 1 / 4; font-size: 30px; }
.char-card .cn { font-weight: 800; font-size: 16px; color: var(--cc); }
.char-card .cl { font-size: 12px; color: var(--muted); }
.char-card .cp { font-size: 12px; font-weight: 800; color: var(--gold); }
.nc-title { font-weight: 800; color: var(--gold); margin: 6px 0 8px; }
#loadState { font-size: 12px; color: var(--muted); min-height: 16px; }

/* ---------- items ---------- */
.islot .plus { position: absolute; top: 1px; right: 3px; font-size: 11px; color: #ffd36b; text-shadow: 0 1px 2px #000; }
.islot.legend { box-shadow: 0 0 12px rgba(255, 159, 26, 0.65), inset 0 0 10px rgba(255, 159, 26, 0.35); animation: legendPulse 2.4s ease-in-out infinite; }
@keyframes legendPulse { 50% { box-shadow: 0 0 20px rgba(255, 180, 60, 0.9), inset 0 0 14px rgba(255, 180, 60, 0.5); } }
.tt-name.legend { text-shadow: 0 0 10px rgba(255, 159, 26, 0.7); }
.tt-stat.special, #itemMenu .tt-stat.special { color: #ffcf6e !important; }
.lore { margin: 6px 0; font-style: italic; color: #d8c08a; font-size: 12px; }
.pity { margin-top: 8px; }
.label.mob.elite { color: #ffd36b; }
#itemMenu { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(0, 0, 0, 0.45); }
#itemMenu .im-box { width: min(340px, calc(100vw - 32px)); padding: 14px 16px; background: rgba(10, 8, 6, 0.98); border: 1px solid var(--gold-dim); border-radius: 12px; font-size: 14px; }
#itemMenu .tt-name { font-weight: 800; font-size: 17px; }
#itemMenu .tt-stat { color: #9fe08a; }
.im-actions { margin-top: 12px; gap: 8px; flex-wrap: wrap; }
.im-actions .btn { flex: 1; padding: 10px; font-size: 15px; }
.q-opt { cursor: pointer; }
.q-opt.on { border-color: var(--gold); }
.q-opt input { accent-color: var(--gold); width: 18px; height: 18px; }

/* ---------- world map ---------- */
#minimap { cursor: pointer; }
#worldMap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, 0.6); }
.wm-box { padding: 12px 14px; background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 14px; box-shadow: 0 10px 60px rgba(0,0,0,0.8); }
.wm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.wm-head h2 { margin: 0; font-family: 'Noto Serif Georgian', serif; font-size: 20px; color: var(--gold); flex: 1; }
#wmCanvas { display: block; border-radius: 10px; border: 2px solid var(--gold-dim); }
.wm-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--muted); max-width: 900px; }
.wm-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 3px; }
.wm-legend .dot.mob { background: #e8564a; }
.wm-legend .dot.pl { background: #5fb8ff; }

/* ---------- cutscenes ---------- */
#cutscene { position: fixed; inset: 0; z-index: 80; cursor: pointer; }
#cutscene .cs-bar { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height .6s ease; }
#cutscene .cs-bar.top { top: 0; } #cutscene .cs-bar.bottom { bottom: 0; }
#cutscene.on .cs-bar { height: 11vh; }
#cutscene .cs-fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .5s; }
#cutscene .cs-fade.flash { opacity: 0.85; transition: none; }
#cutscene .cs-card { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: #000; opacity: 0; pointer-events: none; transition: opacity .8s; }
#cutscene .cs-card.on { opacity: 1; }
#cutscene .cs-card h1 { margin: 0; font-family: 'Noto Serif Georgian', serif; font-size: clamp(32px, 6vw, 64px); font-weight: 900; color: #f4e3b0; letter-spacing: 1px; text-shadow: 0 0 30px rgba(224,180,90,0.4); }
#cutscene .cs-card p { margin: 12px 0 0; color: #b8a888; font-size: clamp(14px, 2vw, 20px); }
#cutscene .cs-sub { position: absolute; left: 50%; bottom: calc(11vh + 18px); transform: translateX(-50%); width: min(900px, calc(100vw - 40px)); padding: 14px 22px;
  background: linear-gradient(180deg, rgba(10,8,6,0.55), rgba(10,8,6,0.8)); border-radius: 10px; opacity: 0; transition: opacity .3s; text-align: center; }
#cutscene .cs-sub.on { opacity: 1; }
#cutscene .cs-who { display: block; font-size: 14px; margin-bottom: 4px; letter-spacing: .5px; }
#cutscene .cs-sub.narrator .cs-who { display: none; }
#cutscene .cs-sub.narrator .cs-text { font-style: italic; color: #d8ccb0; }
#cutscene .cs-text { font-size: clamp(15px, 1.8vw, 20px); line-height: 1.55; color: #f4ecd8; text-shadow: 0 1px 3px #000; }
#cutscene .cs-next { position: absolute; right: 14px; bottom: 10px; font-size: 11px; color: var(--gold); font-style: normal; animation: blink 1.2s infinite; }
#cutscene .cs-skip { position: absolute; right: 18px; top: calc(11vh + 14px); padding: 8px 14px; border-radius: 8px; border: 1px solid rgba(224,180,90,0.5);
  background: rgba(0,0,0,0.55); color: #e8dcc0; font-weight: 700; font-size: 14px; }
#cutscene .cs-skip small { opacity: .6; margin-left: 4px; }
#cutscene .cs-skip:hover { border-color: var(--gold); }

/* ---------- story ---------- */
#questTracker .qt.story { border-left-color: #ffb030; background: rgba(40,24,0,0.55); }
#questTracker .qt.story b { color: #ffcf6e; }
.story-now { border-color: #8a6a2e; background: #241a0c; }
.story-done { border-color: #5a8a3a; }
.story-prog { color: #ffcf6e; margin-top: 4px; }
#storyBanner { position: absolute; top: 16%; left: 50%; transform: translateX(-50%); width: min(620px, calc(100vw - 40px)); padding: 14px 22px; text-align: center;
  background: linear-gradient(180deg, rgba(40,26,6,0.92), rgba(18,12,4,0.92)); border: 1px solid #b08a3a; border-radius: 12px; pointer-events: none; z-index: 25; }
#storyBanner.show { animation: bannerIn 9s forwards; }
@keyframes bannerIn { 0% { opacity: 0; transform: translate(-50%, -10px); } 6% { opacity: 1; transform: translate(-50%, 0); } 88% { opacity: 1; } 100% { opacity: 0; } }
#storyBanner small { display: block; color: #ffb030; font-weight: 800; letter-spacing: 1px; }
#storyBanner b { display: block; font-family: 'Noto Serif Georgian', serif; font-size: 24px; color: #f4e3b0; margin: 4px 0; }
#storyBanner p { margin: 0; color: #d8ccb0; font-size: 14px; line-height: 1.5; }

/* ---------- arena ---------- */
#arenaBar { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 8px 16px; background: rgba(40,10,6,0.88); border: 1px solid #b04a30;
  border-radius: 10px; font-weight: 800; font-size: 14px; color: #ffd8c0; cursor: pointer; z-index: 15; white-space: nowrap; }
#arenaBar .red { color: #ff6a5a; } #arenaBar .blue { color: #6ab8ff; }
#menuBtns button.locked { opacity: 0.55; }
#menuBtns button.locked::after { content: '🔒'; position: absolute; top: -6px; left: -6px; font-size: 12px; }
#arenaBadge { position: absolute; top: -6px; right: -6px; background: #e0452f; color: #fff; border-radius: 10px; padding: 0 6px; font-size: 12px; animation: blink 1.2s infinite; }
.label.player.team-red { color: #ff7a6a; }
.label.player.team-blue { color: #7ac0ff; }

/* ---------- touch controls ---------- */
#touchUI { position: absolute; inset: 0; pointer-events: none; }
#touchUI > * { pointer-events: auto; }
#joyZone { position: absolute; left: 0; bottom: 0; width: 42vw; height: 60vh; touch-action: none; }
#joy { position: fixed; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%; border: 2px solid rgba(255, 230, 180, 0.35);
  background: radial-gradient(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.35)); pointer-events: none; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(circle at 40% 35%, #f3d9a0, #a07a3a); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); }
#tbtns { position: absolute; right: calc(12px + env(safe-area-inset-right)); bottom: 120px; display: grid; grid-template-columns: repeat(3, 54px); grid-auto-flow: column; grid-template-rows: repeat(2, 54px); gap: 8px; }
#tbtns button { width: 54px; height: 54px; border-radius: 50%; border: 2px solid var(--gold-dim); background: rgba(18, 14, 10, 0.75); color: var(--text); font-size: 22px; touch-action: none; }
#tbtns button.big { grid-column: 3; grid-row: 1 / 3; width: 64px; height: 64px; align-self: center; font-size: 28px; }
#tbtns button.on { background: rgba(224, 180, 90, 0.45); }
#tbtns button.ready { border-color: #8ee07a; box-shadow: 0 0 14px rgba(142, 224, 122, 0.7); }

#fsTouchBtn.on { display: none; }
.vol-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; font-size: 14px; }
.vol-row span { flex: 1; }
.vol-row input[type=range] { width: 46%; accent-color: var(--gold); }
.vol-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--gold); }
#installGuide { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.6); padding: 16px; }
#installGuide[hidden] { display: none; }
#installGuide .ig-box { max-width: 420px; max-height: calc(100% - 16px); overflow-y: auto; background: rgba(22, 17, 11, 0.97); border: 2px solid var(--gold-dim); border-radius: 12px; padding: 18px 20px; color: var(--text); font-size: 14px; line-height: 1.5; }
#installGuide h3 { margin: 0 0 8px; color: var(--gold); font-size: 18px; }
#installGuide ol { margin: 10px 0 14px; padding-left: 22px; }
#installGuide li { margin-bottom: 6px; }
#installGuide .ig-share { display: inline-block; border: 1.5px solid currentColor; border-radius: 4px; padding: 0 5px; font-size: 12px; }
#installGuide .btn { width: 100%; }

/* ---------- phones and tablets ---------- */
/* iPhone Safari: no page zoom on double tap, no text-selection / callout on long press, and the
   dynamic viewport height so the browser's own bars don't cover the game's buttons */
body.touch { touch-action: manipulation; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
@supports (height: 100dvh) { body.touch, body.touch #hud { height: 100dvh; } }
body.touch input, body.touch textarea { -webkit-user-select: text; font-size: 16px; } /* 16px stops iOS zooming into a focused field */
body.touch #game { touch-action: none; }
body.touch #help, body.touch #interactHint { display: none !important; }
/* above the joystick zone, which reaches up over the menu column when the phone is held upright */
body.touch #menuBtns { z-index: 2; top: calc(8px + env(safe-area-inset-top)); bottom: auto; right: auto; left: 50%; transform: translateX(-50%); flex-direction: row; gap: 4px; }
body.touch #menuBtns button { padding: 5px 6px; font-size: 17px; }
/* small phones on their side: start the row right after the player frame so the two never overlap */
@media (orientation: landscape) and (max-width: 760px) {
  body.touch #menuBtns { left: calc(226px + env(safe-area-inset-left)); transform: none; gap: 3px; }
  body.touch #menuBtns button { padding: 4px 5px; font-size: 15px; }
}
body.touch #menuBtns button span { display: none; }
body.touch #bottom { bottom: calc(6px + env(safe-area-inset-bottom)); left: auto; right: calc(12px + env(safe-area-inset-right)); transform: none; }
body.touch #actionBar { gap: 6px; padding: 6px; }
body.touch .slot { width: 56px; height: 56px; }
body.touch #chat { z-index: 2; width: min(300px, 40vw); bottom: auto; top: 120px; left: 8px; }
body.touch #chatLog { max-height: 90px; font-size: 11px; }
body.touch #mapWrap { transform: scale(0.6); transform-origin: top right; }
body.touch #questTracker { display: none; }
body.touch #playerFrame { width: 210px; padding: 6px 8px; left: calc(8px + env(safe-area-inset-left)); top: 8px; }
body.touch #targetFrame { left: calc(226px + env(safe-area-inset-left)); top: calc(52px + env(safe-area-inset-top)); width: 180px; padding: 6px 8px; }
body.touch .panel { max-height: calc(100vh - 20px); width: min(560px, calc(100vw - 16px)); }
body.touch .panel.wide { width: calc(100vw - 16px); }
body.touch .bag-grid { grid-template-columns: repeat(6, 1fr); }
body.touch .btn { padding: 9px 12px; }
body.touch #zoneBanner { font-size: 30px; }
@media (max-height: 500px) {
  body.touch #chat { top: 92px; width: 190px; }
  body.touch #chatLog { display: none; }
  body.touch #chatInput { padding: 5px 8px; font-size: 12px; border-radius: 8px; }
  body.touch #tbtns { bottom: 84px; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 48px); }
  body.touch #tbtns button { width: 48px; height: 48px; font-size: 19px; }
  body.touch .slot { width: 48px; height: 48px; font-size: 22px; }
  .login-box { padding: 14px 16px; max-height: calc(100vh - 16px); overflow-y: auto; }
  .login-box h1 { font-size: 30px; }
  .sub { margin-bottom: 10px; }
}
/* phone held upright: menu becomes a slim column on the left, chat a single line, everything fits */
@media (max-width: 560px) and (orientation: portrait) {
  body.touch #playerFrame { width: 170px; }
  body.touch #targetFrame { left: 8px; top: 74px; width: 170px; }
  body.touch #mapWrap { transform: none; top: 8px; right: 8px; }
  body.touch #minimap { width: 96px; height: 96px; border-width: 2px; }
  body.touch #zoneName, body.touch #clock { font-size: 10px; }
  body.touch #menuBtns { top: calc(130px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left)); transform: none; flex-direction: column; gap: 4px; }
  body.touch #menuBtns button { width: 40px; height: 40px; padding: 0; justify-content: center; font-size: 17px; }
  body.touch #chat { top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); left: 52px; width: calc(100vw - 52px - 190px); }
  body.touch #chatLog { display: none; }
  body.touch #chatInput { padding: 6px 8px; border-radius: 8px; }
  body.touch #bottom { left: 0; right: 0; bottom: calc(4px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; }
  body.touch #actionBar { gap: 4px; padding: 4px; }
  body.touch .slot { width: 44px; height: 44px; font-size: 20px; }
  body.touch #tbtns { bottom: calc(76px + env(safe-area-inset-bottom)); grid-template-columns: repeat(3, 46px); grid-template-rows: repeat(2, 46px); gap: 6px; }
  body.touch #tbtns button { width: 46px; height: 46px; font-size: 18px; }
  body.touch #tbtns button.big { width: 56px; height: 56px; }
  body.touch #joyZone { width: 55vw; height: 45vh; bottom: 70px; }
  body.touch #questTracker { display: block; width: 140px; font-size: 10px; margin-left: auto; }
  body.touch #questTracker .qt:not(.story) { display: none; } /* only the story objective, to keep the view clear */
  body.touch #arenaBar { top: auto; bottom: 200px; font-size: 12px; }
  body.touch #storyBanner { top: 22%; }
}
@media (max-width: 700px) {
  .login-box { padding: 20px 16px; max-height: calc(100vh - 16px); overflow-y: auto; }
  .login-box h1 { font-size: 32px; }
  #playerFrame { width: 190px; }
}
.label.mob.target { color: #fff; }
.label.boss { color: #ffcf6e; font-size: 14px; }
.floater { position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 18px; text-shadow: 0 2px 3px #000, 0 0 3px #000; white-space: nowrap; }
.floater.crit { font-size: 26px; color: #ffd84a; }
.floater.taken { color: #ff5a4a; }
.floater.burn { color: #ff9a3a; font-size: 14px; }
.floater.frost { color: #8fe0ff; }
.floater.fire { color: #ffb347; }
.floater.poison { color: #8ee05a; font-size: 14px; }
.floater.storm { color: #e0c8ff; }
.floater.phys { color: #fff0d0; }
.floater.heal { color: #6ef06a; }

@media (max-width: 800px) {
  #targetFrame { left: 14px; top: 110px; }
  #chat { width: 240px; bottom: 120px; }
  .slot { width: 46px; height: 46px; font-size: 22px; }
  #minimap { width: 120px; height: 120px; }
  #menuBtns span { display: none; }
}

/* ---------- upgrade markers in the bag ---------- */
.islot { position: relative; }
.islot .upg { position: absolute; left: 2px; top: 0; font-size: 13px; line-height: 1; color: #6ef06a; text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(110, 240, 106, 0.7); pointer-events: none; }
.islot .upg.later { color: #b5b5a0; text-shadow: 0 0 4px rgba(0, 0, 0, 0.9); }
.tt-verdict { margin-top: 6px; font-weight: 800; }
.tt-verdict.up { color: #6ef06a; }
.tt-verdict.later { color: #d8d0a8; }
.tt-verdict.down { color: #ff8a7a; }
#menuBtns button { position: relative; }
.upg-badge { position: absolute; top: -6px; left: -4px; color: #6ef06a; font-size: 14px; text-shadow: 0 0 4px #000, 0 0 8px rgba(110, 240, 106, 0.8); pointer-events: none; }

/* ---------- character creation: appearance ---------- */
#creator { display: grid; grid-template-columns: 240px 1fr; gap: 14px; margin-bottom: 14px; }
.cr-preview { position: relative; height: 340px; border-radius: 10px; border: 1px solid var(--gold-dim);
  background: radial-gradient(ellipse at 50% 35%, #4a3a28 0%, #1e1710 70%, #120d09 100%); overflow: hidden; }
.cr-preview canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.cr-tools { position: absolute; top: 6px; right: 6px; display: flex; flex-direction: column; gap: 4px; }
.cr-tools .btn { padding: 4px 7px; font-size: 16px; }
.cr-hint { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; font-size: 11px; color: rgba(241, 230, 208, 0.55); pointer-events: none; }
.cr-opts { max-height: 340px; overflow-y: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 6px; }
.cr-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.cr-row.col { flex-direction: column; align-items: stretch; }
.cr-l { color: #cdbb98; }
.cr-l i { color: var(--text); font-style: normal; }
.cr-pick { display: flex; align-items: center; gap: 6px; }
.cr-pick b { min-width: 120px; text-align: center; font-weight: 600; }
.cr-pick button { width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--gold-dim); background: #241b12; color: var(--text); font-size: 18px; line-height: 1; cursor: pointer; }
.cr-sw { display: flex; flex-wrap: wrap; gap: 4px; }
.cr-sw .sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.5); cursor: pointer; padding: 0; }
.cr-sw .sw.on { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(224, 180, 90, 0.5); }
.cr-sw .sw.none { background: repeating-linear-gradient(45deg, #2a2018 0 4px, #4a3a28 4px 8px); }
@media (max-width: 640px) {
  #creator { grid-template-columns: 1fr; }
  .cr-preview { height: 260px; }
  .cr-opts { max-height: none; overflow: visible; }
  .cr-sw .sw { width: 26px; height: 26px; }
}

/* ---------- item pictures ---------- */
.iico { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; -webkit-user-drag: none; }
.islot { background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--rc, #3a2e22) 26%, #1a140f) 0%, #1a140f 72%); }
.islot .iico { width: 92%; height: 92%; }
.list-item .ico { width: 40px; height: 40px; display: grid; place-items: center; flex: none; }
.list-item .ico .iico { width: 40px; height: 40px; }
.mat .iico, .req .iico { display: inline-block; width: 22px; height: 22px; vertical-align: middle; }
.tt-pic { float: right; width: 64px; height: 64px; margin: -2px -2px 4px 8px; }
.tt-pic .iico { width: 64px; height: 64px; }
.slot .iico { width: 70%; height: 70%; margin: auto; }

#gameVer { margin-top: 10px; text-align: center; font-size: 11px; color: rgba(241, 230, 208, 0.45); letter-spacing: 1px; }

