/* Selección de luchador en pantallas táctiles (móvil y tableta; html.is-touch lo pone device.js). menus.js (buildSelTouch,
   selLayoutTouch, renderSelCta) añade las pestañas de categoría, el botón CONFIRMAR y el retrato del panel, y reparte la
   rejilla en columnas de al menos --tile-min px. En PC nada de esto se ve.
   Horizontal: rejilla desplazable a la izquierda (pestañas encima) y, a la derecha, el panel del luchador señalado con el
   botón CONFIRMAR abajo, bajo el pulgar derecho. Vertical: panel arriba, rejilla en medio y CONFIRMAR abajo a lo ancho.
   Tocar un retrato lo señala; tocarlo otra vez (o CONFIRMAR) lo elige. */

/* lo que solo existe en táctil: fuera en PC */
.sel-tabs, .sel-cta, .sel-info .sel-pf { display: none; }

html.is-touch #chars:not(.hidden) {
  --panel-w: min(38vw, 330px); --tile-min: 74;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "head band" "dock band" "dock cta";
  gap: 6px 12px; align-content: stretch; justify-content: stretch; align-items: stretch; justify-items: stretch; overflow: hidden;
  height: var(--app-h, 100vh);
  padding: calc(var(--sat, 0px) + 8px) calc(var(--sar, 0px) + 10px) calc(var(--sab, 0px) + 8px) calc(var(--sal, 0px) + 10px);
}
html.is-touch #chars .sel-art, html.is-touch #chars .sel-player, html.is-touch #chars .sel-dock .blink, html.is-touch #chars .sel-head .sub { display: none; }
html.is-touch #chars .sel-vig { background: linear-gradient(180deg, rgba(2,4,12,.55), rgba(2,4,12,.35) 40%, rgba(2,4,12,.75)); }
html.is-touch #chars .sel-bg img { opacity: .32; }

/* ---- cabecera: VOLVER compacto y el título a su lado */
html.is-touch #chars > .back-btn { top: calc(var(--sat, 0px) + 8px); left: calc(var(--sal, 0px) + 10px); min-height: 40px; padding: 0 12px; font-size: 8px; }
html.is-touch #chars .sel-head { grid-area: head; position: relative; top: auto; left: auto; right: auto; min-height: 40px; padding-left: 112px;
  flex-direction: row; align-items: center; justify-content: flex-start; }
html.is-touch #chars .sel-head h2 { font-size: 11px; line-height: 1.5; letter-spacing: .1em; white-space: normal; text-align: left; }

/* ---- pestañas y rejilla */
html.is-touch #chars .sel-dock { grid-area: dock; display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-height: 0; padding: 0; width: auto; position: relative; z-index: 4; }
.is-touch .sel-tabs { display: flex; flex: none; gap: 6px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 2px 2px 4px;
  -webkit-overflow-scrolling: touch; touch-action: pan-x; scroll-snap-type: x proximity; }
.is-touch .sel-tabs::-webkit-scrollbar { display: none; }
.is-touch .sel-tabs button { --cc: #9fb3e6; flex: none; scroll-snap-align: start; font: inherit; font-size: 8px; letter-spacing: 1px; min-height: 38px; padding: 0 12px;
  color: #dfe7ff; background: rgba(8,12,30,.85); border: 0; box-shadow: 0 0 0 2px #000, inset 0 -3px 0 var(--cc); cursor: pointer; white-space: nowrap; text-shadow: 1px 1px 0 #000; }
.is-touch .sel-tabs button.on { color: #111; background: var(--cc); text-shadow: none; box-shadow: 0 0 0 2px #000, 0 3px 0 #000; }
.is-touch .sel-tabs button:focus-visible { outline: 2px dashed #fff; outline-offset: 2px; }

html.is-touch #char-cards.touch { flex: 1 1 auto; min-height: 0; max-height: none; width: 100%; display: block; overflow-y: auto; overflow-x: hidden;
  padding: 8px 10px 14px; box-sizing: border-box; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
html.is-touch #char-cards.touch .cat { margin-bottom: 10px; }
html.is-touch #char-cards.touch .cat[hidden] { display: none; }
html.is-touch #char-cards.touch .cat-label { position: sticky; top: -8px; z-index: 7; height: 22px; line-height: 22px; font-size: 8px; margin: 0 -2px 2px;
  background: rgba(10,14,34,.96); }
html.is-touch #char-cards.touch .cat-grid { grid-template-columns: repeat(var(--n, 4), var(--tile)); gap: 6px; padding: 4px 0; }
html.is-touch #char-cards.touch.only-mine .card.is-locked { display: none; }
/* el señalado no crece (se saldría de la rejilla con scroll): marco grueso y brillo */
html.is-touch #char-cards.touch .card.active { transform: none; box-shadow: 0 0 0 1px #000, inset 0 -3px 0 var(--cc), 0 0 14px var(--cur, #ffd84a); }
html.is-touch #char-cards.touch .card:active { transform: scale(.96); }
html.is-touch #char-cards.touch .card.cur1, html.is-touch #char-cards.touch .card.cur2 { outline-width: 3px; outline-offset: -1px; }
html.is-touch #char-cards.touch .card .tg { font-size: 7px; }
html.is-touch #char-cards.touch .card .crown { top: -4px; right: -2px; }

/* ---- panel del luchador señalado */
html.is-touch #chars .sel-band { grid-area: band; position: relative; z-index: 4; flex-direction: column; justify-content: flex-start; align-items: stretch;
  gap: 8px; margin: 0; padding: 0; min-height: 0; overflow: hidden; pointer-events: auto; }
html.is-touch #chars .sel-info { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); grid-auto-rows: auto; align-content: start; align-items: center;
  gap: 4px 10px; width: 100%; max-width: none; box-sizing: border-box; padding: 10px; text-align: left;
  background: linear-gradient(180deg, rgba(14,20,46,.92), rgba(6,9,22,.92)); box-shadow: 0 0 0 2px #000, inset 0 0 0 2px color-mix(in srgb, var(--c) 55%, #2d3b66), 0 4px 0 rgba(0,0,0,.4); }
html.is-touch #chars .sel-info:not(.on) { display: none; }
html.is-touch #chars .sel-info.p2 { align-items: center; text-align: left; }
html.is-touch #chars .sel-info .sel-pf { display: block; grid-column: 1; grid-row: 1 / span 4; align-self: start; position: relative; width: 100%; aspect-ratio: 3 / 2;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c, #5fd0ff) 30%, #1d2a5a), #0b1026); box-shadow: 0 0 0 2px #000, inset 0 -3px 0 var(--c, #fff); overflow: hidden; }
.is-touch .sel-pf img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: pixelated; }
.is-touch .sel-pf b { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; font-weight: normal; font-size: 26px; color: #ffd84a; text-shadow: 3px 3px 0 #000; }
.is-touch .sel-pf.q img { display: none; }
.is-touch .sel-pf.q b { display: flex; }
.is-touch .sel-pf.dark img { filter: brightness(0) drop-shadow(0 0 2px var(--c)); opacity: .8; }
html.is-touch #chars .sel-info > .chip { grid-column: 2; align-self: end; justify-self: start; display: inline-block; font-size: 7px; padding: .5em .8em; }
html.is-touch #chars .sel-info > .bigname { grid-column: 2; width: auto; font-size: calc(15px * var(--k, 1)); line-height: 1.25; transform: skewX(-8deg); transform-origin: left bottom;
  white-space: nowrap; overflow: hidden; text-overflow: clip; text-shadow: .08em .08em 0 var(--c), .16em .16em 0 #000; }
html.is-touch #chars .sel-info > .ttl { grid-column: 2; display: block; font-size: 7px; letter-spacing: 1px; transform: none; }
html.is-touch #chars .sel-info > .meta { grid-column: 2; width: auto; display: flex; flex-wrap: wrap; gap: 4px; font-size: 7px; letter-spacing: 1px; justify-content: flex-start; }
html.is-touch #chars .sel-info .skin-pick { grid-column: 1 / -1; justify-self: stretch; justify-content: space-between; font-size: 8px; padding: 0 4px; opacity: 1; }
html.is-touch #chars .skin-pick .sk-lab, html.is-touch #chars .skin-pick .sk-n { display: inline; }
html.is-touch #chars .skin-pick .sk-arr { min-width: 44px; min-height: 40px; justify-content: center; font-size: 10px; }
html.is-touch #chars .sel-info .sel-lockbar { grid-column: 1 / -1; max-width: none; font-size: 7px; line-height: 1.7; padding: 6px 8px; gap: 6px 8px; flex-wrap: wrap; justify-content: flex-start; text-align: left; }
html.is-touch #chars .sel-lockbar .tx { display: block; flex: 1 1 100%; }
html.is-touch #chars .sel-lockbar .buy { min-height: 40px; }
html.is-touch #chars .sel-lockbar .k { display: none; }

/* eligiendo J2: J1 queda como resumen compacto (tocarlo vuelve a J1) y el panel grande es el del rival */
html.is-touch #chars .sel-info.p1.ready { grid-template-columns: 54px minmax(0, 1fr) auto; padding: 6px 8px; gap: 2px 8px; cursor: pointer;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px var(--p1); }
html.is-touch #chars .sel-info.p1.ready .sel-pf { grid-row: 1 / span 2; }
html.is-touch #chars .sel-info.p1.ready > .chip { grid-column: 2; }
html.is-touch #chars .sel-info.p1.ready > .bigname { grid-column: 2; font-size: calc(10px * var(--k, 1)); opacity: 1; }
html.is-touch #chars .sel-info.p1.ready > .ttl, html.is-touch #chars .sel-info.p1.ready > .meta,
html.is-touch #chars .sel-info.p1.ready .skin-pick, html.is-touch #chars .sel-info.p1.ready .sel-lockbar { display: none; }
html.is-touch #chars .sel-info.p1.ready::after { content: "✎"; grid-column: 3; grid-row: 1 / span 2; font-size: 14px; color: var(--p1); padding: 0 4px; font-family: Arial, sans-serif; }
html.is-touch #chars .sel-info.p2 > .chip { background: var(--p2) !important; }

/* ---- botón CONFIRMAR */
.is-touch .sel-cta { grid-area: cta; display: flex; position: relative; z-index: 6; }
.is-touch .sel-go { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; min-height: 58px; padding: 8px 10px;
  font: inherit; font-size: 14px; letter-spacing: 2px; color: #1a1200; background: #ffd84a; border: 0; cursor: pointer;
  box-shadow: 0 0 0 3px #000, 0 5px 0 3px #8a6a00, 0 5px 0 6px #000; transform: translateY(-3px); }
.is-touch .sel-go small { font-size: 7px; letter-spacing: 1px; color: #3a2a00; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-touch .sel-go:active { transform: translateY(1px); box-shadow: 0 0 0 3px #000, 0 1px 0 3px #8a6a00, 0 1px 0 6px #000; }
.is-touch .sel-go:focus-visible { outline: 2px dashed #fff; outline-offset: 6px; }
.is-touch .sel-cta.p2 .sel-go { background: var(--p2, #5fd0ff); color: #00202c; box-shadow: 0 0 0 3px #000, 0 5px 0 3px #1f6f8f, 0 5px 0 6px #000; }
.is-touch .sel-cta.p2 .sel-go small { color: #00303f; }
.is-touch .sel-cta.locked .sel-go { background: #f4ecd8; color: #1a1a1a; box-shadow: 0 0 0 3px #000, 0 5px 0 3px #8d99ad, 0 5px 0 6px #000; }
.is-touch .sel-go.pulse { animation: sel-go-pulse .35s steps(3); }
@keyframes sel-go-pulse { 50% { filter: brightness(1.35); transform: translateY(-3px) scale(1.04); } }

/* horizontal muy bajo (iPhone SE y similares): más compacto */
@media (orientation: landscape) and (max-height: 360px) {
  html.is-touch #chars:not(.hidden) { --tile-min: 66; gap: 4px 10px; }
  html.is-touch #chars .sel-info .sel-pf { grid-row: 1 / span 3; }
  html.is-touch #chars .sel-info > .ttl { display: none; }
  .is-touch .sel-go { min-height: 50px; font-size: 12px; }
  .is-touch .sel-tabs button { min-height: 34px; }
}

/* ---- vertical: panel arriba, rejilla, CONFIRMAR abajo a lo ancho */
@media (orientation: portrait) {
  html.is-touch #chars:not(.hidden) { --tile-min: 64; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "head" "band" "dock" "cta"; gap: 8px; }
  html.is-touch #chars .sel-band { overflow: visible; }
  html.is-touch #chars .sel-info { grid-template-columns: minmax(0, 36%) minmax(0, 1fr); }
  html.is-touch #chars .sel-info > .bigname { font-size: calc(18px * var(--k, 1)); }
  .is-touch .sel-go { min-height: 62px; font-size: 15px; }
}
/* tableta (más sitio): retratos y textos algo mayores */
@media (min-width: 900px) and (min-height: 600px) {
  html.is-touch #chars:not(.hidden) { --tile-min: 96; --panel-w: min(34vw, 420px); }
  html.is-touch #chars .sel-head h2 { font-size: 15px; }
  html.is-touch #chars .sel-info > .bigname { font-size: calc(24px * var(--k, 1)); }
  html.is-touch #chars .sel-info > .meta, html.is-touch #chars .sel-info > .ttl, html.is-touch #chars .sel-info > .chip { font-size: 9px; }
  .is-touch .sel-tabs button { font-size: 10px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .is-touch .sel-go.pulse { animation: none; } }
