/* Estilo "foro de Dofus 2010": pergamino claro, barras verdes, botones naranjas, Verdana/Tahoma. */
:root {
  --bg: #3b2f20; --bg2: #e4d8b4; --panel: #f7f0da; --panel2: #eadfbb; --line: #bda76f;
  --text: #3d2f1b; --dim: #7d6c49; --accent: #dd7a00; --good: #3d8a2b; --bad: #b8321f; --blue: #2f6fb0;
  --green1: #a5ba35; --green2: #6f8a17; --greenline: #55700f;
  --radius: 8px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; color: var(--text); font-family: Verdana, Tahoma, "Segoe UI", sans-serif; font-size: 13px;
  background: #3b2f20 url("assets/bg.jpg") center top / cover fixed no-repeat; }
#app { height: 100%; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 8px; }
h3 { color: var(--greenline); border-bottom: 1px solid var(--line); padding-bottom: 3px; font-size: 1rem; }
h3 small { color: var(--dim); font-weight: 400; font-size: .72em; }
.small { color: var(--dim); font-size: .78rem; }
.hide { display: none !important; }
.art { display: block; }

/* ---- botones */
.btn { background: linear-gradient(#fbf6e6, #e3d5a8); border: 1px solid #a48d52; border-radius: 6px; padding: 7px 13px; cursor: pointer; font-weight: 700; color: #4a3a1c; box-shadow: 0 1px 0 #fff8 inset, 0 1px 2px #0003; }
.btn:hover:not(:disabled) { background: linear-gradient(#fffbe9, #efe0ae); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: linear-gradient(#ffb443, #e07b00); color: #fff; border-color: #b45f00; text-shadow: 0 1px 1px #7a3d00aa; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(#ffc26a, #ee8a10); }
.btn.big { padding: 11px 20px; font-size: 1.05rem; }
.btn.ghost { background: transparent; box-shadow: none; }
#menuMusic { position: fixed; top: 12px; right: 12px; z-index: 50; width: 40px; height: 40px; padding: 0; font-size: 1.3rem; line-height: 1; }
#menuMusic.off { background: linear-gradient(#e5484d, #b8232a); border-color: #7a1418; color: #fff; }
#menuMusic[hidden] { display: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.mini { background: linear-gradient(#fbf6e6, #e3d5a8); border: 1px solid #a48d52; border-radius: 5px; padding: 3px 8px; font-size: .74rem; cursor: pointer; font-weight: 700; color: #4a3a1c; }
.mini:hover { background: #fff6d6; }
.mini.dbg { background: linear-gradient(#e59a86, #c4523a); color: #fff; border-color: #8d2f1c; }
input[type=text], input[type=number], input:not([type]), select { background: #fffdf3; border: 1px solid #a48d52; border-radius: 4px; padding: 6px 8px; width: 100%; box-shadow: 0 1px 2px #0002 inset; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px #dd7a0044; }

/* ---- inicio */
.home { max-width: 440px; margin: 24px auto; padding: 22px 20px; display: flex; flex-direction: column; gap: 11px; background: var(--panel); border: 2px solid #8a7440; border-radius: 10px; box-shadow: 0 8px 30px #0008; }
.home h1 { text-align: center; font-size: 1.7rem; color: #fff; background: linear-gradient(var(--green1), var(--green2)); border: 1px solid var(--greenline); border-radius: 6px; padding: 8px; text-shadow: 0 2px 2px #34470a; margin: 0; }
.home .sub { text-align: center; color: var(--dim); margin: 0 0 4px; }
.logo { display: flex; justify-content: center; gap: 4px; }
.home label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: .82rem; }
.row { display: flex; gap: 8px; }
.or { text-align: center; color: var(--dim); font-size: .82rem; }
.conn { background: #c4523a; color: #fff; padding: 5px 10px; border-radius: 6px; text-align: center; font-size: .82rem; }
#conn.conn:not(.hide) { position: fixed; left: 50%; top: 8px; transform: translateX(-50%); z-index: 99; }

/* ---- lobby */
.lobby { max-width: 640px; margin: 14px auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--panel); border: 2px solid #8a7440; border-radius: 10px; box-shadow: 0 8px 30px #0008; }
.lobbyhead { display: flex; justify-content: space-between; align-items: center; background: linear-gradient(var(--green1), var(--green2)); border: 1px solid var(--greenline); border-radius: 6px; padding: 8px 14px; color: #fff; }
.lobbyhead .small { color: #eef5c4; }
.code { font-size: 2.2rem; font-weight: 900; letter-spacing: .25em; color: #fff; text-shadow: 0 2px 2px #34470a; cursor: pointer; }
.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.pl { display: flex; align-items: center; gap: 8px; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.pl.off { opacity: .5; }
.pl b { flex: 1; }
.tag { background: #fffdf3; border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-size: .68rem; color: var(--dim); }
.tag.me { background: #6f8a17; color: #fff; border-color: var(--greenline); } .tag.bot { background: #dd7a00; color: #fff; border-color: #b45f00; }
#lset { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.f { display: flex; flex-direction: column; gap: 3px; font-size: .78rem; color: var(--dim); }
.biomes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 8px; }
.bio { border-left: 8px solid var(--c); padding: 4px 8px; position: relative; display: flex; flex-direction: column; gap: 4px;
  background: #fffdf3; border-radius: 0 6px 6px 0; font-size: .78rem; color: var(--dim); }
.bio.off { opacity: .55; border-left-style: dashed; }
.biotog { display: flex; align-items: center; gap: 6px; cursor: pointer; color: var(--text); }
.biotog input { width: 16px; height: 16px; accent-color: var(--green2); }
.bioval { display: flex; flex-direction: column; gap: 2px; }
.bio em { position: absolute; right: 8px; top: 5px; font-style: normal; color: var(--accent); font-weight: 700; }
/* orden fijo de biomas: lista en una columna, con asa para arrastrar y su posición (1º, 2º…) */
.biorow { display: flex; align-items: center; gap: 6px; }
.biohandle, .bionum { display: none; }
.biomes.ordered { grid-template-columns: 1fr; }
.biomes.ordered .bio { flex-direction: row; align-items: center; gap: 12px; padding-right: 70px; }
.biomes.ordered .bioval { flex-direction: row; align-items: center; gap: 6px; }
.biomes.ordered .bioval input { width: 64px; }
.biomes.ordered .bio em { top: 50%; transform: translateY(-50%); }
.biomes.ordered .biohandle { display: inline-block; cursor: grab; touch-action: none; user-select: none; font-size: 1.15rem;
  line-height: 1; padding: 2px 4px; color: var(--dim); border-radius: 4px; }
.biomes.ordered .biohandle:hover { background: rgba(0,0,0,.07); color: var(--text); }
.biomes.ordered .bionum { display: inline-block; min-width: 1.6em; font-style: normal; font-weight: 800; color: var(--accent); }
.bio.dragging { box-shadow: 0 4px 14px rgba(0,0,0,.25); outline: 2px solid var(--accent); z-index: 2; }
.bio.dragging .biohandle { cursor: grabbing; }
/* sala: desplegable con los objetos de la tienda que salen (desmarcados = tachados y apagados) */
.itemsdd { margin-top: 8px; border: 1px solid #a48d52; border-radius: 6px; background: #fffdf3; }
.itemsdd > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 10px; font-weight: 700; color: #4a3a1c; background: linear-gradient(#fbf6e6, #e3d5a8); border-radius: 6px; }
.itemsdd > summary::-webkit-details-marker { display: none; }
.itemsdd > summary b { color: var(--accent); white-space: nowrap; }
.itemsdd[open] > summary { border-radius: 6px 6px 0 0; border-bottom: 1px solid #c9b27e; }
.ddbody { padding: 6px 10px 8px; }
.ddbtns { display: flex; gap: 6px; margin-bottom: 2px; }
.itoggles { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; margin: 6px 0; }
.itoggles > b { width: 100%; font-size: .78rem; color: var(--dim); }
.itog { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px; border: 1px solid var(--line); border-radius: 14px; background: #fffdf3; font-size: .76rem; cursor: pointer; }
.itog input { width: auto; margin: 0; }
.itog.off { opacity: .55; text-decoration: line-through; background: transparent; }
.small.warn { color: #b8321f; font-weight: 700; }
.lstats { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 10px 0; padding: 6px 10px;
  border: 1px dashed #a48d52; border-radius: 6px; font-size: .82rem; color: var(--dim); }
.mini.danger { background: linear-gradient(#e5484d, #b8232a); border-color: #7a1418; color: #fff; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: .82rem; color: var(--dim); }
.check input { width: auto; }

/* ---- juego */
.game { height: 100dvh; display: grid; grid-template-rows: auto minmax(160px, 1fr) auto auto; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 5px 10px; gap: 8px; color: #fff; background: linear-gradient(var(--green1), var(--green2)); border-bottom: 2px solid var(--greenline); }
.tb-l { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-r { display: flex; gap: 6px; }
.rc { background: #fffdf3; color: var(--greenline); border-radius: 4px; padding: 1px 8px; font-weight: 900; letter-spacing: .15em; }
.tmsg { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 1px #34470a; }
.tmsg.mine { color: #fff3a8; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.mapwrap { position: relative; min-height: 0; background: #2a2016; border-top: 2px solid #8a7440; border-bottom: 2px solid #8a7440; }
.map { position: absolute; inset: 0; }
.mapsvg { width: 100%; height: 100%; display: block; }
/* vista 2.5D: el lienzo WebGL y una capa encima para los números flotantes */
.map25 { width: 100%; height: 100%; display: block; touch-action: manipulation; }
.map25fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.map25float { position: absolute; transform: translate(-50%, -100%); font: 900 20px sans-serif; -webkit-text-stroke: 4px #1a1020; paint-order: stroke fill;
  white-space: nowrap; animation: floatup25 1.3s ease-out forwards; }
@keyframes floatup25 { from { transform: translate(-50%, -100%); opacity: 1; } to { transform: translate(-50%, calc(-100% - 30px)); opacity: 0; } }
.mapbtns { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; z-index: 4; }
.mapbtns .mini { padding: 6px 12px; font-size: .86rem; border-radius: 7px; box-shadow: 0 2px 5px #0004; }
.cell.done .cbody { opacity: .45; }
.cell.done .cicon { opacity: .5; }
.cell.off { opacity: .35; }
.token { transition: transform .55s cubic-bezier(.3, .8, .3, 1); }
.token.active circle.tbody { stroke: #ffd84a; stroke-width: 4.5; animation: tpulse 1s infinite; }
.token.me .tbody { filter: drop-shadow(0 0 4px #fff); }
/* personajes: el turno se marca con el anillo de los pies (dorado y latiendo) */
.token.active .tring { stroke: #ffd84a; stroke-width: 3.5; animation: tringp 1s infinite; }
@keyframes tringp { 50% { stroke-width: 1.5; opacity: .6; } }
.token.player.hit .tbody, .token.summon.hit .tbody { animation: tokhitp .6s; }
.token.player.heal .tbody, .token.summon.heal .tbody { animation: tokhealp .6s; }
@keyframes tokhitp { 0%, 55% { filter: sepia(1) saturate(8) hue-rotate(-50deg) brightness(1.1) drop-shadow(0 0 5px #ff2a2a); } }
@keyframes tokhealp { 0%, 55% { filter: brightness(1.2) saturate(1.5) drop-shadow(0 0 6px #4fe07a); } }
@keyframes tpulse { 50% { stroke-width: 2.5; } }
/* invocación a punto de atacar: se hincha dos veces y brilla; anillos que se expanden desde ella */
.token.summon .tbody { transform-box: fill-box; transform-origin: center; }
.token.charging .tbody { animation: tokcharge .6s ease-in-out; }
@keyframes tokcharge { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.55); filter: drop-shadow(0 0 5px #ffd84a); } 50% { transform: scale(1.2); } 72% { transform: scale(1.6); filter: drop-shadow(0 0 7px #ffd84a); } }
.chargering { transform-box: fill-box; transform-origin: center; opacity: 0; animation: chargering .5s ease-out forwards; }
@keyframes chargering { from { transform: scale(1); opacity: 1; } to { transform: scale(3.6); opacity: 0; } }
.sumchip.casting { animation: castglow .8s ease-out; }
.floaty { animation: floatup 1.3s ease-out forwards; }
@keyframes floatup { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-26px); opacity: 0; } }
.ring { animation: ringp 1.1s infinite; pointer-events: none; }
@keyframes ringp { 50% { opacity: .5; } }
/* mapa interactivo: información de la casilla bajo el puntero y menú de habilidades sobre ti */
.mapwrap.aiming .map { cursor: crosshair; }
.token { cursor: pointer; }
/* invisible (sram): solo lo ve quien lo controla, casi transparente */
.token.ghost { opacity: .2; }
/* fuego de la moto de ADN: la llama se mece con el viento */
.flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flamewave 1.1s ease-in-out infinite alternate; }
@keyframes flamewave {
  0% { transform: skewX(-7deg) scale(1, .94); }
  50% { transform: skewX(3deg) scale(.96, 1.06); }
  100% { transform: skewX(8deg) scale(1.03, .97); }
}
.maptip, .quickcast { position: absolute; z-index: 5; max-width: min(300px, calc(100% - 12px)); background: rgba(30, 22, 14, .94); color: #f7ecd0;
  border: 1px solid #bda76f; border-radius: 8px; padding: 7px 9px; font-size: .74rem; line-height: 1.35; box-shadow: 0 6px 18px #0009; }
.maptip { pointer-events: none; display: flex; flex-direction: column; gap: 3px; }
.maptip[hidden], .quickcast[hidden] { display: none; }
.tiphead { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; border-bottom: 1px solid #bda76f55; padding-bottom: 3px; }
.tiphead b { color: #ffd84a; font-size: .8rem; } .tiphead span { color: #cdbb8c; font-size: .66rem; white-space: nowrap; }
.maptip i { color: #cdbb8c; }
.tipunit { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; background: #ffffff10; border-radius: 5px; padding: 2px 5px; }
.tipaim { margin-top: 2px; color: #b8f08a; font-weight: 700; } .tipaim.no { color: #ff9a8a; }
.quickcast { display: flex; flex-direction: column; gap: 4px; min-width: 170px; }
.qhead { display: flex; justify-content: space-between; align-items: center; color: #ffd84a; font-weight: 700; }
.qskill { display: flex; align-items: center; gap: 6px; background: linear-gradient(#fffdf3, #efe4c0); border: 1px solid #a48d52; border-radius: 6px;
  padding: 3px 7px; cursor: pointer; color: var(--text); font-size: .76rem; text-align: left; }
.qskill:hover { border-color: var(--accent); background: #fff6d6; }
.qskill span { flex: 1; font-weight: 700; } .qskill em { font-style: normal; color: var(--accent); font-weight: 700; }

.players { display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px; background: var(--bg2); }
.pcard { position: relative; flex: 0 0 auto; display: flex; gap: 6px; align-items: center; min-width: 168px; background: var(--panel); border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 6px; padding: 4px 8px 4px 4px; }
.pcard.active { border-color: var(--accent); background: #fff2c9; box-shadow: 0 0 0 2px #dd7a0066; }
.pcard.me .pname { color: var(--good); }
.pcard.off { opacity: .5; }
.pname { font-weight: 800; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.pmeta { display: flex; gap: 8px; font-size: .7rem; color: var(--dim); align-items: center; }
.pmeta span { display: inline-flex; align-items: center; gap: 2px; }
.bar { position: relative; height: 15px; background: #d3c496; border-radius: 8px; overflow: hidden; border: 1px solid #8a7440; margin: 2px 0; min-width: 96px; }
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#8fd45a, #4a9a26); transition: width .4s; }
.bar.foe i { background: linear-gradient(#f08a72, #c4402a); }
.bar span { position: relative; z-index: 1; display: block; text-align: center; font-size: .66rem; font-weight: 800; line-height: 13px; color: #fff; text-shadow: 0 1px 2px #000c; }
.sts { display: flex; flex-wrap: wrap; gap: 3px; }
.st { background: color-mix(in srgb, var(--c) 28%, #fffdf3); border: 1px solid var(--c); border-radius: 5px; padding: 0 5px; font-size: .62rem; font-weight: 700; color: #3d2f1b; }
.psum { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.sumchip .art { vertical-align: -3px; }
.sumchip { position: relative; background: #fffdf3; border: 1px dashed var(--c, #888); border-radius: 5px; padding: 0 5px; font-size: .62rem; color: var(--text); }
.coin { display: inline-flex; align-items: center; gap: 2px; color: #b07a00; font-weight: 800; }

.actions { background: var(--bg2); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.hint { color: var(--dim); text-align: center; padding: 4px; display: flex; gap: 8px; justify-content: center; align-items: center; }
.dicebadges { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.badge { background: #fffdf3; border: 1px solid var(--line); padding: 3px 12px; border-radius: 14px; font-size: .88rem; display: inline-flex; gap: 6px; align-items: center; }
.badge b { font-size: 1.1rem; }
.badge.mv b { color: var(--blue); } .badge.ap b { color: var(--accent); }
.skills { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.skill { position: relative; display: flex; align-items: center; gap: 7px; text-align: left; background: linear-gradient(#fffdf3, #efe4c0); border: 1px solid #a48d52; border-radius: 8px; padding: 6px 8px; cursor: pointer; min-height: 52px; color: var(--text); }
.skill:hover:not(:disabled) { background: #fff6d6; border-color: var(--accent); }
.skill.sel { border-color: var(--accent); background: #ffe7b0; box-shadow: 0 0 0 2px #dd7a0066; }
.skill:disabled { opacity: .5; cursor: not-allowed; }
.sic { color: #7a5a1c; flex: 0 0 auto; }
.stx { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.15; }
.stx b { font-size: .8rem; } .stx small, .stx em { font-size: .66rem; color: var(--dim); font-style: normal; }
.scost { background: linear-gradient(#ffb443, #e07b00); border: 1px solid #b45f00; border-radius: 50%; width: 30px; height: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 900; font-size: 1rem; color: #fff; line-height: 1; text-shadow: 0 1px 1px #7a3d00; flex: 0 0 auto; }
.scost i { font-size: .45rem; font-style: normal; }
.why { position: absolute; right: 6px; top: 2px; font-size: .58rem; color: var(--bad); font-weight: 700; }
.sdesc { display: none; position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); background: #3b2f20; color: #f7f0da; border-radius: 6px; padding: 6px 9px; font-size: .72rem; z-index: 20; pointer-events: none; }
@media (hover: hover) { .skill:hover .sdesc { display: block; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: #fffdf3; border: 1px solid #a48d52; border-radius: 14px; padding: 3px 10px; font-size: .78rem; cursor: pointer; color: var(--text); }
button.chip:hover:not(:disabled) { background: #fff0c4; }
.chip:disabled { opacity: .45; }
.chip.tgt { background: #ffe7b0; border-color: var(--accent); font-weight: 700; }
.chip.ghost { background: transparent; }
.none { color: var(--dim); font-size: .8rem; }
.targets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; background: #fff4d0; border: 1px dashed var(--accent); border-radius: 8px; padding: 6px 8px; font-size: .82rem; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; }
/* mientras se anima o se espera al servidor, las acciones de juego no responden (ver main.js) */
body.busy .actions button, body.busy .fightcard button, body.busy .shop button, body.busy .card [data-act=roll], body.busy .card [data-act=pick] { cursor: progress; }
.btnrow .btn { flex: 1 1 auto; }

/* ---- modales */
.modal { position: fixed; inset: 0; background: #1c140bb0; display: flex; align-items: center; justify-content: center; padding: 10px; z-index: 30; overflow-y: auto; }
.card { background: var(--panel); border: 2px solid #8a7440; border-radius: 10px; padding: 14px; width: min(100%, 460px); max-height: 100%; overflow-y: auto; box-shadow: 0 12px 40px #000b; }
.card.wide { width: min(100%, 980px); }
.card.center { text-align: center; }
.card.center .btn { margin-top: 10px; }
.card > h2 { color: #fff; background: linear-gradient(var(--green1), var(--green2)); border: 1px solid var(--greenline); border-radius: 6px; padding: 6px 10px; text-shadow: 0 1px 2px #34470a; font-size: 1.05rem; }
.rrow { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.rrow.pend .rstate { color: var(--accent); }
.rval { min-width: 34px; }
.ords { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ord { background: var(--panel2); border: 1px solid var(--line); padding: 1px 9px; border-radius: 12px; font-size: .76rem; color: var(--dim); }
.ord.now { background: var(--accent); border-color: #b45f00; color: #fff; font-weight: 800; }
.ord.done { color: var(--good); }
.cgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.ccard { background: #fffdf3; border: 2px solid var(--c); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.chead { display: flex; gap: 10px; align-items: center; }
.chead h3 { margin: 0; color: var(--c); border: 0; filter: brightness(.8); }
.role { color: var(--dim); font-size: .76rem; }
.hpline { display: flex; gap: 4px; align-items: center; color: #c23a5a; font-weight: 800; font-size: .82rem; }
.cdesc { margin: 0; font-size: .76rem; color: var(--dim); }
.csk { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; font-size: .74rem; flex: 1; }
.csk li > .art { display: inline-block; vertical-align: middle; margin-right: 3px; color: #7a5a1c; }
.cs { color: var(--accent); font-size: .68rem; font-weight: 700; }
.csk small { color: var(--dim); }

.fightcard { width: min(100%, 560px); border-color: #a4532c; background: linear-gradient(#f9e6c8, #efd2a6); }
.fightcard.final { border-color: #c4222f; box-shadow: 0 0 40px #c4222f88; }
.ftitle { text-align: center; font-weight: 900; letter-spacing: .1em; color: #fff; background: linear-gradient(#d0623f, #a4381c); border: 1px solid #7a2510; border-radius: 6px; padding: 4px; text-transform: uppercase; margin-bottom: 8px; text-shadow: 0 1px 2px #5a1a08; }
.arena { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; margin-bottom: 8px; }
.fighter { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; }
.fighter .bar { width: 100%; max-width: 170px; }
.fname { font-weight: 800; }
.fdesc { font-size: .68rem; color: var(--dim); max-width: 180px; }
.vs { font-weight: 900; font-size: 1.3rem; color: #a4381c; }
.apbadge { background: #fffdf3; border: 1px solid var(--line); padding: 1px 12px; border-radius: 14px; }
.apbadge b { color: var(--accent); font-size: 1.15rem; }
.fighter.enemy .enemy { animation: bob 2.2s ease-in-out infinite; }
/* invocaciones del combate: a la izquierda del personaje (en el HTML van detrás, así ".fighter.hero .art" es él) */
.herorow { display: flex; align-items: flex-end; gap: 2px; }
.pets { order: -1; display: flex; flex-direction: column; gap: 2px; }
.pet { position: relative; animation: bob 1.8s ease-in-out infinite; }
.pet:nth-child(2) { animation-delay: -.6s; } .pet:nth-child(3) { animation-delay: -1.2s; }
.arena .pet .art { width: 46px; height: 46px; }
.pet b { position: absolute; right: -2px; bottom: 0; background: #fffdf3; border: 1px solid var(--line); border-radius: 8px; font-size: .62rem; padding: 0 4px; }
.pet.casting { animation: castglow .8s ease-out; }
.st.pend { display: inline-flex; align-items: center; gap: 3px; }
.st.pend svg { flex: none; }
@keyframes bob { 50% { transform: translateY(-5px); } }
.flog { margin-top: 8px; background: #fffdf3; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; max-height: 110px; overflow-y: auto; font-size: .72rem; }
.ll { padding: 1px 0; color: var(--dim); }
.ll.dmg { color: #b8321f; } .ll.heal { color: #2f7a1f; } .ll.turn { color: #55700f; font-weight: 700; } .ll.win { color: #b07a00; font-weight: 800; }
.ll.death { color: #b8321f; font-weight: 700; } .ll.money, .ll.shop { color: #a06a00; } .ll.fight { color: #8a3a5a; } .ll.status { color: #5a4a9a; }

.shop .shophead { display: flex; align-items: center; gap: 12px; }
.shop .shophead h2 { flex: 1; margin: 0; }
/* inventario, arriba de la tienda: iconos con tooltip propio (nombre + qué hace) */
.inv { margin: 8px 0 4px; background: #fffdf3; border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px 8px; }
.inv h3 { margin: 4px 0 6px; }
.islots { display: flex; flex-wrap: wrap; gap: 6px; }
.islot { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: #f3ead2; border: 1px solid #c9b27e; cursor: help; }
.islot.dofus { border: 2px solid #d9a521; background: linear-gradient(#fff8dc, #fbe9a8); }
.islot > b { position: absolute; right: -4px; bottom: -4px; background: #4a3a1c; color: #fff; font-size: .62rem; border-radius: 8px; padding: 0 4px; }
.islot.new { animation: invnew .7s cubic-bezier(.3, 1.6, .5, 1); box-shadow: 0 0 0 3px #ffd84a, 0 0 14px #ffd84a; }
@keyframes invnew { 0% { transform: scale(0) rotate(-20deg); } 100% { transform: scale(1) rotate(0); } }
.itip { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 20; width: max-content; max-width: 220px;
  background: #3b2f20; color: #f6ead0; border: 1px solid #d9a521; border-radius: 6px; padding: 5px 8px; font-size: .72rem; line-height: 1.3; text-align: left; box-shadow: 0 4px 12px #0007; pointer-events: none; }
.itip b { display: block; color: #ffd84a; font-size: .78rem; }
.islot:hover .itip, .islot:focus .itip { display: block; }
.listbtn { padding: 4px 9px; font-size: .78rem; }
.listbtn.on { background: linear-gradient(#f3d77a, #d9a521); border-color: #9a7412; }
.dofuslist { margin: 12px 0 4px; border: 2px solid #d9a521; border-radius: 8px; background: linear-gradient(#fffaf0, #fbefc4); padding: 6px 10px; }
.dofuslist h3 { margin: 2px 0 6px; }
.drow { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-top: 1px dashed #d9c27a; }
.drow:first-of-type { border-top: 0; }
.drow .dtxt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.drow .dtxt small { color: var(--dim); font-size: .72rem; }
.drow .dmeta { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: .7rem; color: var(--dim); }
.igrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 8px; }
.icard { background: #fffdf3; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; }
.icard.dofus { border: 2px solid #d9a521; background: linear-gradient(#fff8dc, #fbe9a8); box-shadow: 0 0 12px #d9a52155; }
.icard p { margin: 0; font-size: .74rem; color: var(--dim); flex: 1; }
.ihead { display: flex; align-items: center; gap: 8px; }
.ibuy { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.price { font-size: 1rem; }

.win h2 { font-size: 1.5rem; }
.win .art { margin: 8px auto; }
.stats { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .82rem; }
.stats td, .stats th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: center; }
.stats th { background: var(--panel2); }

.btn.danger { background: linear-gradient(#e0735a, #b8321f); color: #fff; border-color: #8d2f1c; text-shadow: 0 1px 1px #5a1a08aa; }
.btn.danger:hover:not(:disabled) { background: linear-gradient(#ea8670, #c63d28); }

/* ---- menú */
.modal.menu { z-index: 45; }
.menucard { display: flex; flex-direction: column; gap: 8px; }
.menuhead { display: flex; align-items: center; gap: 10px; }
.menuhead h2 { flex: 1; margin: 0; color: #fff; background: linear-gradient(var(--green1), var(--green2)); border: 1px solid var(--greenline); border-radius: 6px; padding: 6px 10px; text-shadow: 0 1px 2px #34470a; font-size: 1.05rem; }
.menucard h3 { margin: 4px 0 0; }
.mport { flex: 0 0 30px; line-height: 0; }
.mname { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.mname b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mname small { color: var(--dim); font-size: .7rem; }
.vol { display: grid; grid-template-columns: 70px 1fr 42px; align-items: center; gap: 8px; font-weight: 700; }
.vol input { width: 100%; accent-color: var(--accent); min-height: 28px; }
.vol output { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.menuend { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.menuend.confirm { background: #fbe3d8; border: 1px solid #c4523a; border-radius: 8px; padding: 10px; }

.drawer { position: fixed; right: 0; top: 0; bottom: 0; width: min(100%, 340px); background: var(--panel); border-left: 2px solid #8a7440; z-index: 40; display: flex; flex-direction: column; box-shadow: -8px 0 30px #0007; }
.drawer.dbg { border-color: #b23a2a; }
.dhead { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; color: #fff; background: linear-gradient(var(--green1), var(--green2)); }
.drawer.dbg .dhead { background: linear-gradient(#d0623f, #a4381c); }
.dbody { padding: 8px 10px; overflow-y: auto; flex: 1; font-size: .78rem; display: flex; flex-direction: column; gap: 6px; }
.drow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.drow input { width: 64px; } .drow select { width: auto; }
/* panel de debug por secciones */
.dsec { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; background: #fffdf3; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.dsec > b { color: #a4381c; margin-right: 2px; }
.dsec small { color: var(--dim); }
.dsec select { max-width: 160px; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 4px 6px; width: 100%; }
.dgrid label { display: flex; flex-direction: column; font-size: .7rem; color: var(--dim); }
.dgrid input { width: 100%; }
.dinl { display: inline-flex; align-items: center; gap: 3px; } .dinl input { width: 48px; }
.dorder { margin: 0; padding-left: 0; list-style: none; width: 100%; display: flex; flex-direction: column; gap: 3px; }
.dorder li { display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 4px; }
.dorder li span { flex: 1; } .dorder li.now { background: #ffe7b0; font-weight: 700; }

/* ---- dados y avisos */
#dice { position: fixed; left: 50%; top: 14%; transform: translate(-50%, -20px); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#dice.show { opacity: 1; transform: translate(-50%, 0); }
.dicecard { background: var(--panel); border: 2px solid #8a7440; border-radius: 10px; padding: 8px 18px; text-align: center; box-shadow: 0 10px 40px #000a; }
.dwho { font-weight: 800; margin-bottom: 6px; color: var(--greenline); font-size: .85rem; }
.dfaces { display: flex; gap: 8px; justify-content: center; }
.dfaces.shake .die { transform: rotate(8deg); }
.dfaces .die { transition: transform .07s; }
.dtotal { font-size: 1.25rem; font-weight: 900; margin-top: 4px; }
.dcol { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dcap { font-size: .68rem; font-weight: 800; padding: 1px 8px; border-radius: 10px; background: #fffdf3; border: 1px solid var(--line); color: var(--dim); }
.dcap.move { background: #d9f7cf; border-color: #4a9a3a; color: #1d6b34; }
.dcap.ap { background: #d3f4fa; border-color: #2a9ab5; color: #0e6a80; }
.dslot { line-height: 0; }
.dslot.crit { animation: critpulse .9s ease-out; }
.dslot.crit .die { filter: drop-shadow(0 0 10px #ffd23f) drop-shadow(0 0 22px #ffd23f) saturate(1.4) brightness(1.1); }
.dslot.sad { animation: sadsink 1.2s ease-out forwards; }
.dslot.sad .die { filter: grayscale(.85) brightness(.75) drop-shadow(0 4px 6px #1a2a55); }
@keyframes critpulse { 0% { transform: scale(1); } 30% { transform: scale(1.35) rotate(-6deg); } 60% { transform: scale(1.15) rotate(4deg); } 100% { transform: scale(1.2); } }
@keyframes sadsink { 0% { transform: translateY(0) rotate(0); } 40% { transform: translateY(10px) rotate(-14deg); } 100% { transform: translateY(16px) rotate(-20deg) scale(.92); } }
#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 30px); background: #b8321f; color: #fff; padding: 7px 16px; border-radius: 8px; opacity: 0; z-index: 90; transition: .25s; pointer-events: none; max-width: 90vw; text-align: center; white-space: pre-line; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.pop { position: absolute; left: 50%; top: 0; font-weight: 900; font-size: 1.4rem; text-shadow: 0 0 3px #fff, 0 2px 4px #000a; animation: popup 1.2s ease-out forwards; pointer-events: none; z-index: 5; }
.pop.dmg { color: #d8321f; } .pop.heal { color: #2f9a3f; } .pop.miss { color: #2a88c8; font-size: 1.1rem; white-space: nowrap; }
@keyframes popup { from { transform: translate(-50%, 0); opacity: 1; } to { transform: translate(-50%, -34px); opacity: 0; } }

/* ---- efectos de combate */
#fxlayer { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.fxo { will-change: transform, opacity; }
.hitflash { animation: hitshake .45s; }
.hitflash .art { animation: hitred .6s; }
.healflash .art { animation: healg .7s; }
@keyframes hitshake { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-5px); } 35% { transform: translateX(5px); } 55% { transform: translateX(-3px); } 75% { transform: translateX(2px); } }
@keyframes hitred { 0%, 45% { filter: sepia(1) saturate(10) hue-rotate(-40deg) brightness(1.15) drop-shadow(0 0 10px #ff2a2a); } 100% { filter: none; } }
@keyframes healg { 0%, 40% { filter: brightness(1.25) saturate(1.4) drop-shadow(0 0 12px #4fe07a); } 100% { filter: none; } }
.skill.casting { animation: skillglow .8s ease-out; }
.pcard.casting, .fighter.casting { animation: castglow .8s ease-out; }
@keyframes skillglow { 0% { box-shadow: 0 0 0 0 #ffd23f, 0 0 0 0 #ffd23faa; transform: scale(1); } 25% { box-shadow: 0 0 18px 6px #ffd23f, 0 0 40px 12px #ffb44388; transform: scale(1.06); filter: brightness(1.25); } 100% { box-shadow: 0 0 0 0 transparent; transform: scale(1); } }
@keyframes castglow { 0% { box-shadow: 0 0 0 0 transparent; } 30% { box-shadow: 0 0 22px 6px #ffd23f; } 100% { box-shadow: 0 0 0 0 transparent; } }

@media (min-width: 900px) {
  .game { grid-template-columns: 1fr 380px; grid-template-rows: auto 1fr auto; }
  .topbar { grid-column: 1 / 3; }
  .mapwrap { grid-column: 1; grid-row: 2 / 4; }
  .players { grid-column: 2; grid-row: 2; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
  .pcard { min-width: 0; }
  .actions { grid-column: 2; grid-row: 3; max-height: 55vh; border-top: 2px solid #8a7440; }
}
@media (max-width: 520px) {
  .arena { grid-template-columns: 1fr 1fr; }
  .arena .art { width: 84px; height: 84px; }
  .vs { display: none; }
  .fdesc { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---- chat (client/chat.js): botón abajo a la izquierda; panel que se abre encima; se desvanece sin uso */
.chat { position: fixed; left: 10px; bottom: 10px; z-index: 60; display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  pointer-events: none; max-width: min(380px, calc(100vw - 20px)); }
.chat.off { display: none; }
.chat > * { pointer-events: auto; }
.chatbtn { position: relative; width: 42px; height: 42px; border-radius: 50%; border: 2px solid #a48d52; cursor: pointer; font-size: 1.25rem;
  background: linear-gradient(#fbf6e6, #e3d5a8); box-shadow: 0 2px 6px #0005; transition: opacity .6s, transform .15s; }
.chatbtn:hover { transform: scale(1.06); }
.chat.idle .chatbtn { opacity: .38; }
.chat.idle .chatbtn:hover, .chat.open .chatbtn { opacity: 1; }
.chatbadge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--bad);
  color: #fff; font-size: .7rem; font-weight: 800; line-height: 18px; text-align: center; }
.chatbadge[hidden] { display: none; }
.chatbox { display: none; width: min(380px, calc(100vw - 20px)); background: rgba(43, 33, 20, .92); border: 2px solid #a48d52; border-radius: 10px;
  box-shadow: 0 8px 24px #0008; color: #f7f0da; overflow: hidden; animation: chatin .18s ease-out; }
.chat.open .chatbox { display: block; }
@keyframes chatin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.chatlist { max-height: min(240px, 40vh); overflow-y: auto; padding: 8px 10px; font-size: .85rem; line-height: 1.35; }
.chatline { word-wrap: break-word; overflow-wrap: anywhere; padding: 1px 0; }
.chatempty { color: #c9b98a; font-style: italic; }
.chatemojis { display: flex; flex-wrap: wrap; gap: 2px; padding: 4px 6px; border-top: 1px solid #5a4a2c; }
.chatemojis button { background: none; border: 0; cursor: pointer; font-size: 1.05rem; padding: 2px 3px; border-radius: 4px; line-height: 1; }
.chatemojis button:hover { background: #ffffff22; }
.chatform { display: flex; gap: 6px; padding: 6px; border-top: 1px solid #5a4a2c; }
.chatform input { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 6px; border: 1px solid #a48d52; background: #f7f0da; color: var(--text); }
.chatform .btn { padding: 5px 10px; }
.chatfeed { display: flex; flex-direction: column; gap: 4px; }
.chat.open .chatfeed { display: none; }
.chatpop { background: rgba(43, 33, 20, .85); color: #f7f0da; padding: 4px 10px; border-radius: 8px; font-size: .82rem; max-width: min(360px, calc(100vw - 20px));
  box-shadow: 0 2px 8px #0006; animation: chatin .2s ease-out; transition: opacity .7s, transform .7s; pointer-events: none; }
.chatpop.gone { opacity: 0; transform: translateY(-6px); }
/* en la partida, el chat va arriba a la izquierda (sobre el mapa) y se abre hacia abajo: no tapa los botones */
.chat.ingame { top: 46px; bottom: auto; flex-direction: column-reverse; }
.chat.ingame .chatlist { max-height: min(200px, 32vh); }
.chatsys { color: #ffe9a8; font-style: italic; }
