* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b0f1e; overflow: hidden; font-family: "Courier New", monospace; color: #e0f7ff; }
#game { position: fixed; inset: 0; }
#game canvas { image-rendering: pixelated; }

#login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 20, .85); z-index: 10; }
#login .box { background: #121a33; border: 3px solid #2de2e6; padding: 28px; width: min(360px, 90vw); text-align: center; box-shadow: 0 0 30px #2de2e655; }
#login h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: 4px; color: #2de2e6; }
#login h1 span { color: #ff3cac; margin-left: 8px; }
#login p { margin: 0 0 18px; color: #9fb3d9; }
#login input, #login button { width: 100%; padding: 10px; font: inherit; font-size: 16px; border: 2px solid #2de2e6; background: #0b0f1e; color: #e0f7ff; }
#potbtn, #invbtn { position: fixed; z-index: 5; background: #121a33; border: 2px solid #2de2e6; color: #e0f7ff; font: inherit; font-size: 14px; padding: 6px 10px; cursor: pointer; }
#potbtn { top: 10px; right: 10px; }
#invbtn { top: 50px; right: 10px; }
#potbtn small, #invbtn small { color: #ffca28; margin-left: 6px; }
#toasts { position: fixed; top: 100px; right: 10px; z-index: 6; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; pointer-events: none; }
#toasts div { background: rgba(5, 8, 20, .85); border-left: 3px solid var(--c); padding: 4px 8px; font-size: 13px; animation: fade 3s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#inv { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 8; background: #121a33; border: 3px solid #2de2e6; padding: 14px; width: min(340px, calc(100vw - 32px)); box-shadow: 0 0 30px #2de2e655; }
#inv[hidden] { display: none; }
#inv .head { font-weight: bold; color: #2de2e6; display: flex; justify-content: space-between; margin-bottom: 8px; }
#inv .head button { background: none; border: none; color: #e0f7ff; font-size: 16px; cursor: pointer; }
#inv .label { font-size: 12px; color: #9fb3d9; margin: 10px 0 4px; }
#stats { font-size: 13px; color: #ffca28; }
#equip { display: flex; gap: 6px; }
#grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.slot { aspect-ratio: 1; min-width: 34px; background: #0b0f1e; border: 2px solid #22306b; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; position: relative; }
#equip .slot { width: 48px; }
.slot.empty { opacity: .35; cursor: default; }
.slot.comun { border-color: #9fb3d9; }
.slot.raro { border-color: #4fc3f7; box-shadow: inset 0 0 6px #4fc3f7; }
.slot.epico { border-color: #e040fb; box-shadow: inset 0 0 8px #e040fb; }
.slot.legendario { border-color: #ffab00; box-shadow: inset 0 0 10px #ffab00, 0 0 8px #ffab0088; }
.slot.locked::after { content: '🚫'; position: absolute; font-size: 10px; right: 0; bottom: 0; }
#tip { min-height: 54px; margin-top: 10px; font-size: 12px; color: #e0f7ff; background: #0b0f1e; padding: 6px; }
#tip .n { font-weight: bold; }
#bitsbox { position: fixed; top: 90px; right: 10px; z-index: 5; background: #121a33; border: 2px solid #2de2e6; padding: 6px 10px; font-size: 14px; color: #2de2e6; font-weight: bold; }
#toasts { top: 132px; }
#shophint { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 5; background: rgba(5, 8, 20, .85); border: 2px solid #ff3cac; padding: 6px 12px; font-size: 14px; }
#shophint[hidden], #shop[hidden] { display: none; }
#shophint b { color: #ffca28; }
#shop { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 8; background: #121a33; border: 3px solid #ff3cac; padding: 14px; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 0 30px #ff3cac55; }
#shop .head { font-weight: bold; color: #ff3cac; display: flex; justify-content: space-between; }
#shop .head button { background: none; border: none; color: #e0f7ff; font-size: 16px; cursor: pointer; }
#shop .sub { font-size: 12px; color: #9fb3d9; margin: 4px 0 10px; }
#shoplist { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.skin { background: #0b0f1e; border: 2px solid #22306b; padding: 8px; text-align: center; font-size: 12px; }
.skin.raro { border-color: #4fc3f7; } .skin.epico { border-color: #e040fb; } .skin.legendario { border-color: #ffab00; box-shadow: 0 0 10px #ffab0077; }
.skin canvas { width: 96px; height: 96px; image-rendering: pixelated; display: block; margin: 0 auto 4px; }
.skin .nm { font-weight: bold; font-size: 13px; }
.skin .rar { font-size: 11px; margin-bottom: 6px; }
.skin button { width: 100%; padding: 5px; font: inherit; font-size: 12px; border: 2px solid #2de2e6; background: #182457; color: #e0f7ff; cursor: pointer; }
.skin button:disabled { opacity: .45; cursor: default; }
.skin button.on { background: #2de2e6; color: #0b0f1e; font-weight: bold; }
#shopmsg { min-height: 18px; margin-top: 8px; font-size: 13px; color: #ffca28; text-align: center; }
#questbox { position: fixed; top: 132px; right: 10px; z-index: 5; width: 220px; background: rgba(18, 26, 51, .9); border: 2px solid #ffca28; padding: 8px; font-size: 12px; }
#questbox[hidden], #dialog[hidden] { display: none; }
#questbox .qt { color: #ffca28; font-weight: bold; font-size: 13px; margin-bottom: 2px; }
#questbox #qgoal { color: #e0f7ff; margin-bottom: 4px; }
#questbox .bar { position: relative; height: 14px; background: #05070f; border: 1px solid #22306b; }
#questbox .fill { height: 100%; background: #ffca28; width: 0; transition: width .2s; }
#questbox .bar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 13px; color: #fff; text-shadow: 1px 1px #000; }
#questbox.ready { border-color: #66bb6a; box-shadow: 0 0 12px #66bb6a88; }
#toasts { top: 210px; }
#dialog { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 8; width: min(480px, calc(100vw - 32px)); background: #121a33; border: 3px solid #2de2e6; padding: 14px; box-shadow: 0 0 30px #2de2e655; }
#dialog .head { color: #2de2e6; font-weight: bold; display: flex; justify-content: space-between; }
#dialog .head button { background: none; border: none; color: #e0f7ff; font-size: 16px; cursor: pointer; }
#dialog .qname { color: #ffca28; font-weight: bold; margin-top: 6px; }
#dialog p { margin: 6px 0; line-height: 1.4; font-size: 14px; }
#dlgreward { font-size: 13px; color: #66bb6a; margin-bottom: 8px; }
#dlgbtn { width: 100%; padding: 8px; font: inherit; font-weight: bold; border: 2px solid #2de2e6; background: #2de2e6; color: #0b0f1e; cursor: pointer; }
#dungeons[hidden], #dunhud[hidden], #bossbar[hidden] { display: none; }
#dungeons { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 8; width: min(480px, calc(100vw - 32px)); background: #121a33; border: 3px solid #7c4dff; padding: 14px; box-shadow: 0 0 30px #7c4dff66; }
#dungeons .head { color: #b388ff; font-weight: bold; display: flex; justify-content: space-between; }
#dungeons .head button { background: none; border: none; color: #e0f7ff; font-size: 16px; cursor: pointer; }
#dungeons .sub { font-size: 12px; color: #9fb3d9; margin: 4px 0 10px; }
.dun { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: #0b0f1e; border: 2px solid #7c4dff; padding: 8px; margin-bottom: 6px; font-size: 13px; }
.dun.locked { border-color: #22306b; opacity: .6; }
.dun small { color: #9fb3d9; }
.dun .ok { color: #66bb6a; font-size: 11px; }
.dun button { flex-shrink: 0; padding: 6px 10px; font: inherit; font-size: 12px; border: 2px solid #b388ff; background: #7c4dff; color: #fff; cursor: pointer; }
.dun button:disabled { background: #182457; border-color: #22306b; color: #9fb3d9; cursor: default; }
#dunmsg { color: #ffca28; font-size: 13px; min-height: 16px; text-align: center; }
#dunhud { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 5; text-align: center; background: rgba(18, 26, 51, .9); border: 2px solid #7c4dff; padding: 6px 12px; font-size: 13px; }
#dunname { color: #b388ff; font-weight: bold; }
#dunstatus { color: #e0f7ff; margin: 2px 0 4px; }
#dunleave { font: inherit; font-size: 12px; padding: 3px 10px; background: #182457; color: #e0f7ff; border: 2px solid #7c4dff; cursor: pointer; }
#bossbar { position: fixed; top: 92px; left: 50%; transform: translateX(-50%); z-index: 5; width: min(520px, calc(100vw - 32px)); text-align: center; }
#bossname { color: #ff1744; font-weight: bold; text-shadow: 1px 1px #000; margin-bottom: 2px; }
#bossbar .bb { position: relative; height: 18px; background: #05070f; border: 2px solid #ff1744; }
#bossfill { height: 100%; background: linear-gradient(90deg, #b71c1c, #ff1744); transition: width .15s; }
#bosshp { position: absolute; inset: 0; font-size: 12px; line-height: 14px; color: #fff; text-shadow: 1px 1px #000; }
#skills.silenced { filter: grayscale(1) brightness(.6); }
#partybtn { position: fixed; top: 50px; right: 140px; z-index: 5; background: #121a33; border: 2px solid #2de2e6; color: #e0f7ff; font: inherit; font-size: 14px; padding: 6px 10px; cursor: pointer; }
#partybtn small { color: #ffca28; margin-left: 6px; }
#partyhud[hidden], #partypanel[hidden], #invitebox[hidden], #partyleave[hidden] { display: none; }
#partyhud { position: fixed; top: 150px; left: 10px; z-index: 5; width: 200px; display: flex; flex-direction: column; gap: 4px; }
#partyhud .pm { background: rgba(18, 26, 51, .85); border: 1px solid #22306b; padding: 3px 6px; font-size: 12px; }
#partyhud .pm .bar { height: 6px; background: #05070f; margin-top: 2px; }
#partyhud .pm .bar div { height: 100%; background: #66bb6a; }
#partyhud .pm.away { opacity: .5; }
#partypanel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 8; width: min(380px, calc(100vw - 32px)); background: #121a33; border: 3px solid #2de2e6; padding: 14px; }
#partypanel .head { color: #2de2e6; font-weight: bold; display: flex; justify-content: space-between; }
#partypanel .head button { background: none; border: none; color: #e0f7ff; font-size: 16px; cursor: pointer; }
#partypanel .sub { font-size: 12px; color: #9fb3d9; margin: 4px 0 10px; }
#partypanel .row, #invitebox .row { display: flex; gap: 6px; }
#partypanel input { flex: 1; min-width: 0; padding: 6px; font: inherit; background: #0b0f1e; color: #e0f7ff; border: 2px solid #22306b; }
#partypanel button, #invitebox button { padding: 6px 10px; font: inherit; font-size: 12px; border: 2px solid #2de2e6; background: #182457; color: #e0f7ff; cursor: pointer; }
#partylist { margin: 10px 0; font-size: 13px; }
#partylist .pl { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid #22306b; }
#partylist .pl button { padding: 2px 6px; font-size: 11px; border-color: #ef5350; }
#partyleave { width: 100%; border-color: #ef5350 !important; }
#invitebox { position: fixed; top: 100px; left: 50%; transform: translateX(-50%); z-index: 9; background: #121a33; border: 3px solid #ffca28; padding: 10px 14px; text-align: center; font-size: 14px; box-shadow: 0 0 20px #ffca2866; }
#invitebox .row { justify-content: center; margin-top: 8px; }
#invitebox #invyes { background: #2de2e6; color: #0b0f1e; font-weight: bold; }
.dun .btns { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.dun button.hard { background: #b71c1c; border-color: #ff1744; }
#dunname .hard { color: #ff1744; }
@media (max-width: 700px) { #partybtn { top: 50px; right: auto; left: 10px; } #partyhud { top: 190px; } }
#minimap { position: fixed; right: 10px; bottom: 10px; z-index: 5; width: 200px; height: 150px; border: 2px solid #2de2e6; background: #05070f; image-rendering: pixelated; }
#minimap[hidden] { display: none; }
#zonebanner { position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 6; pointer-events: none; text-align: center;
  font-size: 30px; font-weight: bold; letter-spacing: 3px; text-shadow: 2px 2px #000, 0 0 12px currentColor; opacity: 0; transition: opacity .6s; }
#zonebanner small { display: block; font-size: 14px; letter-spacing: 1px; color: #e0f7ff; }
#zonebanner.show { opacity: 1; }
@media (max-width: 700px) { #minimap { width: 120px; height: 90px; bottom: 230px; } #zonebanner { font-size: 20px; } }
#soundbtn { position: fixed; top: 10px; right: 90px; z-index: 5; background: #121a33; border: 2px solid #2de2e6; color: #e0f7ff; font-size: 15px; padding: 5px 9px; cursor: pointer; }
#soundpanel { position: fixed; top: 48px; right: 90px; z-index: 9; background: #121a33; border: 2px solid #2de2e6; padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; width: 210px; }
#soundpanel[hidden] { display: none; }
#soundpanel label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#soundpanel input { width: 110px; accent-color: #2de2e6; }
#soundpanel button { font: inherit; font-size: 12px; padding: 4px; background: #182457; color: #e0f7ff; border: 2px solid #2de2e6; cursor: pointer; }
#tester { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 10; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; background: #121a33; border: 3px solid #2de2e6; padding: 14px; }
#tester[hidden] { display: none; }
#tester .head { color: #2de2e6; font-weight: bold; display: flex; justify-content: space-between; }
#tester .head button { background: none; border: none; color: #e0f7ff; font-size: 16px; cursor: pointer; }
#tester .sub { font-size: 12px; color: #9fb3d9; margin: 4px 0 8px; }
#tester .label { font-size: 12px; color: #ffca28; margin: 10px 0 4px; }
#testthemes, #testsfx { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 4px; }
#tester button.t { font: inherit; font-size: 12px; padding: 5px; text-align: left; background: #0b0f1e; color: #e0f7ff; border: 2px solid #22306b; cursor: pointer; }
#tester button.t:hover, #tester button.t.on { border-color: #2de2e6; }
#tester button.t b { color: #ffca28; }
#rules { font-size: 11px; color: #9fb3d9; text-align: left; margin-top: 8px; line-height: 1.4; }
#rules[hidden] { display: none; }
#log b.gm { color: #ffca28; }
.flybit { position: fixed; z-index: 7; font-size: 16px; pointer-events: none; transition: left .55s cubic-bezier(.5,-0.4,.7,1), top .55s cubic-bezier(.3,0,.7,1.4), opacity .55s, transform .55s; }
#bitsbox.pulse { animation: pulse .3s; }
@keyframes pulse { 50% { transform: scale(1.15); box-shadow: 0 0 14px #2de2e6; } }
#panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 8; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto;
  background: #121a33; border: 3px solid var(--pc, #2de2e6); padding: 14px; box-shadow: 0 0 30px #0008; }
#panel[hidden] { display: none; }
#panel .head { display: flex; justify-content: space-between; font-weight: bold; color: var(--pc, #2de2e6); }
#panel .head button { background: none; border: none; color: #e0f7ff; font-size: 16px; cursor: pointer; }
#ptext { font-size: 13px; color: #9fb3d9; margin: 6px 0 10px; white-space: pre-line; }
#ptext:empty { display: none; }
.pi { display: flex; gap: 8px; align-items: center; background: #0b0f1e; border: 2px solid #22306b; padding: 8px; margin-bottom: 6px; }
.pi.raro { border-color: #4fc3f7; } .pi.epico { border-color: #e040fb; } .pi.legendario { border-color: #ffab00; }
.pi .ic { font-size: 22px; width: 32px; text-align: center; flex-shrink: 0; }
.pi canvas { width: 32px; height: 32px; image-rendering: pixelated; flex-shrink: 0; }
.pi .tx { flex: 1; min-width: 0; font-size: 13px; }
.pi .tx b { display: block; }
.pi .tx small { color: #9fb3d9; white-space: pre-line; display: block; line-height: 1.35; }
.pi .bt, #pextra { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
#panel button.pb { font: inherit; font-size: 12px; padding: 5px 9px; border: 2px solid var(--pc, #2de2e6); background: #182457; color: #e0f7ff; cursor: pointer; }
#panel button.pb:disabled { opacity: .45; cursor: default; }
#pmsg { color: #ffca28; font-size: 13px; text-align: center; min-height: 16px; margin-top: 4px; }
#pfoot { font-size: 12px; color: #2de2e6; text-align: center; margin-top: 4px; }
#sidelist { margin-top: 6px; font-size: 11px; color: #e0f7ff; }
#sidelist div { display: flex; justify-content: space-between; gap: 6px; }
#sidelist div.ok { color: #66bb6a; }
#matsline { font-size: 12px; color: #e0f7ff; margin-top: 4px; }
#achbtn { position: fixed; top: 90px; right: 110px; z-index: 5; background: #121a33; border: 2px solid #ffca28; color: #e0f7ff; font: inherit; font-size: 14px; padding: 6px 10px; cursor: pointer; }
#achbtn small { color: #ffca28; margin-left: 6px; }
#achbanner { position: fixed; top: 32%; left: 50%; transform: translate(-50%, -20px); z-index: 9; pointer-events: none; opacity: 0; transition: all .4s;
  background: linear-gradient(90deg, #3e2723, #ff8f00, #3e2723); border: 3px solid #ffd600; padding: 10px 24px; text-align: center; font-weight: bold; color: #fff8e1; text-shadow: 1px 1px #000; }
#achbanner small { display: block; font-weight: normal; font-size: 12px; }
#achbanner.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 700px) { #achbtn { top: 90px; right: auto; left: 10px; } }
/* ===================== MÓVIL / TÁCTIL ===================== */
html, body { overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
input, textarea { -webkit-user-select: text; user-select: text; }
#game { touch-action: none; }
#touch[hidden], #chatbtn[hidden], #tact[hidden] { display: none !important; }
#touch { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
#joyzone { position: absolute; left: 0; bottom: 0; width: 45%; height: 60%; pointer-events: auto; touch-action: none; }
#joy { position: absolute; left: calc(28px + env(safe-area-inset-left)); bottom: calc(28px + env(safe-area-inset-bottom)); width: 120px; height: 120px;
  border-radius: 50%; background: rgba(45, 226, 230, .12); border: 2px solid rgba(45, 226, 230, .5); }
#knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: rgba(45, 226, 230, .55); border: 2px solid #2de2e6; box-shadow: 0 0 12px #2de2e688; }
#tbtns { position: absolute; right: calc(18px + env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom)); width: 190px; height: 190px; pointer-events: none; }
.tb { position: absolute; pointer-events: auto; touch-action: none; width: 62px; height: 62px; border-radius: 50%; border: 3px solid #2de2e6;
  background: rgba(18, 26, 51, .78); color: #e0f7ff; font: bold 13px 'Courier New', monospace; overflow: hidden; padding: 0; }
.tb.big { width: 86px; height: 86px; right: 0; bottom: 0; font-size: 14px; border-color: #ffca28; }
.tb[data-s="1"] { right: 96px; bottom: 6px; }
.tb[data-s="2"] { right: 18px; bottom: 98px; }
.tb.small { width: 48px; height: 48px; font-size: 20px; }
#tpot { right: 112px; bottom: 96px; border-color: #ef5350; }
#tact { right: 100px; bottom: 156px; border-color: #ff3cac; background: rgba(255, 60, 172, .3); animation: pulse 1s infinite; }
.tb.down { transform: scale(.92); background: rgba(45, 226, 230, .35); }
.tb .tl { position: relative; z-index: 2; }
.tb .tcd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(5, 8, 20, .7); z-index: 1; }
#chatbtn { position: fixed; left: 10px; top: calc(118px + env(safe-area-inset-top)); z-index: 6; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid #2de2e6; background: #121a33; font-size: 20px; }

body.mobile #skills, body.mobile #help { display: none; }
body.mobile #hud { top: calc(6px + env(safe-area-inset-top)); left: calc(6px + env(safe-area-inset-left)); transform: scale(.85); transform-origin: top left; }
body.mobile #chat { display: none; bottom: auto; top: calc(168px + env(safe-area-inset-top)); width: min(320px, 70vw); }
body.mobile #chat.open { display: block; }
body.mobile #log { max-height: 110px; font-size: 12px; }
/* Botones de arriba a la derecha: fila compacta de iconos */
body.mobile #soundbtn, body.mobile #potbtn, body.mobile #invbtn, body.mobile #partybtn, body.mobile #achbtn {
  top: calc(6px + env(safe-area-inset-top)); left: auto; width: 40px; height: 40px; padding: 0; font-size: 0; border-radius: 8px; }
body.mobile #soundbtn { right: calc(6px + env(safe-area-inset-right)); font-size: 16px; }
body.mobile #invbtn { right: calc(50px + env(safe-area-inset-right)); }
body.mobile #partybtn { right: calc(94px + env(safe-area-inset-right)); }
body.mobile #achbtn { right: calc(138px + env(safe-area-inset-right)); }
body.mobile #potbtn { display: none; }
body.mobile #invbtn::before { content: '🎒'; font-size: 18px; }
body.mobile #partybtn::before { content: '👥'; font-size: 18px; }
body.mobile #achbtn::before { content: '🏅'; font-size: 18px; }
body.mobile #bitsbox { top: calc(52px + env(safe-area-inset-top)); right: calc(6px + env(safe-area-inset-right)); font-size: 12px; padding: 3px 8px; }
body.mobile #questbox { top: calc(84px + env(safe-area-inset-top)); right: calc(6px + env(safe-area-inset-right)); width: 170px; font-size: 11px; padding: 5px; }
body.mobile #questbox.mini #qgoal, body.mobile #questbox.mini .bar, body.mobile #questbox.mini #sidelist { display: none; }
body.mobile #minimap { width: 96px; height: 72px; top: calc(70px + env(safe-area-inset-top)); bottom: auto; right: auto; left: calc(6px + env(safe-area-inset-left)); }
body.mobile #chatbtn { top: calc(150px + env(safe-area-inset-top)); }
body.mobile #chat { top: calc(150px + env(safe-area-inset-top)); left: 60px; }
body.mobile #touch { z-index: 6; }
body.mobile #questbox { max-width: 44vw; }
body.mobile #toasts { top: calc(150px + env(safe-area-inset-top)); }
body.mobile #shophint { bottom: auto; top: calc(48px + env(safe-area-inset-top)); font-size: 12px; }
body.mobile #shophint b { display: none; }
body.mobile #dunhud { top: calc(48px + env(safe-area-inset-top)); font-size: 11px; }
body.mobile #bossbar { top: calc(100px + env(safe-area-inset-top)); width: min(360px, 60vw); }
body.mobile #partyhud { top: calc(168px + env(safe-area-inset-top)); transform: scale(.85); transform-origin: top left; }
body.mobile #zonebanner { font-size: 20px; }
body.mobile #inv, body.mobile #shop, body.mobile #panel, body.mobile #dungeons, body.mobile #tester { max-height: calc(100vh - 20px); overflow-y: auto; }
body.mobile #dialog { bottom: 10px; }
/* Pantalla en vertical: aviso para girar el móvil */
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) {
  body.mobile.playing #rotate { display: flex; position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 3; padding: 10px 14px;
    background: rgba(18, 26, 51, .9); border: 2px solid #ffca28; font-size: 13px; text-align: center; pointer-events: none; border-radius: 6px; animation: fade 4s forwards; }
}
#gallink { display: block; margin-top: 10px; font-size: 12px; color: #2de2e6; }
#install { display: none; }
#install.show { display: block; margin-top: 10px; width: 100%; padding: 8px; font: inherit; border: 2px solid #ffca28; background: #3e2723; color: #ffca28; cursor: pointer; }
#iosHint { font-size: 11px; color: #9fb3d9; margin-top: 8px; display: none; }
#iosHint.show { display: block; }
#tabs { display: flex; gap: 6px; margin-bottom: 10px; }
#login button.tab { margin: 0; background: #0b0f1e; color: #9fb3d9; border-color: #22306b; font-weight: bold; }
#login button.tab.sel { color: #2de2e6; border-color: #2de2e6; }
.passwrap { position: relative; margin-top: 8px; }
.passwrap #pass { padding-right: 46px; }
#login .passwrap #eye { position: absolute; right: 2px; top: 2px; bottom: 2px; width: 40px; margin: 0; padding: 0; background: #182457; border: none; color: #e0f7ff; font-size: 18px; cursor: pointer; }
#login .passwrap #eye.on { background: #2de2e6; color: #0b0f1e; }
#err { color: #ef5350; font-size: 13px; min-height: 16px; margin-top: 6px; }
#classes[hidden] { display: none; }
#classes { display: grid; gap: 6px; margin-top: 10px; }
#login button.cls { margin: 0; background: #0b0f1e; color: #e0f7ff; border-color: #22306b; text-align: left; font-weight: normal; padding: 8px 10px; }
#login button.cls b { display: block; color: var(--c); }
#login button.cls small { color: #9fb3d9; font-size: 12px; }
#login button.cls.sel, #login button.cls:hover { border-color: var(--c); background: #182457; }
#skills { position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 5; }
#skills .sk { position: relative; width: 74px; height: 58px; background: #121a33; border: 2px solid #2de2e6; text-align: center; font-size: 11px; padding-top: 6px; overflow: hidden; }
#skills .sk .key { display: block; color: #ffca28; font-weight: bold; font-size: 14px; }
#skills .sk .cdov { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(5, 8, 20, .75); }
#skills .sk .cdt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: bold; color: #fff; text-shadow: 1px 1px #000; }
@media (max-width: 700px) { #skills { bottom: 230px; } }
#login button#play { margin-top: 10px; background: #2de2e6; color: #0b0f1e; font-weight: bold; cursor: pointer; }
#login button:hover { background: #ff3cac; border-color: #ff3cac; }

#hud { position: fixed; top: 10px; left: 10px; font-size: 13px; z-index: 5; text-shadow: 1px 1px #000; }
#hud #online { color: #2de2e6; font-weight: bold; margin-top: 4px; }
#hud #lvl { color: #ffca28; font-weight: bold; font-size: 15px; margin-bottom: 4px; }
#hud .bar { position: relative; width: 200px; height: 16px; background: #05070f; border: 2px solid #22306b; margin-bottom: 4px; }
#hud .fill { height: 100%; width: 100%; transition: width .2s; }
#hud .fill.hp { background: #ef5350; }
#hud .fill.xp { background: #2de2e6; }
#hud .bar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 12px; color: #fff; }
#hud #help { color: #9fb3d9; }

#chat { position: fixed; left: 10px; bottom: 10px; width: min(380px, calc(100vw - 20px)); z-index: 5; }
#log { max-height: 170px; overflow-y: auto; font-size: 13px; background: rgba(5, 8, 20, .6); padding: 6px 8px; }
#log div { margin: 2px 0; word-wrap: break-word; }
#log .sys { color: #ffca28; }
#log b { color: #2de2e6; }
#msg { width: 100%; padding: 8px; font: inherit; font-size: 13px; border: 2px solid #2de2e655; background: rgba(5, 8, 20, .8); color: #e0f7ff; outline: none; }
#msg:focus { border-color: #2de2e6; }
#chat.typing::after { content: 'Escribiendo… Enter: enviar · Esc o clic fuera: volver al juego'; display: block; font-size: 11px; color: #ffca28; margin-top: 2px; }

/* Rarezas del arsenal */
.slot .ico { width: 34px; height: 34px; image-rendering: pixelated; pointer-events: none; }
.slot.poco { border-color: #4cdc6a; box-shadow: inset 0 0 6px #4cdc6a; }
.slot.rara { border-color: #3d9bff; box-shadow: inset 0 0 8px #3d9bff; }
.slot.leg { border-color: #ffb300; box-shadow: inset 0 0 10px #ffb300, 0 0 8px #ffb30088; }
.slot.exo { border-color: #ff1744; box-shadow: inset 0 0 12px #ff1744, 0 0 10px #ff1744aa; animation: exoSlot 1.4s ease-in-out infinite; }
@keyframes exoSlot { 50% { box-shadow: inset 0 0 16px #ff6d00, 0 0 16px #ff1744; } }

.slot { position: relative; }
.slot .qty { position: absolute; right: 2px; bottom: 0; font-size: 10px; font-weight: bold; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.pi .ic.slot { width: 36px; height: 36px; border: 2px solid #22306b; display: grid; place-items: center; }
.pi .ic.slot .ico { width: 30px; height: 30px; image-rendering: pixelated; }
.pi.comun { border-color: #9fb3d9; } .pi.poco { border-color: #4cdc6a; } .pi.rara { border-color: #3d9bff; } .pi.leg { border-color: #ffb300; } .pi.exo { border-color: #ff1744; }

/* Amigos, lobby y buscador de grupo */
#friendsbtn, #lobbybtn { position: fixed; z-index: 5; background: #121a33; border: 2px solid #66bb6a; color: #e0f7ff; font: inherit; font-size: 14px; padding: 6px 10px; cursor: pointer; }
#friendsbtn { top: 130px; right: 110px; }
#lobbybtn { top: 130px; right: 230px; border-color: #4fc3f7; }
#finderbox { position: fixed; top: 170px; left: 50%; transform: translateX(-50%); z-index: 6; background: #1a1033ee; border: 2px solid #b388ff; color: #e0f7ff; padding: 6px 10px; font-size: 13px; }
#finderbox button { background: none; border: 1px solid #b388ff; color: #b388ff; margin-left: 8px; cursor: pointer; font: inherit; }
#finderbtn { width: 100%; margin: 4px 0 8px; background: #2a1840; border: 2px solid #b388ff; color: #e0f7ff; font: inherit; padding: 6px; cursor: pointer; }
@media (max-width: 700px) { #friendsbtn { top: 130px; right: auto; left: 10px; } #lobbybtn { top: 170px; right: auto; left: 10px; } }
body.mobile #friendsbtn, body.mobile #lobbybtn { top: calc(6px + env(safe-area-inset-top)); left: auto; width: 40px; height: 40px; padding: 0; font-size: 0; border-radius: 8px; }
body.mobile #friendsbtn { right: calc(182px + env(safe-area-inset-right)); }
body.mobile #lobbybtn { right: calc(226px + env(safe-area-inset-right)); }
body.mobile #friendsbtn::before { content: '🤝'; font-size: 18px; }
body.mobile #lobbybtn::before { content: '🌐'; font-size: 18px; }
body.mobile #finderbox { top: calc(52px + env(safe-area-inset-top)); font-size: 11px; }
