:root {
  --gold: #f0cf7a;
  --gold-dim: #a98a45;
  --edge: rgba(214, 178, 98, .55);
  --edge-soft: rgba(214, 178, 98, .25);
  --glass: linear-gradient(180deg, rgba(34, 29, 24, .93), rgba(15, 13, 11, .95));
  --glass-flat: rgba(14, 13, 12, .78);
  --text: #ece3cf;
  --muted: #a89a7e;
  --green: #3ccf4e;
  --red: #e24a3a;
  --font: "Segoe UI", "Trebuchet MS", Tahoma, sans-serif;
  --serif: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --slot: 44px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0d10; color: var(--text); font-family: var(--font); user-select: none; -webkit-user-select: none; }
canvas#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #6d5a30; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Menü ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; gap: 24px; pointer-events: none; }
.screen > * { pointer-events: auto; }
.panel { background: var(--glass); border: 1px solid var(--edge); border-radius: 8px; box-shadow: 0 0 0 1px #000, 0 14px 50px #000c, inset 0 1px 0 rgba(255, 235, 180, .15); padding: 24px 28px; backdrop-filter: blur(6px); }
.login-panel { width: 380px; }
.login-panel h1 { margin: 0 0 16px; text-align: center; font-family: var(--serif); font-size: 36px; color: var(--gold); text-shadow: 0 2px 10px #000; letter-spacing: 1px; }
.login-panel h1 span { color: #fff; font-weight: 400; }
.side-panel { width: 320px; max-height: 92vh; overflow-y: auto; }
.side-panel.wide { width: 470px; }
.screen#screen-chars, .screen#screen-create { justify-content: space-between; padding: 0 4vw; }
.side-panel h2 { margin: 0 0 12px; font-family: var(--serif); color: var(--gold); }
.side-panel h3 { margin: 16px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 2px; color: var(--gold-dim); font-weight: 600; }
.tabs { display: flex; margin-bottom: 14px; border-bottom: 1px solid var(--edge-soft); }
.tabs button { flex: 1; background: none; color: var(--muted); border: none; border-bottom: 2px solid transparent; padding: 9px; font-size: 14px; }
.tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }
label { display: block; margin: 10px 0; font-size: 12px; color: var(--gold-dim); text-transform: uppercase; letter-spacing: 1px; }
label input, #in-charname { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; background: rgba(0, 0, 0, .45); border: 1px solid var(--edge-soft); color: #fff; font-size: 15px; border-radius: 4px; user-select: text; text-transform: none; letter-spacing: 0; }
label input:focus, #in-charname:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(240, 207, 122, .15); }
button.big { width: 100%; margin-top: 14px; padding: 12px; font-size: 15px; font-family: var(--serif); letter-spacing: .5px; color: #2b1a05; background: linear-gradient(#f7dc8e, #cf9a33); border: 1px solid #6a4a10; border-radius: 4px; font-weight: 700; box-shadow: 0 2px 8px #0008, inset 0 1px 0 #fff6; transition: filter .12s, transform .05s; }
button.big:hover:not(:disabled) { filter: brightness(1.1); }
button.big:active:not(:disabled) { transform: translateY(1px); }
button.big:disabled { filter: grayscale(1) brightness(.5); cursor: default; }
button.small { padding: 6px 12px; background: rgba(255, 255, 255, .05); color: var(--text); border: 1px solid var(--edge-soft); border-radius: 4px; margin-top: 8px; font-size: 13px; }
button.small:hover:not(:disabled) { border-color: var(--gold); color: #fff; }
button.small:disabled { opacity: .4; cursor: default; }
button.small.active { background: rgba(240, 207, 122, .18); border-color: var(--gold); color: var(--gold); }
button.danger { color: #ff8a8a; }
.error { color: #ff7a7a; min-height: 18px; font-size: 13px; margin-top: 6px; }
.hint { text-align: center; color: #8a7a60; font-size: 12px; margin: 12px 0 0; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row .big { margin-top: 12px; }
#char-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; max-height: 50vh; overflow-y: auto; }
.char-item { display: flex; gap: 12px; align-items: center; padding: 9px 11px; background: rgba(255, 255, 255, .04); border: 1px solid var(--edge-soft); border-radius: 6px; cursor: pointer; transition: border-color .12s, background .12s; }
.char-item:hover { border-color: var(--gold-dim); }
.char-item.sel { border-color: var(--gold); background: rgba(240, 207, 122, .1); }
.char-item .ico { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; border: 2px solid; background: #000a; }
.char-item .nm { font-weight: 700; }
.char-item .sub { font-size: 12px; color: var(--muted); }
.cards { display: flex; gap: 8px; flex-wrap: wrap; }
.card { flex: 1 1 120px; min-width: 120px; padding: 10px; background: rgba(255, 255, 255, .04); border: 1px solid var(--edge-soft); border-radius: 6px; cursor: pointer; text-align: center; transition: border-color .12s; }
.card:hover { border-color: var(--gold-dim); }
.card.sel { border-color: var(--gold); background: rgba(240, 207, 122, .1); box-shadow: 0 0 14px rgba(240, 207, 122, .2); }
.card .big-ico { font-size: 28px; }
.card .cn { font-weight: 700; margin-top: 2px; }
.card .cr { font-size: 11px; color: var(--muted); }
.look-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.look-row > span { width: 90px; color: var(--gold-dim); }
.look-row button { margin: 0; }
.swatches { display: flex; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #000; cursor: pointer; outline: 2px solid transparent; }
.swatch.sel { outline-color: var(--gold); }
#class-detail h2 { margin-bottom: 2px; }
#class-detail .role { color: var(--gold-dim); font-size: 13px; margin-bottom: 10px; }
#class-detail .skill { display: flex; gap: 10px; margin: 10px 0; align-items: flex-start; }
#class-detail .skill .si { width: 38px; height: 38px; flex: none; display: grid; place-items: center; font-size: 22px; border: 1px solid var(--edge); border-radius: 6px; background: #000a; }
#class-detail .skill b { color: var(--gold); }
#class-detail .skill div { font-size: 12.5px; color: #cdbf9f; }
#class-detail .skill .lvl { display: inline-block; margin-left: 6px; font-size: 11px; color: var(--muted); }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; font-size: 13px; }
#hud > * { pointer-events: auto; }
#hud #labels, #hud #fct, #hud #errmsg, #hud #tooltip, #hud #levelup { pointer-events: none; }
#labels, #fct { position: absolute; inset: 0; overflow: hidden; }
.nameplate { position: absolute; transform: translate(-50%, -100%); text-align: center; white-space: nowrap; font-size: 13px; font-weight: 700; text-shadow: 0 0 3px #000, 1px 1px 2px #000, -1px -1px 2px #000; }
.nameplate small { display: block; font-size: 11px; font-weight: 400; color: #eec; }
.nameplate .hpb { width: 74px; height: 6px; margin: 2px auto 0; background: #000b; border: 1px solid #000; border-radius: 3px; overflow: hidden; }
.nameplate .hpb i { display: block; height: 100%; background: linear-gradient(#f0d84a, #b89a14); }
.fct { position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 20px; text-shadow: 0 0 3px #000, 1px 1px 2px #000; animation: fct 1.2s ease-out forwards; }
.fct.crit { font-size: 30px; }
.fct.out { color: #ffd84a; }
.fct.in { color: #ff4a4a; }
.fct.other { color: #ddd; font-size: 15px; }
.fct.abs { color: #8fb4ff; font-size: 14px; }
@keyframes fct { 0% { opacity: 0; margin-top: 10px; } 12% { opacity: 1; } 100% { opacity: 0; margin-top: -70px; } }
#errmsg { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); color: #ff5a4a; font-size: 18px; font-weight: 700; text-shadow: 0 0 4px #000, 1px 1px 2px #000; opacity: 0; transition: opacity .4s; }
#errmsg.show { opacity: 1; transition: none; }

/* unit frames: round gold-ringed portrait + slim flat bars */
.uframe { position: absolute; bottom: 20%; display: flex; align-items: center; filter: drop-shadow(0 2px 5px #000b); }
#pframe { left: 24%; }
#tframe { left: 62%; }
.portrait { position: relative; width: 64px; height: 64px; border-radius: 50%; flex: none; z-index: 2; display: grid; place-items: center; font-size: 34px;
  background: radial-gradient(circle at 35% 30%, #5a6a7a, #1b2530); box-shadow: 0 0 0 3px #1a1408, 0 0 0 5px var(--gold-dim), inset 0 0 12px #000; }
.portrait::after { content: ""; position: absolute; inset: -7px; border-radius: 50%; border: 1px solid rgba(255, 235, 170, .55); pointer-events: none; }
.portrait .lvl { position: absolute; bottom: -9px; left: -9px; min-width: 24px; height: 24px; padding: 0 3px; border-radius: 12px; background: #15110a; border: 2px solid var(--gold-dim); font-size: 12px; display: grid; place-items: center; color: #fff6d8; font-weight: 700; }
.target .portrait .lvl { left: auto; right: -9px; }
.bars { width: 172px; margin: 0 -6px; padding: 4px 14px 5px; z-index: 1; background: linear-gradient(90deg, rgba(10, 9, 8, .78), rgba(10, 9, 8, .55)); border: 1px solid var(--edge-soft); border-radius: 4px; }
.target .bars { background: linear-gradient(270deg, rgba(10, 9, 8, .78), rgba(10, 9, 8, .55)); text-align: right; }
.uname { font-size: 12px; font-weight: 700; color: #ffe9a8; text-shadow: 1px 1px 2px #000; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { position: relative; height: 15px; background: #070707; border: 1px solid #000; border-radius: 2px; margin-bottom: 2px; overflow: hidden; box-shadow: inset 0 0 4px #000; }
.bar.res { height: 11px; }
.bar .fill { height: 100%; width: 100%; transition: width .15s; position: relative; }
.bar .fill::after { content: ""; position: absolute; inset: 0 0 50% 0; background: rgba(255, 255, 255, .18); }
.bar.hp .fill { background: linear-gradient(#58e060, #1d9a2c); }
.bar.hp.hostile .fill { background: linear-gradient(#f0d84a, #b08a10); }
.bar.hp.dead .fill { background: #555; }
.bar .txt { position: absolute; inset: 0; text-align: center; font-size: 10.5px; line-height: 14px; color: #fff; text-shadow: 1px 1px 1px #000; }
.bar.res .txt { line-height: 10px; font-size: 9px; }
.buffs { display: flex; gap: 2px; margin-top: 2px; min-height: 16px; }
.target .buffs { justify-content: flex-end; }
.buffs i { width: 17px; height: 17px; font-style: normal; font-size: 11px; display: grid; place-items: center; background: #000a; border: 1px solid #555; border-radius: 3px; }
.buffs i.bad { border-color: #c33; }

/* minimap + objectives */
#topright { position: absolute; top: 8px; right: 14px; width: 224px; display: flex; flex-direction: column; align-items: center; }
#zonebar { width: 100%; display: flex; justify-content: space-between; padding: 3px 12px; font-size: 12px; color: var(--gold); background: var(--glass-flat); border: 1px solid var(--edge-soft); border-radius: 12px; text-shadow: 1px 1px 2px #000; backdrop-filter: blur(4px); }
#minimap-wrap { position: relative; width: 176px; height: 176px; margin-top: 8px; border-radius: 50%; padding: 0;
  box-shadow: 0 0 0 4px #17110a, 0 0 0 6px #b8923c, 0 0 0 7px #000, 0 6px 18px #000a; overflow: hidden; background: #123; }
#minimap { width: 100%; height: 100%; display: block; }
#mm-north { position: absolute; font-size: 10px; color: #fff; text-shadow: 0 0 3px #000; font-weight: 700; }
#tracker { width: 100%; margin-top: 16px; text-shadow: 1px 1px 2px #000; }
#tracker .th { padding: 3px 4px; font-weight: 700; color: var(--gold); border-bottom: 1px solid var(--edge); font-family: var(--serif); letter-spacing: .5px; background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .55)); text-align: right; }
#tracker-body { padding: 4px 4px 4px 8px; text-align: right; background: linear-gradient(90deg, transparent, rgba(0, 0, 0, .35)); }
#tracker .tq { color: #ffd650; font-weight: 700; margin-top: 6px; }
#tracker .to { color: #ddd; font-size: 12px; }
#tracker .to.done { color: #7e7; }

/* chat */
#chat { position: absolute; left: 10px; bottom: 10px; width: 430px; }
#chat-tabs { display: flex; gap: 2px; }
#chat-tabs button { padding: 3px 12px; font-size: 11px; background: rgba(0, 0, 0, .45); color: var(--muted); border: 1px solid var(--edge-soft); border-bottom: none; border-radius: 5px 5px 0 0; }
#chat-tabs button.active { color: var(--gold); background: rgba(0, 0, 0, .7); border-color: var(--edge); }
#chat-log { height: 150px; overflow-y: auto; padding: 5px 8px; background: linear-gradient(180deg, rgba(0, 0, 0, .55), rgba(0, 0, 0, .35)); border: 1px solid var(--edge-soft); border-radius: 0 5px 5px 5px; font-size: 13px; line-height: 1.4; text-shadow: 1px 1px 2px #000; user-select: text; scrollbar-width: thin; }
#chat-log div { word-wrap: break-word; }
.c-sys { color: #ffe27a; } .c-say { color: #fff; } .c-combat { color: #ff9b6a; } .c-xp { color: #b98cff; }
.c-loot { color: #5bd65b; } .c-quest { color: #ffd650; } .c-level { color: #ffeb3b; font-weight: 700; }
#chat[data-f="combat"] #chat-log div:not(.c-combat):not(.c-xp) { display: none; }
#chat[data-f="loot"] #chat-log div:not(.c-loot):not(.c-quest):not(.c-level) { display: none; }
#chat-input { width: 100%; margin-top: 3px; padding: 6px 9px; background: #000c; border: 1px solid var(--edge); color: #fff; display: none; border-radius: 4px; }
#chat.typing #chat-input { display: block; }

/* bottom: xp bar + action bar */
#bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; padding-bottom: 6px; background: linear-gradient(0deg, rgba(0, 0, 0, .55), transparent 80px); pointer-events: none; }
#bottom > * { pointer-events: auto; }
#xpbar { position: relative; width: min(760px, 62vw); height: 8px; background: rgba(8, 4, 16, .85); border: 1px solid #000; border-radius: 4px; box-shadow: 0 0 0 1px var(--edge-soft); margin-bottom: 6px; overflow: hidden; }
#xpbar::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), rgba(0, 0, 0, .55) calc(10% - 1px) 10%); }
#xpfill { height: 100%; width: 0; background: linear-gradient(#b878ff, #6a30c0); transition: width .3s; }
#xptext { position: absolute; inset: 0; z-index: 1; text-align: center; font-size: 8px; line-height: 8px; color: #fff; text-shadow: 1px 1px 1px #000; opacity: 0; transition: opacity .15s; }
#xpbar:hover { height: 14px; } #xpbar:hover #xptext { opacity: 1; line-height: 13px; font-size: 10px; }
#bar-wrap { display: flex; align-items: center; }
.cap { position: relative; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 28px; z-index: 1;
  background: radial-gradient(circle at 40% 35%, #d9a95a, #7a5a22 60%, #2b1a05); box-shadow: 0 0 0 2px #1a1005, 0 0 0 3px #c9a24a, 0 4px 10px #000a; }
.cap.left { margin-right: -14px; }
.cap.right { margin-left: -14px; }
.cap.right span { display: inline-block; transform: scaleX(-1); }
#actionbar { display: flex; gap: 4px; padding: 8px 20px; background: linear-gradient(180deg, rgba(44, 36, 26, .93), rgba(18, 14, 10, .95)); border: 1px solid var(--edge); border-radius: 6px; box-shadow: 0 4px 14px #000a, inset 0 1px 0 rgba(255, 235, 180, .12); }
.slot { position: relative; width: var(--slot); height: var(--slot); background: rgba(0, 0, 0, .55); border: 1px solid #5a4a2c; border-radius: 4px; display: grid; place-items: center; font-size: 24px; cursor: pointer; overflow: hidden; box-shadow: inset 0 0 8px #000; transition: border-color .1s; }
.slot.has { border-color: #8a7240; background: radial-gradient(circle at 50% 35%, rgba(90, 76, 50, .5), rgba(0, 0, 0, .6)); }
.slot.has:hover { border-color: var(--gold); box-shadow: inset 0 0 8px #000, 0 0 8px rgba(240, 207, 122, .5); }
.slot .key { position: absolute; top: 1px; right: 3px; font-size: 10px; color: #e8e0cc; text-shadow: 1px 1px 1px #000; font-family: var(--font); }
.slot .cost { position: absolute; bottom: 0; right: 3px; font-size: 10px; color: #9cf; text-shadow: 1px 1px 1px #000; }
.slot .cdo { position: absolute; inset: 0; background: #000a; display: none; }
.slot .cdt { position: absolute; inset: 0; display: none; place-items: center; font-size: 17px; font-weight: 700; color: #fff; text-shadow: 1px 1px 2px #000; font-family: var(--font); }
.slot.active { border-color: #ff4b3b; box-shadow: inset 0 0 10px #f33a; }
.slot.nores { filter: brightness(.55) saturate(.5); }
.slot.press { transform: scale(.93); }
.slot.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 #ffe27a, inset 0 0 14px #ffe27a; } 100% { box-shadow: 0 0 0 14px #ffe27a00, inset 0 0 0 #ffe27a00; } }
#micro { display: flex; gap: 3px; margin-left: 14px; padding: 6px 8px; background: linear-gradient(180deg, rgba(44, 36, 26, .93), rgba(18, 14, 10, .95)); border: 1px solid var(--edge); border-radius: 6px; }
#micro button { width: 32px; height: 38px; background: rgba(0, 0, 0, .5); border: 1px solid #5a4a2c; border-radius: 4px; font-size: 17px; color: #fff; }
#micro button:hover { border-color: var(--gold); }

#castbar { position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%); width: 240px; height: 18px; background: rgba(0, 0, 0, .75); border: 1px solid #000; border-radius: 3px; box-shadow: 0 0 0 1px var(--edge); overflow: hidden; }
#castbar .fill { height: 100%; background: linear-gradient(#ffd34a, #d99a10); width: 0; }
#castbar span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 17px; color: #fff; text-shadow: 1px 1px 1px #000; }

/* windows */
.win { position: absolute; background: var(--glass); border: 1px solid var(--edge); border-radius: 6px; box-shadow: 0 10px 34px #000c, inset 0 1px 0 rgba(255, 235, 180, .12); min-width: 250px; backdrop-filter: blur(6px); }
.win.wide { width: 640px; }
.wtitle { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border-bottom: 1px solid var(--edge-soft); color: var(--gold); font-family: var(--serif); font-weight: 700; cursor: move; letter-spacing: .5px; background: linear-gradient(90deg, rgba(240, 207, 122, .12), transparent); }
.wtitle .x { background: none; border: none; color: #bbb; font-size: 14px; }
.wtitle .x:hover { color: #fff; }
.wbody { padding: 10px 12px; }
.wbody.split { display: flex; gap: 10px; min-height: 280px; }
.wfoot { padding: 6px 12px 12px; display: flex; gap: 8px; }
.wfoot .big { margin-top: 0; }
.wfoot .small { margin-top: 0; }
.parchment { background: linear-gradient(#e0cc9c, #d4bc86); color: #2b1b0a; border-radius: 4px; box-shadow: inset 0 0 25px #7a5a1d88; font-family: var(--serif); }
.parchment h4 { margin: 0 0 8px; font-size: 18px; color: #5a1a00; }
.parchment .ob { font-weight: 700; margin: 10px 0 3px; color: #3a2000; }
.parchment .reward { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
#dialog { left: 12%; top: 16%; width: 440px; }
#dialog .wbody { margin: 10px; max-height: 52vh; overflow-y: auto; user-select: text; }
#dlg-tabs { display: flex; gap: 4px; padding: 8px 10px 0; }
#dlg-tabs:empty { display: none; }
#dlg-tabs button { padding: 5px 12px; font-size: 12px; background: rgba(255, 255, 255, .05); color: var(--muted); border: 1px solid var(--edge-soft); border-radius: 4px; }
#dlg-tabs button.active { color: var(--gold); border-color: var(--gold); background: rgba(240, 207, 122, .1); }
#dlg-text { white-space: pre-wrap; line-height: 1.45; font-size: 14.5px; }
.trow { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid rgba(90, 60, 20, .3); }
.trow:last-child { border-bottom: none; }
.trow .ti { width: 38px; height: 38px; flex: none; display: grid; place-items: center; font-size: 22px; background: rgba(0, 0, 0, .45); border: 1px solid #6a4a1a; border-radius: 5px; }
.trow .tn { flex: 1; min-width: 0; font-size: 14px; }
.trow .tn small { display: block; font-size: 11.5px; color: #5a4526; line-height: 1.3; }
.trow .tp { font-size: 13px; white-space: nowrap; }
.trow .ta { min-width: 70px; text-align: right; }
.trow .ta .small { margin: 0; background: #3a2a10; color: #ffe9a8; border-color: #6a4a1a; }
.trow .tk { color: #1a6a1a; font-weight: 700; font-size: 12px; }
.trow .tl { color: #7a3a1a; font-size: 11.5px; }
.trow.locked { opacity: .7; }
.trow.sell { cursor: pointer; } .trow.sell:hover { background: rgba(90, 60, 20, .2); }
#spellbook .trow { border-bottom-color: var(--edge-soft); } #spellbook .trow .tn small { color: var(--muted); } #spellbook .trow .ti { border-color: var(--edge); }
#spellbook .trow.locked { opacity: .55; } #spellbook .trow .tl { color: #d49a6a; }
#spellbook { left: 30%; top: 14%; width: 400px; max-height: 70vh; overflow-y: auto; }
#lootwin { left: 40%; top: 30%; width: 260px; }
.lootrow { display: flex; gap: 8px; align-items: center; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; }
.lootrow:hover { background: rgba(240, 207, 122, .1); border-color: var(--gold-dim); }
.lootrow .ii { width: 34px; height: 34px; display: grid; place-items: center; font-size: 20px; background: #000a; border: 2px solid #555; border-radius: 4px; }
.r-poor { color: #9d9d9d; } .r-common { color: #fff; } .r-uncommon { color: #1eff00; }
.ii.r-poor { border-color: #9d9d9d; } .ii.r-common { border-color: #ddd; } .ii.r-uncommon { border-color: #1eff00; }
.coin { font-weight: 700; } .coin .g { color: #ffd700; } .coin .s { color: #ccd; } .coin .c { color: #d9803d; }
#bags { right: 8%; bottom: 20%; width: 230px; min-width: 230px; }
#bag-grid { display: grid; grid-template-columns: repeat(4, 46px); gap: 4px; justify-content: center; }
.bslot { position: relative; width: 46px; height: 46px; background: rgba(0, 0, 0, .55); border: 1px solid #4a3c22; border-radius: 4px; display: grid; place-items: center; font-size: 24px; }
.bslot .cnt { position: absolute; bottom: 0; right: 3px; font-size: 11px; color: #fff; text-shadow: 1px 1px 1px #000; }
#bag-money { margin-top: 10px; text-align: right; }
#questlog { left: 50%; top: 12%; transform: translateX(-50%); }
#ql-list { width: 200px; }
#ql-list .qi { padding: 6px 8px; cursor: pointer; border-radius: 3px; color: #ffd650; font-weight: 700; }
#ql-list .qi:hover { background: rgba(240, 207, 122, .1); } #ql-list .qi.sel { background: rgba(240, 207, 122, .2); }
#ql-detail { flex: 1; padding: 12px; font-size: 14px; user-select: text; overflow-y: auto; max-height: 55vh; }
#charwin { left: 12%; top: 20%; width: 280px; }
#char-body .row2 { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--edge-soft); }
#menuwin { left: 50%; top: 25%; transform: translateX(-50%); width: 280px; }
.menu .big { margin-top: 8px; }
#controls-help { margin-top: 10px; font-size: 12.5px; line-height: 1.6; color: #d8cba8; }
#controls-help b { color: var(--gold); display: inline-block; min-width: 110px; }
#deathbox { position: absolute; top: 28%; left: 50%; transform: translateX(-50%); text-align: center; padding: 20px 40px; background: rgba(32, 10, 10, .85); border: 1px solid #a33; border-radius: 6px; backdrop-filter: blur(4px); }
#deathbox h2 { margin: 0 0 6px; color: #f55; font-family: var(--serif); }
#tooltip { position: absolute; z-index: 50; max-width: 270px; padding: 8px 11px; background: rgba(10, 8, 6, .96); border: 1px solid var(--gold-dim); border-radius: 5px; font-size: 12.5px; line-height: 1.4; box-shadow: 0 6px 20px #000c; }
#tooltip .tt { font-weight: 700; color: var(--gold); font-size: 14px; }
#tooltip .tm { color: #aaa; }
#levelup { position: absolute; top: 28%; left: 50%; transform: translateX(-50%); font-family: var(--serif); font-size: 64px; font-weight: 900; color: #ffe27a; text-shadow: 0 0 20px #f90, 0 3px 6px #000; animation: lvl 3s ease-out forwards; }
@keyframes lvl { 0% { opacity: 0; transform: translateX(-50%) scale(.5); } 15% { opacity: 1; transform: translateX(-50%) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(1); } }
#toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); color: #fff; background: rgba(0, 0, 0, .8); border: 1px solid var(--edge); padding: 8px 18px; border-radius: 6px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 99; }
#toast.show { opacity: 1; }
.parchment .r-uncommon { color: #0a7a00; } .parchment .r-common { color: #333; } .parchment .r-poor { color: #666; }
.parchment .coin .g { color: #8a6400; } .parchment .coin .s { color: #555; } .parchment .coin .c { color: #8a4a10; }

#sys-btns { position: fixed; top: 8px; left: 10px; display: flex; gap: 4px; z-index: 60; }
#sys-btns button { width: 30px; height: 30px; background: var(--glass-flat); border: 1px solid var(--edge-soft); border-radius: 5px; color: #fff; font-size: 15px; backdrop-filter: blur(4px); }
#sys-btns button:hover { border-color: var(--gold); }
input[type=range] { padding: 0; accent-color: #d9a93a; }

/* ---------- Touch / Mobil (Querformat) ---------- */
#touch-ui, #rotate-hint { display: none; }
body.touch { overscroll-behavior: none; touch-action: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.touch input { user-select: text; -webkit-user-select: text; touch-action: manipulation; }
body.touch #sys-btns { top: max(4px, env(safe-area-inset-top)); left: max(6px, env(safe-area-inset-left)); }
body.touch #sys-btns button { width: 34px; height: 34px; }

/* Bitte drehen */
@media (orientation: portrait) {
  body.touch #rotate-hint { position: fixed; inset: 0; z-index: 999; display: grid; place-items: center; text-align: center; background: #0b0d10; color: var(--gold); padding: 24px; font-family: var(--serif); }
  body.touch #rotate-hint .ri { font-size: 64px; }
  body.touch #rotate-hint p { font-size: 18px; margin: 10px 0 0; }
}

/* Steuerelemente nur im Spiel */
body.touch #hud:not(.hidden) ~ #touch-ui { display: block; }
body.touch #touch-ui { position: fixed; inset: 0; pointer-events: none; z-index: 20; }
#joy { position: fixed; width: 140px; height: 140px; left: calc(max(14px, env(safe-area-inset-left)) + 10px); bottom: calc(max(12px, env(safe-area-inset-bottom)) + 14px); top: auto; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02)); border: 2px solid rgba(240, 207, 122, .35); opacity: .55; display: grid; place-items: center; }
#joy.active { opacity: .9; bottom: auto; }
#joy .knob { width: 60px; height: 60px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #f4dc98, #a9822c); border: 2px solid #3b2a08; box-shadow: 0 2px 8px #000a; }
.tbtn { position: fixed; pointer-events: auto; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; color: #fff; background: radial-gradient(circle at 40% 35%, rgba(90, 76, 50, .85), rgba(18, 14, 10, .85)); border: 2px solid var(--gold-dim); box-shadow: 0 3px 10px #000a; }
.tbtn.on { transform: scale(.92); border-color: var(--gold); filter: brightness(1.3); }
.tbtn.big { width: 78px; height: 78px; font-size: 34px; }
:root { --tr: max(14px, env(safe-area-inset-right)); --tb: max(12px, env(safe-area-inset-bottom)); }
#t-atk { right: calc(var(--tr) + 10px); bottom: calc(var(--tb) + 10px); }
#t-jump { right: calc(var(--tr) + 92px); bottom: calc(var(--tb) + 6px); }
#t-tgt { right: calc(var(--tr) + 94px); bottom: calc(var(--tb) + 70px); }
#t-use { right: calc(var(--tr) + 20px); bottom: calc(var(--tb) + 98px); }
#t-chat { right: calc(var(--tr) + 160px); bottom: calc(var(--tb) + 10px); width: 40px; height: 40px; font-size: 18px; }

/* HUD kompakter */
body.touch { --slot: 38px; }
body.touch #hud { font-size: 11px; }
body.touch #bottom { padding-bottom: max(4px, env(safe-area-inset-bottom)); background: none; }
body.touch #hud { z-index: 25; }
body.touch #xpbar { width: 300px; margin-bottom: 3px; }
body.touch #bar-wrap { flex-direction: column; align-items: center; gap: 3px; }
body.touch .cap { display: none; }
body.touch #actionbar { display: grid; grid-template-columns: repeat(7, var(--slot)); gap: 3px; padding: 5px 6px; }
body.touch .slot { font-size: 20px; }
body.touch .slot .key { display: none; }
body.touch #micro { position: fixed; top: max(4px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); margin: 0; padding: 3px 5px; }
body.touch #micro button { width: 38px; height: 34px; }
body.touch #castbar { bottom: 112px; }
body.touch .uframe { bottom: auto; top: max(44px, calc(env(safe-area-inset-top) + 40px)); transform: scale(.78); }
body.touch #pframe { left: max(2px, env(safe-area-inset-left)); transform-origin: left top; }
body.touch #tframe { left: 200px; transform-origin: left top; }
body.touch #petframes { left: 12px; bottom: auto; top: 130px; }
body.touch #partyframes { top: 128px; left: max(6px, env(safe-area-inset-left)); }
body.touch #topright { top: max(4px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); width: 130px; }
body.touch #minimap-wrap { width: 100px; height: 100px; margin-top: 4px; }
body.touch #zonebar { padding: 1px 8px; font-size: 10px; }
body.touch #tracker { display: none; }
body.touch #chat { display: none; left: max(8px, env(safe-area-inset-left)); bottom: auto; top: 40px; width: 300px; z-index: 30; }
body.touch #chat.open { display: block; }
body.touch #chat-log { height: 90px; font-size: 12px; }
body.touch #zb-zone { font-size: 30px; }
body.touch #levelup { font-size: 40px; }
body.touch #zonebanner { top: 8%; }
body.touch #deathbox { top: 22%; }

/* Fenster passen ins Querformat */
body.touch .win { top: 4px !important; bottom: auto !important; max-height: calc(100% - 8px); overflow-y: auto; transform: none; }
body.touch #questlog, body.touch #menuwin { left: 50% !important; transform: translateX(-50%); }
body.touch .win.wide { width: min(640px, calc(100vw - 16px)); }
body.touch #dialog { width: min(440px, calc(100vw - 24px)); }
body.touch #dialog .wbody { max-height: 48vh; }
body.touch #mapwin { width: auto; }
body.touch .wtitle { cursor: default; }
body.touch .wtitle .x { font-size: 20px; padding: 0 8px; }
body.touch button.small { padding: 9px 14px; }
body.touch #tooltip { max-width: 220px; }

/* Menü-Bildschirme niedrig */
@media (pointer: coarse) and (max-height: 520px) {
  .login-panel { width: 340px; padding: 12px 18px; } .login-panel h1 { font-size: 26px; margin-bottom: 8px; }
  .side-panel { width: 280px; padding: 12px 16px; max-height: 96vh; } .side-panel.wide { width: 400px; }
  button.big { margin-top: 8px; padding: 9px; }
}
