/* Anime Fights: negro, dorado, azul y morado; todo en píxel. */
@font-face { font-family: DotGothic16; src: url(fuentes/DotGothic16-Regular.ttf) format('truetype'); font-display: swap; }

:root {
  --tinta: #07060d; --fondo: #0d0a1c; --panel: #151030; --borde: #2a1f5c;
  --oro: #f2c14e; --oro2: #a8741a; --azul: #2f7bff; --morado: #7b3fe4; --morado2: #3a1a7a;
  --texto: #ece8ff; --flojo: #9a92c4; --rojo: #ff5a4d; --verde: #3fd07a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--tinta); color: var(--texto);
  font-family: DotGothic16, 'MS Gothic', monospace; font-size: 18px; line-height: 1.5;
  -webkit-font-smoothing: none; -webkit-tap-highlight-color: transparent;
}
body.en-combate { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
canvas, img { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ---------- intro ---------- */
#intro { position: fixed; inset: 0; z-index: 50; background: var(--tinta); display: grid; place-items: center; }
#intro canvas { width: min(100vw, calc(100vh * 384 / 224)); height: min(100vh, calc(100vw * 224 / 384)); cursor: pointer; }

/* ---------- fondo y armazón ---------- */
#app {
  min-height: 100vh; display: flex; flex-direction: column;
  background:
    radial-gradient(1px 1px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 78% 9%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 33% 31%, #cfe0ff 50%, transparent 51%), radial-gradient(1px 1px at 58% 22%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 91% 37%, #f2c14e 50%, transparent 51%), radial-gradient(1px 1px at 6% 52%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 46% 8%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 69% 44%, #cfe0ff 50%, transparent 51%),
    linear-gradient(#05030c 0%, #140a33 45%, #2a1466 80%, #4a1f8f 100%);
  background-attachment: fixed;
}
.barra {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: rgba(7, 6, 13, .82); border-bottom: 3px solid var(--oro2); position: sticky; top: 0; z-index: 5;
}
.pestanas { display: flex; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }
.pestanas button {
  background: none; border: 3px solid transparent; padding: 4px 14px; color: var(--flojo);
}
.pestanas button:hover { color: var(--texto); }
.pestanas button.activa { color: var(--oro); border-color: var(--oro2); background: var(--panel); }
.jugador { color: var(--oro); min-width: 48px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30vw; }

.icono {
  width: 48px; height: 48px; padding: 4px; background: var(--panel); border: 3px solid var(--oro2); position: relative; flex: none;
  box-shadow: 3px 3px 0 #000;
}
.icono svg { width: 100%; height: 100%; display: block; shape-rendering: crispEdges; }
.icono:hover { border-color: var(--oro); }
.icono:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.engranaje:hover svg { animation: gira 1.2s steps(8) infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.globo {
  position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 4px; background: var(--rojo); color: #fff;
  border: 2px solid var(--tinta); font-size: 16px; line-height: 18px; text-align: center;
}

main { flex: 1; width: min(980px, 100%); margin: 0 auto; padding: 24px 16px 48px; }
h2 { color: var(--oro); font-size: 32px; font-weight: normal; margin-bottom: 8px; text-shadow: 3px 3px 0 var(--morado2); }
h3 { color: var(--azul); font-size: 18px; font-weight: normal; margin-bottom: 8px; }
.nota { color: var(--flojo); font-size: 16px; margin-bottom: 16px; }

/* ---------- inicio ---------- */
.heroe { display: flex; align-items: center; justify-content: center; gap: 32px; min-height: calc(100vh - 190px); flex-wrap: wrap; }
#heroe_pjs { display: flex; align-items: flex-end; justify-content: center; }
#heroe_pjs canvas { width: 212px; height: 292px; margin: 0 -18px; filter: drop-shadow(0 0 18px rgba(47, 123, 255, .55)); }
#heroe_pjs canvas.fav { filter: drop-shadow(0 0 18px rgba(242, 193, 78, .7)); }
.heroe_txt { text-align: center; }
.logo {
  font-size: clamp(48px, 11vw, 96px); line-height: 1; font-weight: normal; color: var(--oro); letter-spacing: 2px;
  text-shadow: 4px 4px 0 var(--morado2), 8px 8px 0 #000, 0 0 28px rgba(123, 63, 228, .7);
}
.logo span { display: inline-block; }
.kana { color: #9fc0ff; font-size: 24px; letter-spacing: 6px; margin-top: 6px; }
.beta {
  display: inline-block; margin-top: 12px; padding: 0 14px; background: var(--morado); color: #fff; font-size: 20px;
  border-top: 2px solid var(--oro); border-bottom: 2px solid var(--oro);
}
.desc { margin-top: 18px; color: var(--texto); font-size: 20px; }
.acciones { margin-top: 26px; display: flex; gap: 16px; justify-content: center; align-items: center; }

.boton {
  background: var(--panel); border: 3px solid var(--borde); color: var(--texto); padding: 8px 18px; min-height: 46px;
  box-shadow: 3px 3px 0 #000;
}
.boton:hover { border-color: var(--azul); }
.boton:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.boton.oro { background: var(--oro); border-color: var(--oro2); color: var(--tinta); }
.boton.oro:hover { background: #ffd874; border-color: #fff3c4; }
.boton.grande { font-size: 32px; padding: 6px 44px; min-height: 64px; animation: late 1.6s steps(2) infinite; }
@keyframes late { 50% { box-shadow: 3px 3px 0 #000, 0 0 0 4px rgba(242, 193, 78, .35); } }
.boton.chico { min-height: 34px; padding: 2px 10px; font-size: 16px; }
.boton.peligro:hover { border-color: var(--rojo); color: var(--rojo); }
.boton:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }

/* ---------- paneles y personajes ---------- */
.panel { background: rgba(21, 16, 48, .92); border: 3px solid var(--borde); padding: 16px; box-shadow: 4px 4px 0 #000; }
.panel p + p { margin-top: 10px; }
.controles { margin-top: 24px; }
.controles ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 4px 24px; font-size: 16px; color: var(--texto); }
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.pj {
  background: rgba(21, 16, 48, .92); border: 3px solid var(--borde); padding: 12px 8px 8px; text-align: center; position: relative;
  box-shadow: 4px 4px 0 #000;
}
button.pj:hover { border-color: var(--azul); }
.pj.fav { border-color: var(--oro); }
.pj.fav::after { content: '★'; position: absolute; top: 2px; right: 8px; color: var(--oro); font-size: 24px; }
.pj canvas { width: 106px; height: 146px; display: block; margin: 0 auto 6px; }
.pj small { display: block; color: var(--flojo); font-size: 16px; }
.pj.pronto { opacity: .55; display: grid; place-items: center; min-height: 200px; color: var(--flojo); }

/* ---------- ventana encima ---------- */
#velo, .capa { position: fixed; inset: 0; z-index: 30; background: rgba(4, 3, 10, .82); display: grid; place-items: center; padding: 12px; }
.ventana {
  width: min(560px, 100%); max-height: calc(100vh - 24px); overflow: auto; position: relative;
  background: var(--fondo); border: 3px solid var(--oro2); padding: 20px; box-shadow: 6px 6px 0 #000, 0 0 0 3px var(--tinta);
}
.ventana.chica { width: min(360px, 100%); text-align: center; display: grid; gap: 12px; }
.ventana h2 { font-size: 24px; margin-bottom: 14px; padding-right: 40px; }
.ventana.chica h2 { padding: 0; margin: 0; }
.x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; background: none; border: 3px solid transparent; color: var(--flojo); font-size: 28px; line-height: 1; }
.x:hover { color: var(--oro); border-color: var(--oro2); }
.campo { display: block; margin-bottom: 12px; }
.campo span { display: block; color: var(--flojo); font-size: 16px; }
.campo input[type=text], .campo input[type=password], .busca input {
  width: 100%; background: var(--tinta); border: 3px solid var(--borde); color: var(--texto); font: inherit; padding: 6px 10px; min-height: 44px;
}
.campo input:focus, .busca input:focus { outline: none; border-color: var(--azul); }
input[type=range] { width: 100%; accent-color: var(--oro); height: 28px; }
.error { color: var(--rojo); min-height: 27px; font-size: 16px; }
.enlace { background: none; border: none; color: var(--azul); text-decoration: underline; padding: 6px 0; }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fila.fin { justify-content: flex-end; margin-top: 8px; }

.banderas { display: flex; gap: 10px; flex-wrap: wrap; }
.bandera { background: none; border: 3px solid var(--borde); padding: 4px; width: 62px; text-align: center; color: var(--flojo); font-size: 16px; line-height: 1.2; }
.bandera svg { width: 48px; height: 32px; display: block; margin: 0 auto 2px; shape-rendering: crispEdges; }
.bandera.activa { border-color: var(--oro); color: var(--oro); background: var(--panel); }

.modos { display: grid; gap: 12px; }
.modo { text-align: left; background: var(--panel); border: 3px solid var(--borde); padding: 12px 14px; box-shadow: 3px 3px 0 #000; }
.modo b { display: block; color: var(--oro); font-weight: normal; font-size: 22px; }
.modo span { color: var(--flojo); font-size: 16px; }
.modo:hover:not(:disabled) { border-color: var(--azul); }
.modo:disabled { opacity: .55; cursor: default; }
.modo:disabled b { color: var(--flojo); }

.subpest { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.subpest button { background: none; border: 3px solid var(--borde); color: var(--flojo); padding: 2px 10px; font-size: 16px; position: relative; }
.subpest button.activa { color: var(--oro); border-color: var(--oro2); background: var(--panel); }
.subpest .globo { position: static; display: inline-block; margin-left: 6px; }
.lista { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 3px solid var(--borde); padding: 6px 10px; }
.item .nombre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .estado { font-size: 16px; color: var(--flojo); }
.item .estado.on { color: var(--verde); }
.busca { display: flex; gap: 8px; margin-bottom: 12px; }
.vacio { color: var(--flojo); padding: 12px 0; }

#aviso {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 40; width: min(460px, calc(100% - 24px));
  background: var(--fondo); border: 3px solid var(--oro); padding: 12px 14px; box-shadow: 6px 6px 0 #000;
}
#aviso p { margin-bottom: 8px; }

/* ---------- combate ---------- */
#combate { position: fixed; inset: 0; z-index: 100; background: #000; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
#lienzo { width: min(100vw, calc(100vh * 16 / 9)); height: min(100vh, calc(100vw * 9 / 16)); display: block; cursor: crosshair; }
#combate .capa { position: absolute; z-index: 3; }
#cmenu {
  position: absolute; top: 6px; left: 50%; transform: translateX(-50%); z-index: 2; width: 40px; height: 32px; display: none;
  background: rgba(7, 6, 13, .7); border: 2px solid var(--oro2); color: var(--oro); font-size: 20px; line-height: 1;
}
#tactil { display: none; }
#combate.tactil #cmenu { display: block; }
#combate.tactil #tactil { display: block; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
#tactil button {
  pointer-events: auto; position: absolute; width: 58px; height: 58px; background: rgba(21, 16, 48, .55); border: 3px solid rgba(242, 193, 78, .6);
  color: #fff; font-size: 24px; line-height: 1; padding: 0; touch-action: none;
}
#tactil button small { display: block; font-size: 12px; color: var(--oro); }
#tactil button.on { background: rgba(242, 193, 78, .5); }
.cruz { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: 14px; width: 186px; height: 126px; }
.cruz .t_arriba { left: 64px; top: 0; } .cruz .t_izq { left: 0; top: 64px; } .cruz .t_abajo { left: 64px; top: 64px; } .cruz .t_der { left: 128px; top: 64px; }
.ataques { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: 14px; width: 250px; height: 190px; }
.ataques .a_golpe { right: 0; bottom: 0; width: 76px; height: 76px; font-size: 32px; border-color: #fff; }
.ataques .a_tp { right: 84px; bottom: 0; border-color: #9fc0ff; }
.ataques .a_rojo { right: 148px; bottom: 0; border-color: #ff3b3b; color: #ff9a8a; }
.ataques .a_azul { right: 84px; bottom: 64px; border-color: #2f7bff; color: #9fc0ff; }
.ataques .a_mor { right: 148px; bottom: 64px; border-color: #9b4dff; color: #d9b8ff; }
.ataques .a_inf { right: 0; bottom: 84px; }
.ataques .a_dom { right: 0; bottom: 148px; width: 76px; height: 42px; font-size: 16px; border-color: #9b4dff; }
#tactil .a_dom small { display: inline; margin-left: 4px; }
#gira { background: #000; text-align: center; align-content: center; gap: 16px; color: var(--oro); font-size: 22px; }
.gira_icono { width: 60px; height: 100px; border: 4px solid var(--oro); margin: 0 auto; animation: girar 1.6s steps(6) infinite alternate; }
@keyframes girar { to { transform: rotate(90deg); } }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .barra { gap: 8px; padding: 8px; }
  .pestanas button { padding: 2px 8px; }
  .jugador { display: none; }
  #heroe_pjs canvas { width: 159px; height: 219px; margin: 0 -16px; }
  .heroe { gap: 12px; }
  .boton.grande { font-size: 24px; padding: 6px 30px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }

/* perfil: foto y biografía */
.avatar { width: 40px; height: 40px; flex: 0 0 40px; border: 2px solid var(--oro); background: #120a33; image-rendering: auto; object-fit: cover; display: grid; place-items: center; color: var(--oro); font-size: 20px; }
.avatar.grande { width: 96px; height: 96px; flex-basis: 96px; font-size: 44px; }
.perfil_cab { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 14px; flex-wrap: wrap; }
.perfil_cab .lado { flex: 1 1 220px; min-width: 0; }
.perfil_cab textarea { width: 100%; min-height: 76px; resize: vertical; font: inherit; color: inherit; background: #0d0920; border: 2px solid #2a1466; padding: 8px; }
.perfil_cab textarea:focus { outline: none; border-color: var(--azul); }
.item .quien { flex: 1 1 auto; min-width: 0; }
.item .quien .bio { display: block; color: var(--flojo); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controles h4 { margin: 14px 0 4px; color: var(--oro); font-weight: normal; }
.lista { min-width: 0; }
.item { min-width: 0; flex-wrap: wrap; }
.item .quien { flex: 1 1 130px; }
.item .quien .nombre { display: block; }
.item .boton, .item .estado { flex: 0 0 auto; }
