/* ==========================================================
   Cabezones Fútbol — estilos de menús, HUD y controles
   ========================================================== */
/* Fuentes guardadas en el proyecto (antes venían de Google Fonts: un viaje extra al arrancar) */
@font-face { font-family: 'Bebas Neue'; font-weight: 400; font-display: swap; src: url(../assets/fonts/bebas-neue-latin.woff2) format('woff2'); }
@font-face { font-family: 'Rubik'; font-weight: 300 900; font-display: swap; src: url(../assets/fonts/rubik-latin.woff2) format('woff2'); }

:root {
  --bg: #070a1c;
  --panel: rgba(12, 16, 40, 0.82);
  --panel-border: rgba(140, 170, 255, 0.22);
  --accent: #ffd23f;
  --accent2: #3ad1ff;
  --hot: #ff4d6d;
  --text: #f4f6ff;
  --muted: #9aa6d6;
  --display: 'Bebas Neue', Impact, 'Arial Black', sans-serif;
  --body: 'Rubik', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --u: min(1vw, 1.6vh); /* unidad que escala con pantallas 16:9 */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; height: var(--app-h, 100%); overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--body); }
body { touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; height: var(--app-h, 100dvh); display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle 75vmax at 50% 50%, rgba(0,0,0,0) 45vmin, rgba(0,0,0,0.45) 75vmax); }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Botones ---------- */
.btn {
  font-family: var(--display); font-size: calc(var(--u) * 2.6); letter-spacing: 0.06em;
  color: var(--text); background: linear-gradient(180deg, #2a3570, #1a2150);
  border: 2px solid var(--panel-border); border-radius: 12px; padding: 0.35em 1.2em 0.25em;
  box-shadow: 0 6px 0 #0b0f2a, 0 10px 24px rgba(0,0,0,0.4);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}
.btn:hover { filter: brightness(1.18); transform: translateY(-2px); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0b0f2a; }
.btn-glow { color: #1b1300; background: linear-gradient(180deg, #ffe680, #ffb81f); border-color: #fff2b0; box-shadow: 0 6px 0 #a86a00, 0 0 30px rgba(255,210,63,0.45); }
.btn-glow:active { box-shadow: 0 2px 0 #a86a00; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-big { font-size: calc(var(--u) * 4.6); padding: 0.25em 2.2em 0.15em; }
.btn-wide { width: 100%; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--panel-border); background: rgba(10,14,34,0.7); color: #fff; font-size: 20px; display: grid; place-items: center; backdrop-filter: blur(6px); transition: transform .12s; }
.icon-btn:hover { transform: scale(1.08); }
.icon-btn.small { width: 32px; height: 32px; font-size: 15px; display: inline-grid; vertical-align: middle; }
#btn-mute { position: fixed; right: 14px; bottom: auto; top: calc(var(--app-h, 100dvh) - 58px); z-index: 40; }
body.in-match #btn-mute { top: 12px; bottom: auto; right: 12px; }
/* En paneles grandes el botón de sonido tapaba la esquina */
body:has(#scr-tricks.active) #btn-mute, body:has(#scr-share.active) #btn-mute, body:has(#scr-pause.active) #btn-mute { display: none; }

/* ---------- Pantallas ---------- */
#screens { position: fixed; inset: 0; bottom: auto; height: var(--app-h, 100dvh); z-index: 20; pointer-events: none; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: calc(var(--u) * 1.6); padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  opacity: 0; visibility: hidden; transform: scale(1.04); transition: opacity 0.35s ease, transform 0.35s ease, visibility 0s linear 0.35s;
  background: radial-gradient(ellipse at center, rgba(7,10,28,0.55), rgba(7,10,28,0.88));
}
.screen.active { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition: opacity 0.35s ease, transform 0.35s cubic-bezier(.2,1.3,.4,1), visibility 0s; }
.screen.active > * { animation: rise 0.5s cubic-bezier(.2,1.2,.4,1) both; }
.screen.active > *:nth-child(2) { animation-delay: 0.06s; }
.screen.active > *:nth-child(3) { animation-delay: 0.12s; }
.screen.active > *:nth-child(4) { animation-delay: 0.18s; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.screen-dim { background: rgba(4,6,18,0.72); backdrop-filter: blur(3px); }
.screen-title { font-family: var(--display); font-weight: 400; font-size: calc(var(--u) * 5.2); letter-spacing: 0.05em; margin: 0; text-shadow: 0 4px 0 rgba(0,0,0,0.5), 0 0 30px rgba(58,209,255,0.35); }
.panel { background: var(--panel); border: 2px solid var(--panel-border); border-radius: 20px; padding: calc(var(--u) * 2.6); display: flex; flex-direction: column; gap: calc(var(--u) * 1.4); align-items: center; box-shadow: 0 20px 60px rgba(0,0,0,0.5); min-width: min(90vw, 360px); }

/* ---------- Título ---------- */
#scr-title { background: radial-gradient(ellipse at center, rgba(7,10,28,0.2), rgba(7,10,28,0.75)); }
.title-wrap { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 3); }
.logo { display: flex; align-items: center; gap: calc(var(--u) * 2); animation: logoIn 0.9s cubic-bezier(.2,1.4,.4,1) both; }
.logo h1 { margin: 0; display: flex; flex-direction: column; line-height: 0.85; font-weight: 400; }
.logo .l1 { font-family: var(--display); font-size: calc(var(--u) * 13); letter-spacing: 0.02em;
  background: linear-gradient(180deg, #fff 20%, #ffe14d 60%, #ff9f1c); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #7a2d00) drop-shadow(0 0 30px rgba(255,180,40,0.5)); }
.logo .l2 { font-family: var(--display); font-size: calc(var(--u) * 4); letter-spacing: 0.35em; color: var(--accent2); text-shadow: 0 0 18px rgba(58,209,255,0.7); padding-left: 0.2em; }
.logo-ball { font-size: calc(var(--u) * 13); display: inline-block; line-height: 0; filter: drop-shadow(0 10px 10px rgba(0,0,0,0.45)); }
/* Logo de la app (imagen) */
.logo-img { width: calc(var(--u) * 15); height: calc(var(--u) * 15); border-radius: 22%; filter: drop-shadow(0 10px 10px rgba(0,0,0,0.45)); }
@keyframes logoIn { from { opacity: 0; transform: scale(0.4) rotate(-6deg); } to { opacity: 1; transform: none; } }
.hint { color: var(--muted); font-size: calc(var(--u) * 1.6); margin: 0; }
.blink { animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.btn-glow.btn-big { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 6px 0 #a86a00, 0 0 60px rgba(255,210,63,0.8); } }

/* ---------- Modo ---------- */
.mode-cards { display: flex; gap: calc(var(--u) * 2.2); flex-wrap: wrap; justify-content: center; }
.mode-card {
  width: calc(var(--u) * 22); min-width: 150px; padding: calc(var(--u) * 1.6) calc(var(--u) * 1.4); border-radius: 20px; color: var(--text);
  background: linear-gradient(160deg, rgba(40,52,120,0.9), rgba(14,18,46,0.95)); border: 2px solid var(--panel-border);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.8); transition: transform .18s, border-color .18s, box-shadow .18s;
}
/* Cada modo con su color (--mc): tinte arriba, círculo central de cancha detrás del ícono y franja inferior. */
.mode-card { --mc: var(--accent); position: relative; overflow: hidden; isolation: isolate;
  background: radial-gradient(circle at 50% 30%, transparent calc(var(--u) * 5.2), color-mix(in srgb, var(--mc) 35%, transparent) calc(var(--u) * 5.2 + 1px), transparent calc(var(--u) * 5.2 + 3px)),
    linear-gradient(90deg, transparent calc(50% - 1px), color-mix(in srgb, var(--mc) 22%, transparent) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(170deg, color-mix(in srgb, var(--mc) 38%, #1c2560) 0%, rgba(14,18,46,0.96) 62%);
  border-color: color-mix(in srgb, var(--mc) 40%, transparent); }
.mode-card::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--mc); box-shadow: 0 0 16px var(--mc); z-index: -1; }
.mode-card[data-mode="cpu"] { --mc: #ff4d6d; } .mode-card[data-mode="local"] { --mc: #ffd23f; }
.mode-card[data-mode="online"] { --mc: #3ad1ff; } .mode-card[data-mode="cup"] { --mc: #ff9f1c; } .mode-card[data-mode="training"] { --mc: #7dff8f; }
.mode-card .mc-title { text-shadow: 0 3px 0 color-mix(in srgb, var(--mc) 55%, #000); }
.mode-card:hover, .mode-card:focus-visible { transform: translateY(-8px) scale(1.03); border-color: var(--mc); box-shadow: 0 16px 40px rgba(0,0,0,0.5), 0 0 30px color-mix(in srgb, var(--mc) 45%, transparent); outline: none; }
.mc-icon { font-size: calc(var(--u) * 6.5); filter: drop-shadow(0 6px 8px rgba(0,0,0,0.5)); }
.mc-title { font-family: var(--display); font-size: calc(var(--u) * 3.4); letter-spacing: 0.05em; }
.mc-desc { color: var(--muted); font-size: calc(var(--u) * 1.5); text-align: center; }
.controls-help { color: var(--muted); font-size: calc(var(--u) * 1.5); text-align: center; line-height: 1.6; max-width: min(100%, 1100px); margin: 0 auto; padding: calc(var(--u) * 1.2) calc(var(--u) * 2); background: rgba(5,8,24,0.72); border: 1px solid var(--panel-border); border-radius: 16px; }
.controls-help > div + div { margin-top: 4px; }
.controls-help b { color: var(--accent); }
.controls-help kbd { display: inline-block; min-width: 1.7em; padding: 0 0.4em; margin: 0 2px; border-radius: 6px; font: inherit; font-weight: 700; line-height: 1.5; color: var(--text); background: linear-gradient(#2a3470, #161c44); border: 1px solid rgba(255,255,255,0.25); box-shadow: 0 2px 0 rgba(0,0,0,0.6); text-align: center; }
#scr-mode { background: radial-gradient(ellipse at center, rgba(7,10,28,0.72), rgba(7,10,28,0.94)); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.howto summary { cursor: pointer; color: var(--accent); font-weight: 600; list-style: none; margin-top: 6px; }
.howto summary::-webkit-details-marker { display: none; }
.howto summary::before { content: '▸ '; }
.howto[open] summary::before { content: '▾ '; }
.howto > div { margin-top: 4px; }

/* ---------- Selección de personaje ---------- */
.select-layout { display: grid; grid-template-columns: 1fr auto 1fr; gap: calc(var(--u) * 2); align-items: center; width: min(100%, 1400px); }
.char-grid { display: grid; grid-template-columns: repeat(6, calc(var(--u) * 9.4)); gap: calc(var(--u) * 1); }
.char {
  position: relative; aspect-ratio: 1; border-radius: 16px; border: 2px solid var(--panel-border); padding: 6%;
  background: linear-gradient(160deg, rgba(40,52,120,0.85), rgba(14,18,46,0.95)); display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .12s, border-color .12s; color: var(--text);
}
.char img { width: 78%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 4px 4px rgba(0,0,0,.4)); transition: transform .2s; }
.char .char-name { font-family: var(--display); font-size: calc(var(--u) * 1.5); letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.char:hover img { transform: scale(1.1) rotate(-4deg); }
.char.cur0 { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(58,209,255,0.4), 0 0 22px rgba(58,209,255,0.4); }
.char.cur1 { border-color: var(--hot); box-shadow: 0 0 0 3px rgba(255,77,109,0.4), 0 0 22px rgba(255,77,109,0.4); }
.char.cur0.cur1 { border-color: #fff; box-shadow: -4px 0 0 0 var(--accent2), 4px 0 0 0 var(--hot); }
.char .tag { position: absolute; top: 4px; font-family: var(--display); font-size: calc(var(--u) * 1.4); padding: 0 6px; border-radius: 6px; }
.char .tag0 { left: 4px; background: var(--accent2); color: #001a22; }
.char .tag1 { right: 4px; background: var(--hot); color: #fff; }
.pick-panel {
  background: var(--panel); border: 2px solid var(--panel-border); border-radius: 20px; padding: calc(var(--u) * 1.6);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.6); min-height: calc(var(--u) * 34); transition: border-color .2s, box-shadow .2s;
}
.pick-panel.p0 { border-color: rgba(58,209,255,0.5); }
.pick-panel.p1 { border-color: rgba(255,77,109,0.5); }
.pick-panel.empty { align-self: stretch; justify-content: center; border-style: dashed; }
.pick-unknown { display: grid; place-items: center; width: calc(var(--u) * 13); aspect-ratio: 1; border-radius: 50%; background: rgba(255,255,255,0.06); font: calc(var(--u) * 7) var(--display); color: var(--muted); }
.pick-panel.confirmed { box-shadow: 0 0 0 3px var(--accent), 0 0 36px rgba(255,210,63,0.45); }
.pick-who { font-family: var(--display); font-size: calc(var(--u) * 2); letter-spacing: 0.1em; color: var(--muted); }
.pick-head { width: calc(var(--u) * 13); aspect-ratio: 1; animation: headIn 0.4s cubic-bezier(.2,1.5,.4,1); }
@keyframes headIn { from { transform: scale(0.5) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.pick-name { font-family: var(--display); font-size: calc(var(--u) * 3.4); letter-spacing: 0.03em; line-height: 1; text-align: center; }
.pick-super { font-size: calc(var(--u) * 1.5); color: var(--muted); }
.pick-super b { color: var(--text); }
.stats { width: 100%; display: flex; flex-direction: column; gap: calc(var(--u) * 0.5); }
.stat { display: grid; grid-template-columns: calc(var(--u) * 9) 1fr; align-items: center; font-size: calc(var(--u) * 1.3); color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.bar i { height: calc(var(--u) * 1.1); min-height: 6px; border-radius: 3px; background: rgba(255,255,255,0.1); }
.bar i.on { background: linear-gradient(90deg, var(--accent2), #7dff8f); box-shadow: 0 0 8px rgba(58,209,255,0.5); animation: barIn .3s both; }
.bar i.on:nth-child(2) { animation-delay: .04s } .bar i.on:nth-child(3) { animation-delay: .08s } .bar i.on:nth-child(4) { animation-delay: .12s } .bar i.on:nth-child(5) { animation-delay: .16s }
@keyframes barIn { from { transform: scaleX(0); } }
.pick-state { font-family: var(--display); font-size: calc(var(--u) * 2); color: var(--accent); min-height: 1.2em; letter-spacing: 0.06em; }
.select-bottom { display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 1.2); }
.select-opts { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--u) * 1.2) calc(var(--u) * 3); }
.select-actions { display: flex; gap: calc(var(--u) * 1.4); flex-wrap: wrap; justify-content: center; }
/* Opciones y CONFIRMAR en filas que se reparten solas (una fila menos que antes).
   Si igual no alcanza la pantalla, CONFIRMAR queda pegado abajo, siempre a la vista. */
#scr-select .select-bottom { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: calc(var(--u) * 1.2) calc(var(--u) * 3); max-width: min(100%, 1300px); }
#scr-select .select-opts { display: contents; }
#scr-select .select-actions { position: sticky; bottom: max(6px, env(safe-area-inset-bottom)); z-index: 3; }
#scr-select #btn-confirm { box-shadow: 0 6px 18px rgba(0,0,0,0.55), 0 0 0 3px rgba(7,10,28,0.6); }
/* VS CPU: Tu jugador → Rival → Partido */
.select-steps { display: flex; align-items: center; gap: 1.3em; margin: 0; padding: 0; list-style: none; font-family: var(--display); font-size: max(13px, calc(var(--u) * 1.7)); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.select-steps.hidden { display: none; }
.select-steps li { position: relative; padding: 0.2em 0.75em 0.1em; border-radius: 999px; border: 2px solid transparent; }
.select-steps li + li::before { content: '→'; position: absolute; right: calc(100% + 0.3em); color: rgba(255,255,255,0.45); }
.select-steps li.done { color: #7dff8f; }
.select-steps li.done::after { content: ' ✓'; }
/* Paso actual: además del color, flecha y subrayado (se distingue sin ver colores) */
.select-steps li.on { color: #1b1300; background: var(--accent); border-color: #fff2b0; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
.select-steps li.on::after { content: ' ◂'; text-decoration: none; display: inline-block; }
/* Arriba, a la altura de ← MODOS: no suma alto a la pantalla */
#scr-select .select-steps { position: absolute; top: max(14px, calc(env(safe-area-inset-top) + 4px)); left: 0; right: 0; width: max-content; margin: 0 auto; z-index: 2; }
/* ELEGIR RIVAL / EMPEZAR PARTIDO: no más ancho que CONFIRMAR, para no empujar ni tapar más las opciones */
#scr-select #btn-confirm.cpu-cta { font-size: calc(var(--u) * 2.4); letter-spacing: 0; padding-left: 0.6em; padding-right: 0.6em; }
.difficulty { display: flex; gap: 8px; align-items: center; font-family: var(--display); font-size: calc(var(--u) * 2); letter-spacing: 0.08em; color: var(--muted); }
.difficulty button { font-family: var(--display); font-size: calc(var(--u) * 2); letter-spacing: 0.06em; padding: 0.15em 0.9em 0.05em; border-radius: 999px; border: 2px solid var(--panel-border); background: rgba(20,26,60,0.8); color: var(--muted); }
.difficulty button.on { background: var(--accent); color: #1b1300; border-color: #fff2b0; }
/* Canchas: cada una con su color (borde y, si está elegida, fondo) */
#field-mode button { --fc: #7dff8f; border-color: color-mix(in srgb, var(--fc) 45%, transparent); }
#field-mode [data-field="viento"] { --fc: #cfe8ff; } #field-mode [data-field="hielo"] { --fc: #5cd0ff; }
#field-mode [data-field="barro"] { --fc: #c08a52; } #field-mode [data-field="azar"] { --fc: #c9a0ff; }
#field-mode button.on { background: linear-gradient(180deg, color-mix(in srgb, var(--fc) 85%, #fff), var(--fc)); color: #10142e; border-color: #fff; box-shadow: 0 0 14px color-mix(in srgb, var(--fc) 60%, transparent); }
#field-mode button.on .gl-svg { filter: drop-shadow(0 0 1px #10142e) drop-shadow(0 0 1px #10142e); }

/* ---------- Online ---------- */
.online-box { background: var(--panel); border: 2px solid var(--panel-border); border-radius: 20px; padding: calc(var(--u) * 2.6); width: min(92vw, 420px); display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
input { font-family: var(--body); font-size: 18px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--panel-border); background: rgba(5,8,24,0.8); color: var(--text); outline: none; user-select: text; -webkit-user-select: text; }
input:focus { border-color: var(--accent2); }
.join-row { display: flex; gap: 10px; }
.retry-row { display: flex; gap: 10px; width: 100%; }
.retry-row .btn { flex: 1; }
.join-row input { flex: 1; min-width: 0; font-family: var(--display); font-size: 28px; letter-spacing: 0.4em; text-align: center; text-transform: uppercase; }
.or { text-align: center; color: var(--muted); }
.warn { background: rgba(255,160,40,0.14); border: 1px solid rgba(255,160,40,0.5); border-radius: 12px; padding: 12px; font-size: 14px; line-height: 1.5; }
.warn code { background: rgba(0,0,0,0.35); padding: 1px 6px; border-radius: 6px; }
.online-status { min-height: 1.3em; color: var(--accent); text-align: center; margin: 0; font-size: 15px; }
.lobby-head { text-align: center; }
.room-code { font-family: var(--display); font-size: calc(var(--u) * 3); letter-spacing: 0.1em; color: var(--muted); }
.room-code b { font-size: 1.6em; color: var(--accent); letter-spacing: 0.25em; margin: 0 0.2em; text-shadow: 0 0 20px rgba(255,210,63,0.5); font-weight: 400; }
.lobby-status { color: var(--muted); margin: 4px 0 0; }

/* Salas públicas: estado del servidor y plazas reservadas, también en móvil. */
#scr-online.numbered-online .online-box { width: min(100%, 760px); min-height: 0; max-height: calc(100dvh - 140px); overflow-y: auto; flex-shrink: 1; padding: 16px; touch-action: pan-y; overscroll-behavior: contain; }
#scr-online.numbered-online .online-box > * { flex-shrink: 0; }
#scr-online.numbered-online .join-row { min-width: 0; }
.public-rooms { display: flex; flex-direction: column; gap: 10px; }
.public-rooms-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.public-rooms-heading h3 { margin: 0; font: 24px var(--display); letter-spacing: .04em; }
.public-rooms-heading span { font-size: 11px; color: var(--muted); text-align: right; }
.public-rooms-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.public-room { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; min-height: 82px; padding: 12px; border: 1px solid var(--panel-border); border-radius: 12px; background: rgba(20,26,60,.9); color: var(--text); text-align: left; }
.public-room strong { font: 24px var(--display); letter-spacing: .04em; }
.public-room-state { font: 500 11px var(--body); }
.public-room-slots { font: 500 11px var(--body); color: var(--muted); }
.public-room[data-state='free'] .public-room-state { color: #8be5b0; }
.public-room[data-state='waiting'] { border-color: var(--accent); }
.public-room[data-state='waiting'] .public-room-state { color: var(--accent); }
.public-room[data-state='playing'] .public-room-state, .public-room[data-state='paused'] .public-room-state { color: #ff91a6; }
.public-room:disabled { cursor: default; background: rgba(13,18,39,.9); }
.public-room:not(:disabled):hover { border-color: var(--accent2); background: rgba(35,50,85,.95); }
.public-room:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
@media (max-width: 520px) { .public-rooms-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .public-room { min-height: 76px; } }
@media (max-height: 480px) and (min-width: 521px) { .public-room { min-height: 64px; padding: 8px; } .public-room strong { font-size: 21px; } }

/* ---------- Final ---------- */
.end-panel { width: min(100%, 640px); min-width: 0; max-height: 100%; gap: 12px; padding: 24px; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.end-panel .end-winner { font-size: clamp(28px, calc(var(--u) * 4), 48px); }
.end-panel .end-winner img { width: clamp(40px, calc(var(--u) * 8), 80px); }
.end-panel .end-score { font-size: clamp(18px, calc(var(--u) * 2.8), 32px); text-align: center; }
#scr-end .online-status:empty { display: none; }
.end-series { width: 100%; display: flex; flex-direction: column; gap: 4px; text-align: center; padding: 10px 14px; border: 1px solid var(--panel-border); border-radius: 10px; background: rgba(0,0,0,.18); overflow-wrap: anywhere; }
.end-label { color: var(--muted); font-size: 11px; letter-spacing: .16em; }
.end-series b { font-size: clamp(14px, calc(var(--u) * 2.2), 22px); }
.end-series small { color: var(--muted); font-size: 12px; }
.end-featured { width: 100%; display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; border-left: 3px solid var(--accent); background: rgba(255,210,63,.08); }
.end-featured b { color: var(--accent); font-family: var(--display); font-size: 24px; letter-spacing: .04em; }
.end-featured span { color: var(--text); font-size: 12px; line-height: 1.4; }
.end-details { width: 100%; color: var(--muted); font-size: 13px; }
.end-details summary { cursor: pointer; padding: 4px; text-align: center; }
.end-details[open] summary { margin-bottom: 8px; }
.end-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#btn-rematch { grid-column: 1 / -1; font-size: clamp(26px, calc(var(--u) * 3.4), 40px); min-height: 48px; }
.end-actions .btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 4px; }
.end-actions .btn:not(#btn-rematch) { font-size: clamp(18px, calc(var(--u) * 2), 24px); padding-left: .6em; padding-right: .6em; }
@media (max-height: 500px) {
  #scr-end .end-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 14px; }
  #scr-end .end-winner { font-size: 24px; gap: 6px; }
  #scr-end .end-winner img { width: 40px; }
  #scr-end .end-score { font-size: 18px; text-align: center; }
  #scr-end .end-details, #scr-end .end-actions, #scr-end .end-status { grid-column: 1 / -1; }
  .end-series, .end-featured { padding: 6px 10px; }
  .end-featured b { font-size: 20px; }
  .end-actions { gap: 6px; }
  .end-actions .btn { font-size: 18px; }
  #btn-rematch { min-height: 42px; font-size: 26px; }
  #scr-end .online-status:empty { display: none; }
}
.end-winner { display: flex; align-items: center; gap: 14px; font-family: var(--display); font-size: calc(var(--u) * 5); letter-spacing: 0.04em; color: var(--accent); text-shadow: 0 0 30px rgba(255,210,63,0.5); text-align: center; }
.end-winner img { width: calc(var(--u) * 10); animation: headIn .6s cubic-bezier(.2,1.5,.4,1), float 2s ease-in-out infinite .6s; }
@keyframes float { 50% { transform: translateY(-8px) rotate(4deg); } }
.end-score { font-family: var(--display); font-size: calc(var(--u) * 3.4); letter-spacing: 0.06em; }
.end-stats { border-collapse: collapse; width: 100%; font-size: calc(var(--u) * 1.7); }
.end-stats td { padding: 5px 10px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.08); }
.end-stats td:nth-child(2) { color: var(--muted); text-transform: uppercase; font-size: 0.8em; letter-spacing: 0.08em; }
.end-stats td.win { color: var(--accent); font-weight: 800; }
.end-stats tr { animation: rise .4s both; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; bottom: auto; height: var(--app-h, 100dvh); z-index: 10; pointer-events: none; }
.scoreboard { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; animation: sbIn .6s cubic-bezier(.2,1.3,.4,1) both; filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5)); }
@keyframes sbIn { from { transform: translate(-50%, -140%); } }
.sb-main { display: flex; align-items: stretch; height: calc(var(--u) * 4.6); min-height: 30px; }
.sb-team { display: flex; align-items: center; gap: 8px; padding: 0 14px; background: linear-gradient(180deg, #1f2a66, #121945); font-family: var(--display); font-size: calc(var(--u) * 2.6); letter-spacing: 0.06em; min-width: calc(var(--u) * 17); }
.sb-left { border-radius: 10px 0 0 10px; justify-content: flex-end; border-left: 5px solid var(--c1, var(--accent2)); }
.sb-right { border-radius: 0 10px 10px 0; justify-content: flex-start; border-right: 5px solid var(--c2, var(--hot)); }
.sb-flag { display: inline-flex; align-items: center; }
img.flag { height: 0.72em; width: auto; aspect-ratio: 3 / 2; border-radius: 2px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.3); }
.sb-score { display: flex; align-items: center; gap: 6px; padding: 0 16px; background: linear-gradient(180deg, #fff, #d8dcf0); color: #0b0f2a; font-family: var(--display); font-size: calc(var(--u) * 3.6); min-width: calc(var(--u) * 11); justify-content: center; }
.sb-score span.bump { animation: bump .6s cubic-bezier(.2,1.8,.4,1); display: inline-block; color: #d6002a; }
@keyframes bump { 0% { transform: scale(2.2); } 100% { transform: scale(1); } }
.sb-sep { width: 10px; height: 3px; background: #0b0f2a; border-radius: 2px; }
.sb-clock { margin-top: -2px; background: #0b0f2a; border: 2px solid rgba(255,255,255,0.15); border-top: none; border-radius: 0 0 10px 10px; padding: 1px 14px 2px; font-family: var(--display); font-size: calc(var(--u) * 2.2); letter-spacing: 0.08em; display: flex; gap: 10px; align-items: center; }
.sb-live { font-size: 0.6em; color: #ff4d6d; letter-spacing: 0.12em; display: flex; align-items: center; gap: 4px; }
.sb-live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #ff4d6d; animation: blink 1s infinite; }
.sb-clock.golden { background: linear-gradient(90deg, #7a4d00, #ffd23f, #7a4d00); color: #1b1300; background-size: 200% 100%; animation: shine 1.2s linear infinite; }
.sb-clock.low #hud-clock { color: #ff4d6d; animation: blink .5s infinite; }
@keyframes shine { to { background-position: -200% 0; } }
/* Barra de súper estilo TV: inclinada como el marcador, 5 segmentos,
   color de la camiseta (--team) hacia el color del súper (--sc) e ícono del súper. */
.power { position: absolute; top: max(14px, env(safe-area-inset-top)); width: calc(var(--u) * 22); height: calc(var(--u) * 2.6); min-height: 16px; display: flex; align-items: center; --team: var(--accent2); --sc: #ff6a1a; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.45)); }
.power-left { left: max(16px, env(safe-area-inset-left)); }
.power-right { right: max(70px, env(safe-area-inset-right)); flex-direction: row-reverse; }
.power-track { position: relative; flex: 1; height: 100%; overflow: hidden; background: linear-gradient(180deg, #1f2a66, #0b0f2a); border: 2px solid rgba(255,255,255,0.18); transform: skewX(-18deg); }
.power-left .power-track { border-left: 5px solid var(--team); margin-left: -6px; }
.power-right .power-track { border-right: 5px solid var(--team); margin-right: -6px; transform: skewX(18deg); }
.power-track::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(90deg, transparent 0 calc(20% - 2px), rgba(5,8,24,0.85) calc(20% - 2px) 20%); }
.power-right .power-fill { margin-left: auto; }
.power-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--team), var(--sc)); box-shadow: inset 0 2px 0 rgba(255,255,255,0.35); transition: width .25s cubic-bezier(.2,1.2,.4,1); }
.power-right .power-fill { background: linear-gradient(270deg, var(--team), var(--sc)); }
.power-label { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-size: calc(var(--u) * 1.7); letter-spacing: 0.12em; color: #fff; text-shadow: 0 1px 2px #000, 0 0 6px rgba(0,0,0,0.6); transform: skewX(18deg); }
.power-right .power-label { transform: skewX(-18deg); }
.power-icon { position: relative; z-index: 1; flex: none; width: calc(var(--u) * 4.2); min-width: 28px; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 50% 35%, #2a3578, #0b0f2a 70%); border: 2px solid var(--sc); box-shadow: 0 0 0 2px rgba(0,0,0,0.5); filter: grayscale(0.7) brightness(0.8); transition: filter .3s; }
.power-icon .gl-svg { width: 62%; height: 62%; }
.power.full .power-icon { filter: none; animation: superPulse .7s ease-in-out infinite alternate; box-shadow: 0 0 14px var(--sc), 0 0 0 2px rgba(0,0,0,0.5); }
.power.full .power-track { border-color: #fff2b0; border-left-color: var(--team); }
.power-right.full .power-track { border-right-color: var(--team); border-left-color: #fff2b0; }
.power.full .power-fill { background: linear-gradient(90deg, var(--sc), #ffe14d, #ff4d6d, var(--sc)); background-size: 200% 100%; animation: shine .8s linear infinite; }
.power.full .power-track::after { background: repeating-linear-gradient(90deg, transparent 0 calc(20% - 2px), rgba(255,255,255,0.25) calc(20% - 2px) 20%); }
.power.armed .power-track { border-color: #ff4d6d; box-shadow: 0 0 18px rgba(255,77,109,0.9); }
@keyframes superPulse { to { transform: scale(1.12) rotate(-6deg); } }
@media (prefers-reduced-motion: reduce) { .power.full .power-icon, .power.full .power-fill { animation: none; } }
.hud-buttons { position: absolute; top: calc(max(14px, env(safe-area-inset-top)) + calc(var(--u) * 3.4)); left: max(16px, env(safe-area-inset-left)); pointer-events: auto; }
#emoji-bar { position: absolute; bottom: max(10px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; pointer-events: auto; background: rgba(5,8,24,0.55); padding: 6px 10px; border-radius: 999px; }
/* Ping: debajo del botón de sonido (que en el partido va arriba a la derecha) */
#net-info { position: absolute; top: 64px; right: calc(12px + env(safe-area-inset-right)); display: flex; align-items: center; gap: 6px; font: 600 12px system-ui, sans-serif; color: #fff; background: rgba(5,8,24,0.55); padding: 3px 8px; border-radius: 999px; pointer-events: none; }
#net-info.mid { color: #ffd76a; }
#net-info.bad, #net-info.lost { color: #ff8a8a; }
/* Barritas de señal: 4 = buena, 3 = regular, 2 = mala, 0 = cortada */
.net-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.net-bars i { width: 3px; border-radius: 1px; background: rgba(255,255,255,.25); }
.net-bars i:nth-child(1) { height: 4px; } .net-bars i:nth-child(2) { height: 6px; } .net-bars i:nth-child(3) { height: 9px; } .net-bars i:nth-child(4) { height: 12px; }
.net-bars i.on { background: #5ee08a; }
#net-info.mid .net-bars i.on { background: #ffd76a; }
#net-info.bad .net-bars i.on { background: #ff6b6b; }
#net-lost { position: absolute; top: 38%; left: 50%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 22px; border-radius: 14px; background: rgba(40,6,12,.88); border: 2px solid #ff6b6b; color: #fff; font: 600 14px system-ui, sans-serif; text-align: center; pointer-events: none; z-index: 30; animation: net-lost-pulse 1s ease-in-out infinite alternate; }
#net-lost strong { font-family: var(--display); font-size: 22px; letter-spacing: .04em; color: #ff8a8a; }
@keyframes net-lost-pulse { from { opacity: .75; } to { opacity: 1; } }
#emoji-bar button { font-size: 22px; background: none; border: none; padding: 2px 4px; transition: transform .12s; }
#emoji-bar button:hover { transform: scale(1.3); }
body.touch #emoji-bar { bottom: auto; top: calc(var(--u) * 10); }
.emoji-pop { position: absolute; top: 22%; font-size: calc(var(--u) * 7); opacity: 0; pointer-events: none; }
#emoji-pop-0 { left: 18%; } #emoji-pop-1 { right: 18%; }
.emoji-pop.show { animation: emojiPop 2s ease both; }
@keyframes emojiPop { 0% { opacity: 0; transform: scale(.2) translateY(20px); } 15% { opacity: 1; transform: scale(1.3); } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-40px); } }

/* ---------- Controles táctiles ---------- */
#touch { position: fixed; inset: 0; bottom: auto; height: var(--app-h, 100dvh); z-index: 15; pointer-events: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#touch * { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#touch { --tb: calc(clamp(60px, 15vh, 100px) * var(--ts, 1)); }
.touch-left, .touch-right { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); pointer-events: auto; }
.touch-left { left: max(18px, env(safe-area-inset-left)); display: flex; gap: calc(var(--tb) * 0.15); align-items: flex-end; }
.touch-right { right: max(18px, env(safe-area-inset-right)); width: calc(var(--tb) * 2.8); height: calc(var(--tb) * 2.7); }
.tbtn { width: var(--tb); height: var(--tb); border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); background: rgba(15,20,50,0.45); color: #fff; font-size: calc(var(--tb) * 0.38); backdrop-filter: blur(4px); touch-action: none; transition: transform .06s, background .06s; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; }
.tbtn.on { transform: scale(0.9); background: rgba(58,209,255,0.45); }
.tlabel { font-family: var(--display); font-weight: normal; font-size: calc(var(--tb) * 0.15); letter-spacing: .05em; line-height: 1; margin-top: .25em; pointer-events: none; text-shadow: 0 1px 2px #000; }
.touch-right .tbtn { position: absolute; }
.tbtn-kick { --action-color: #ffd23f; border-radius: 24%; width: calc(var(--tb) * 1.35); height: calc(var(--tb) * 1.35); right: 0; bottom: 0; background: rgba(255,210,63,0.4); border-color: var(--action-color); }
.tbtn-jump { left: 0; bottom: calc(var(--tb) * 0.05); background: rgba(125,255,143,0.28); border-color: #7dff8f; }
.tbtn-super { border-radius: 30%; right: calc(var(--tb) * 0.18); top: 0; background: rgba(255,77,109,0.35); border-color: #ff8fa3; }
.tbtn-shift { border-radius: 18%; width: var(--tb); height: var(--tb); left: calc(var(--tb) * 0.15); top: calc(var(--tb) * 0.15); background: rgba(92,208,255,0.3); border-color: #5cd0ff; }
.joy { display: none; position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: calc(var(--tb) * 2.2); height: calc(var(--tb) * 2.2); border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); background: rgba(15,20,50,0.4); backdrop-filter: blur(4px); pointer-events: auto; touch-action: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 42%; height: 42%; margin: -21% 0 0 -21%; border-radius: 50%; background: rgba(255,255,255,0.55); border: 2px solid #fff; pointer-events: none; }
#touch.joy-mode .joy { display: block; }
#touch.joy-mode .touch-left { display: none; }
body:not(.touch) .touch-only { display: none; }
body:not(.training) .train-only { display: none !important; }
#btn-ball { font-size: 26px; font-weight: bold; color: #fff; }
.tdetail { font: 600 calc(var(--tb) * 0.105) var(--body, sans-serif); margin-top: 4px; pointer-events: none; line-height: 1.15; }
.tbtn[data-state="unavailable"] { background-color: rgba(15,20,50,0.78); border-style: dashed; }
.tbtn-kick[data-state="available"] { background-color: rgba(15,20,50,0.88); box-shadow: inset 0 0 0 2px var(--action-color); }
.tbtn-super.ready { background: rgba(255,77,109,0.8); box-shadow: 0 0 14px rgba(255,77,109,0.5); }
.tbtn-shift[data-state="charging"] { background: rgba(92,208,255,0.55); }
.tbtn.on { transition: none; transform: scale(0.95); border-style: solid; }
@media (max-width: 620px) { #touch { --tb: calc(clamp(48px, 13vh, 70px) * var(--ts, 1)); } }
@media (prefers-reduced-motion: reduce) { .tbtn { transition: none; } }
@keyframes pulseSuper { 50% { box-shadow: 0 0 30px #ff4d6d; transform: scale(1.06); } }

/* ---------- Aviso y rotación ---------- */
#toast { position: fixed; left: 50%; top: 18%; transform: translate(-50%, -20px); z-index: 60; background: rgba(10,14,34,0.95); border: 2px solid var(--accent); color: var(--text); padding: 12px 22px; border-radius: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; text-align: center; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#rotate { display: none; position: fixed; inset: 0; z-index: 100; background: var(--bg); flex-direction: column; align-items: center; justify-content: center; gap: 16px; font-family: var(--display); font-size: 28px; letter-spacing: .05em; }
.rotate-phone { font-size: 90px; line-height: 0; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }

/* ---------- Pantallas bajas (celular horizontal) ---------- */
@media (max-height: 500px) {
  :root { --u: min(1.1vw, 2vh); }
  .screen { gap: 8px; }
  .pick-panel { min-height: 0; padding: 8px; }
  /* Nombre visible bajo la cara: hasta 2 líneas, la tarjeta crece en alto */
  .char { aspect-ratio: auto; justify-content: flex-start; gap: 1px; }
  .char img { width: 72%; }
  .char .char-name {
    font-size: max(12px, calc(var(--u) * 1.4)); line-height: 1.25; text-align: center; letter-spacing: 0;
    white-space: normal; overflow-wrap: normal; text-overflow: clip;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; min-height: 2.5em; padding-top: 2px; box-sizing: content-box;
  }
  .mode-card { padding: 12px; }
  .controls-help { display: none; }
  .screen-title { font-size: calc(var(--u) * 4); }
  .pick-head { width: calc(var(--u) * 10); }
  .btn { font-size: calc(var(--u) * 2.3); }
  .power { width: calc(var(--u) * 15); }
  .sb-team { min-width: 0; padding: 0 8px; font-size: calc(var(--u) * 2.2); }
  .sb-score { min-width: 0; padding: 0 10px; }
}
@media (max-width: 800px) and (orientation: portrait) {
  .select-layout { grid-template-columns: 1fr 1fr; }
  .select-layout .char-grid { grid-column: 1 / -1; grid-row: 2; grid-template-columns: repeat(4, 1fr); width: 100%; }
}

/* La cara del J2 mira hacia el centro (espejada) */
#pick-1 .pick-head, #lobby-pick-1 .pick-head { transform: scaleX(-1); animation: none; }
.shots-help { max-width: 900px; margin-left: auto; margin-right: auto; }
.shots-help i { font-style: normal; font-weight: 600; white-space: nowrap; }
.hud-buttons { display: flex; gap: 10px; align-items: center; }
.aid-chip { font-family: var(--display); font-size: 15px; letter-spacing: 0.08em; padding: 6px 12px 4px; border-radius: 999px; border: 2px solid rgba(125,255,143,0.6); background: rgba(5,8,24,0.75); color: #7dff8f; }
.aid-chip.off { color: var(--muted); border-color: rgba(255,255,255,0.2); }

/* ---------- Celular horizontal con barras del navegador (poca altura) ---------- */
/* Si algo no entra, la pantalla se puede deslizar */
.screen { overflow-y: auto; touch-action: pan-y; justify-content: flex-start; }
.screen > *:first-child { margin-top: auto; }
.screen > *:last-child { margin-bottom: auto; }
@media (max-height: 460px) {
  .screen { justify-content: flex-start; padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); gap: 6px; }
  .screen > *:first-child { margin-top: auto; }
  .screen > *:last-child { margin-bottom: auto; }
  #scr-select .screen-title, #scr-lobby .lobby-status { display: none; }
  #scr-select .select-steps { font-size: 14px; }
  #scr-select #btn-confirm.cpu-cta { font-size: 16px; }
  .select-layout { gap: 8px; }
  .char-grid { grid-template-columns: repeat(6, min(10.5vw, 15.5vh)); gap: 5px; }
  .char { border-radius: 10px; padding: 3% 3% 4%; }
  .pick-panel { padding: 6px 8px; gap: 2px; min-height: 0; border-radius: 14px; }
  .pick-who { font-size: 13px; }
  .pick-head, .pick-unknown { width: 17vh; }
  .pick-name { font-size: 6.5vh; }
  .pick-super { font-size: 11px; }
  .stat { font-size: 10px; grid-template-columns: 62px 1fr; }
  .bar i { height: 7px; }
  .pick-state { font-size: 14px; min-height: 0; }
  .select-bottom { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px; }
  .difficulty, .difficulty button { font-size: 16px; }
  .btn { font-size: 18px; padding: 0.3em 1em 0.2em; }
  .mode-card { padding: 10px; gap: 4px; }
  .mc-icon { font-size: 9vh; }
  .room-code { font-size: 18px; }
  .panel { padding: 12px 16px; gap: 8px; }
  .end-winner { font-size: 26px; } .end-winner img { width: 56px; }
  .end-score { font-size: 18px; }
  .end-stats { font-size: 13px; } .end-stats td { padding: 2px 8px; }
}

/* Íconos animados dibujados con canvas (js/icons.js) */
[data-icon] { display: inline-block; line-height: 0; vertical-align: middle; }
canvas.anim-icon { width: 1em; height: 1em; display: block; }
.mc-icon { line-height: 0; }
.icon-btn [data-icon] { font-size: 26px; }
.icon-btn.small [data-icon] { font-size: 20px; }
.tbtn [data-icon] { font-size: 1.25em; pointer-events: none; }
.btn-ico { font-size: 1.1em; margin-right: 0.15em; vertical-align: -0.2em; }

.pu-toggle.on { background: var(--accent); color: #1b1300; border-color: #fff2b0; }
.pu-toggle:disabled { opacity: 0.75; cursor: default; }

/* Íconos vectoriales (glyphs.js) en vez de emojis */
.gl { display: inline-block; line-height: 0; vertical-align: -0.15em; }
.gl-svg { width: 1em; height: 1em; vertical-align: -0.15em; overflow: visible; }
.gl .gl-svg { vertical-align: 0; }
#emoji-bar button .gl { font-size: 26px; }
.emoji-pop .gl-svg { width: 1em; height: 1em; filter: drop-shadow(0 4px 10px rgba(0,0,0,.45)); }
.tbtn .gl { font-size: 0.9em; }

/* ---------- Compartir / instalar ---------- */
#btn-share { margin-top: 10px; font-size: calc(var(--u) * 2.4); }
.share-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 28px; justify-items: center; align-items: start; max-width: 94vw; max-height: 92vh; overflow-y: auto; }
.share-col { display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 360px; }
.share-qr { width: min(34vh, 220px); height: auto; border-radius: 12px; border: 4px solid #fff; background: #fff; }
.share-url { font-weight: 600; color: var(--accent); word-break: break-all; text-align: center; }
.share-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.install-box { text-align: left; line-height: 1.5; margin: 0; padding: 12px 16px 12px 32px; border-radius: 12px; background: rgba(5,8,24,0.6); border: 2px solid var(--panel-border); }
#install-done { padding-left: 16px; }
.share-panel .back-title { grid-column: 1 / -1; }
.share-panel .screen-title { margin: 0; }

/* Pausa en celular horizontal: botones en 2 columnas para que entren todos */
@media (max-height: 500px) {
  #scr-pause .panel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; max-height: 94vh; overflow-y: auto; }
  #scr-pause .screen-title { grid-column: 1 / -1; margin: 0; }
  /* SALIR AL MENÚ sube al hueco libre junto a TRUCOS; el tamaño de controles queda al final (antes había que scrollear para salir) */
  #scr-pause .touch-sizes { order: 1; }
}

/* ---------- Libreta de trucos ---------- */
.btn-tricks { font-size: calc(var(--u) * 2.2); }
.tricks-panel { width: min(94vw, 900px); max-height: 94vh; overflow-y: auto; }
.tricks-sub { margin: 0; color: var(--muted); text-align: center; }
#tricks-count { color: #7dff8f; }
.tricks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; width: 100%; }
.trick { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border-radius: 12px; background: rgba(5,8,24,0.6); border: 2px solid rgba(255,255,255,0.12); font-size: 14px; line-height: 1.3; color: var(--muted); }
.trick b { font-family: var(--display); font-weight: normal; font-size: 19px; letter-spacing: .04em; color: var(--muted); }
.trick.on { border-color: rgba(125,255,143,0.6); color: var(--text); }
.trick.on b { color: #7dff8f; }

/* Online: crear sala y unirse con código en una fila */
.code-row { display: flex; gap: 10px; width: 100%; align-items: stretch; flex-wrap: wrap; }
.code-row #btn-create { flex: 1 1 140px; }
.code-row .join-row { flex: 2 1 220px; }
.friends { display: flex; flex-direction: column; gap: 8px; }
.online-section-title { margin: 0; font: 24px var(--display); letter-spacing: .04em; }
/* Celular horizontal: AL AZAR y CON AMIGOS entran sin desplazar; las salas quedan debajo */
@media (max-height: 500px) {
  #scr-online .screen-title { display: none; }
  #scr-online.numbered-online .online-box { max-height: calc(100dvh - 76px); padding: 12px 16px; gap: 8px; }
  #scr-online .field { flex-direction: row; align-items: center; gap: 10px; }
  #scr-online .field input { flex: 1; min-width: 0; padding: 6px 12px; }
  #scr-online .online-status:empty { min-height: 0; }
  #scr-online .online-section-title { font-size: 20px; }
  .friends { gap: 6px; }
  #scr-online .code-row .btn, #scr-online .join-row input { padding-top: 8px; padding-bottom: 6px; }
  #scr-online .join-row input { font-size: 22px; }
  /* El sonido sube a la altura de MODOS: abajo tapaba ENTRAR (sobre todo con el teclado abierto) */
  body:has(#scr-online.active) #btn-mute { top: max(10px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
  /* Con el teclado abierto no queda lugar libre: se oculta mientras se escribe */
  body:has(#scr-online.active input:focus) #btn-mute { display: none; }
}

/* Volver siempre visible arriba a la izquierda (en celular el de abajo quedaba fuera de pantalla) */
.back-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(12px, env(safe-area-inset-left)); z-index: 2; }
.screen:has(> .back-top) { padding-top: max(64px, calc(env(safe-area-inset-top) + 58px)); }
.screen > .back-top:first-child + * { margin-top: auto; }

/* ---------- Zona de práctica ---------- */
#scr-training { padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); }
.training-panel { width: min(100%, 840px); padding: 18px; margin: 0 auto; flex-shrink: 0; align-items: stretch; gap: 12px; }
.training-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.training-heading h2 { margin: 0; font: 28px var(--display); color: var(--accent); }
.training-heading p { margin: 2px 0 0; color: #7dff8f; font-size: 12px; }
.training-heading .btn { font-size: 17px; min-height: 40px; }
.training-tabs { display: flex; gap: 8px; }
.training-tabs button { flex: 1; min-height: 40px; border: 1px solid var(--panel-border); border-radius: 8px; background: #151d41; color: var(--muted); font: 18px var(--display); }
.training-tabs button.selected { color: var(--accent); border-color: var(--accent); }
#training-exercises-page { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; align-items: start; }
.training-category-label { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.training-category-label select { flex: 1; min-width: 0; min-height: 40px; padding: 6px 10px; border: 1px solid var(--panel-border); border-radius: 8px; background: #151d41; color: var(--text); font: 14px var(--body); }
.training-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.training-drill { min-height: 44px; padding: 8px 10px; border: 1px solid var(--panel-border); border-radius: 9px; background: #151d41; color: var(--text); font-size: 13px; text-align: left; }
.training-drill.selected { border-color: var(--accent); background: #303044; box-shadow: inset 0 0 0 1px var(--accent); }
.training-drill.done::after { content: ' ✓'; color: #7dff8f; }
.training-drill:focus-visible, .training-settings select:focus-visible, .training-tabs button:focus-visible, .training-category-label select:focus-visible, .training-result button:focus-visible { outline: 3px solid var(--accent2); outline-offset: 2px; }
.training-selected { margin: 0; padding: 14px; border: 1px solid #ffd23f66; border-radius: 10px; background: #242334; }
.training-selected b { color: var(--accent); font: 24px var(--display); }
.training-selected p { font-size: 13px; line-height: 1.5; margin: 6px 0 0; }
.training-settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.training-settings label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.training-settings select { width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--panel-border); border-radius: 8px; color: var(--text); background: #151d41; font: 13px var(--body); }
.training-settings .training-check { flex-direction: row; align-items: center; min-height: 40px; color: var(--text); }
.training-check input { width: 20px; height: 20px; accent-color: var(--accent); }
.training-effects { grid-column: 1 / -1; display: flex; gap: 10px; align-items: flex-end; }
.training-effects label { flex: 1; }
.training-effects .btn { font-size: 17px; min-height: 40px; }
.training-note { font-size: 11px; color: var(--muted); margin: 10px 0 0; line-height: 1.5; }
.training-start { position: sticky; bottom: -1px; padding: 4px 0; background: #10172e; text-align: center; }
.training-start .btn { font-size: 22px; min-height: 44px; width: 100%; }
.training-result { display: flex; gap: 8px; margin-top: 8px; pointer-events: auto; }
.training-result button { flex: 1; min-height: 40px; border: 1px solid #7dff8f; border-radius: 8px; color: #f4f6ff; background: #162a26; font: 16px var(--display); }
.training-result #btn-training-next { color: #0b1820; background: #7dff8f; }
#training-hint { position: fixed; top: max(80px, calc(var(--u) * 13)); left: 50%; transform: translateX(-50%); width: min(380px, 50vw); z-index: 10; padding: 8px 12px; border: 1px solid #ffd23f66; border-radius: 10px; background: rgba(8,12,30,.9); pointer-events: none; }
#training-hint b { display: block; font: 18px var(--display); color: var(--accent); }
#training-hint span { display: block; font-size: 11px; line-height: 1.45; margin-top: 3px; }
#training-hint.achieved { border-color: #7dff8f; }
#training-hint.achieved b { color: #7dff8f; }
@media (max-width: 620px) {
  #training-exercises-page { grid-template-columns: 1fr; gap: 12px; }
  .training-settings { gap: 12px; }
  .training-heading h2 { font-size: 27px; }
  #training-hint { top: 76px; width: min(310px, 48vw); padding: 6px 9px; }
  #training-hint span { font-size: 10px; }
}

body.training .hud-buttons { top: 80px; max-width: calc((100vw - min(380px, 50vw)) / 2 - 28px); flex-wrap: wrap; gap: 6px; }
body.training #btn-ball { font-size: 14px; }
body:has(.screen.active) #training-hint { display: none; }
@media (max-width: 620px) { body.training .hud-buttons { top: 76px; max-width: calc((100vw - min(310px, 48vw)) / 2 - 28px); } }

.training-settings select:disabled, .training-effects .btn:disabled { opacity: .55; cursor: default; }
.training-effects .btn:disabled { transform: none; filter: none; }

body:has(#scr-training.active) #btn-mute { display: none; }
@media (max-height: 480px) {
  #scr-training { padding-top: 8px; padding-bottom: 8px; }
  .training-panel { padding: 12px; gap: 8px; }
  .training-heading h2 { font-size: 24px; }
  #training-exercises-page { grid-template-columns: 1.2fr 1fr; gap: 12px; }
  .training-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .training-category-label { margin-bottom: 8px; }
  .training-selected { padding: 10px; }
  .training-selected p { font-size: 12px; }
  .training-settings { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .training-settings .training-effects { grid-column: span 2; }
  .training-settings .training-effects .btn { font-size: 14px; padding: 6px; }
  .training-settings .training-check { font-size: 11px; }
  .training-note { font-size: 10px; }
}

@media (max-height: 480px) and (min-width: 540px) {
  .training-panel { padding: 8px; gap: 6px; }
  .training-drill { padding: 6px; line-height: 1.15; }
  .training-category-label { margin-bottom: 4px; }
  .training-selected { padding: 8px; }
  .training-selected b { font-size: 22px; }
  .training-selected p { line-height: 1.35; }
  .training-heading > div { display: flex; align-items: baseline; gap: 12px; }
  .training-start { padding: 0; }
}

/* Práctica: la guía ocupa el marcador, sin panel sobre la cancha. */
body.training .scoreboard { display: none; }
body.training #training-hint { position: absolute; top: max(8px, env(safe-area-inset-top)); width: min(440px, calc(100vw - var(--u) * 40 - 144px)); margin: 0; padding: 7px 10px; border-radius: 9px; pointer-events: auto; }
body.training #training-hint b { font-size: 17px; }
body.training #training-hint span { font-size: 10.5px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
body.training #training-hint.achieved span { display: none; }
body.training .training-result { margin-top: 4px; gap: 6px; }
body.training .training-result button { min-height: 32px; font-size: 14px; }
body.training .hud-buttons { top: 86px; max-width: calc(100vw - 32px); flex-wrap: wrap; gap: 6px; }
.training-free { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; font-size: 25px; }
.training-free small { font: 12px var(--body); }
#training-exercises-page { display: block; }
.training-panel { width: min(100%, 620px); }
.training-drill { min-height: 44px; }
@media (max-width: 620px) {
  body.training .power { display: none; }
  body.training #training-hint { width: calc(100vw - 32px); }
  body.training .hud-buttons { top: 86px; }
  .training-free { min-height: 46px; font-size: 23px; }
}

.training-panel { max-height: calc(100dvh - 24px); overflow-y: auto; }
@media (max-height: 500px) { .training-panel { gap: 6px; } .training-free { min-height: 42px; } }

/* Básicos: carril horizontal y dos acciones principales de posición fija.
   El tamaño se limita también por ancho para no juntar ambos pulgares. */
#touch.basic-mode { --tb: clamp(48px, min(calc(15vh * var(--ts, 1)), 13vw), 88px); }
#touch.basic-mode .touch-left, #touch.basic-mode .tbtn-down { display: none; }
#touch.basic-mode .joy { width: calc(var(--tb) * 2.2); height: calc(var(--tb) * 1.25); border-radius: 999px; }
#touch.basic-mode .joy-knob { width: calc(var(--tb) * .85); height: calc(var(--tb) * .85); margin: calc(var(--tb) * -.425) 0 0 calc(var(--tb) * -.425); }
#touch.basic-mode .touch-right { width: calc(var(--tb) * 2.7); height: calc(var(--tb) * 2.4); }
#touch.basic-mode .tbtn-jump, #touch.basic-mode .tbtn-kick { width: calc(var(--tb) * 1.2); height: calc(var(--tb) * 1.2); bottom: 0; border-radius: 24%; }
#touch.basic-mode .tbtn-jump { left: 0; }
#touch.basic-mode .tbtn-kick { right: 0; }
#touch.basic-mode .tbtn-shift, #touch.basic-mode .tbtn-super { width: calc(var(--tb) * .85); height: calc(var(--tb) * .85); top: 0; }
#touch.basic-mode .tbtn-shift { left: calc(var(--tb) * .175); }
#touch.basic-mode .tbtn-super { right: calc(var(--tb) * .175); }
#touch.basic-mode .tlabel { font-size: max(12px, calc(var(--tb) * .19)); }
#touch.basic-mode .tdetail { font-size: max(8px, calc(var(--tb) * .105)); }
#touch.basic-mode .tbtn-shift .tlabel, #touch.basic-mode .tbtn-super .tlabel { font-size: max(11px, calc(var(--tb) * .16)); }
#touch.basic-mode .joy::before { content: '← MOVER →'; position: absolute; left: 0; right: 0; top: -22px; text-align: center; font: 13px var(--display); color: #fff; text-shadow: 0 1px 3px #000; }
.mobile-controls-help, .mobile-mode-help { max-width: 380px; font-size: 13px; line-height: 1.4; color: var(--muted); text-align: center; margin: 0; }
body.touch .controls-help { display: none; }
#scr-pause .mobile-controls-help { grid-column: 1 / -1; }

#touch:not(.basic-mode) { --tb: clamp(42px, min(calc(15vh * var(--ts, 1)), calc((100vw - 56px) / 6.1)), 100px); }

/* Controles de juego: superficies claras, iconos quietos y respuesta inmediata. */
#touch .tbtn {
  --control-ink: #eaf3ff;
  --control-edge: rgba(215,230,255,.3);
  --control-top: rgba(31,45,68,.96);
  --control-bottom: rgba(16,27,46,.96);
  color: var(--control-ink);
  background: linear-gradient(160deg, var(--control-top), var(--control-bottom));
  border: 1px solid var(--control-edge);
  box-shadow: 0 4px 12px rgba(0,8,24,.3), inset 0 1px 0 rgba(255,255,255,.22);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  text-shadow: none;
  gap: 2px;
  padding: 5px 3px;
  transition: transform 100ms cubic-bezier(.23,1,.32,1);
}
#touch .tbtn .gl { font-size: clamp(18px, calc(var(--tb) * .4), 32px); line-height: 1; pointer-events: none; }
#touch .tlabel { font: 800 clamp(10px, calc(var(--tb) * .19), 16px)/1.1 var(--body); letter-spacing: .02em; margin: 0; text-shadow: none; }
#touch .tdetail { font: 600 clamp(8px, calc(var(--tb) * .13), 10px)/1.2 var(--body); color: inherit; opacity: .82; margin: 0; white-space: nowrap; letter-spacing: -.02em; }
#touch .tbtn-jump { --control-ink: #10372a; --control-edge: #caffdd; --control-top: #b0ffd2; --control-bottom: #77e8ac; }
#touch .tbtn-kick { --control-ink: #473009; --control-edge: #fff1bf; --control-top: #ffeaa3; --control-bottom: #ffd063; }
#touch .tbtn-shift { --control-ink: #b5efff; --control-edge: #73cbe5; --control-top: #25475c; --control-bottom: #172d40; }
#touch .tbtn-super { --control-ink: #e4d7ff; --control-edge: #a48bcd; --control-top: #3f3359; --control-bottom: #27213d; }
#touch .tbtn-super.ready { --control-ink: #332046; --control-edge: #f2e7ff; --control-top: #ead6ff; --control-bottom: #c6a5ff; }
#touch .tbtn-super.ready::after { content: ''; position: absolute; right: 5px; top: 5px; width: 5px; height: 5px; border-radius: 50%; background: #332046; }
#touch .tbtn[data-state='unavailable'] { border-style: solid; }
#touch .tbtn-kick[data-state='available'] { box-shadow: 0 4px 12px rgba(0,8,24,.3), inset 0 1px 0 rgba(255,255,255,.45); }
#touch .tbtn-jump[data-state='unavailable'] { --control-top: #789b8c; --control-bottom: #648676; --control-edge: #a5c3b4; --control-ink: #0f2c21; }
#touch .tbtn-kick[data-state='unavailable'] { --control-top: #b6a574; --control-bottom: #9c8b59; --control-edge: #d6c798; }
#touch .tbtn-shift[data-state='charging'] { --control-top: #336f85; --control-bottom: #214c63; }
#touch .tbtn.on, #touch .tbtn:active { transform: scale(.96); box-shadow: inset 0 2px 5px rgba(0,8,24,.2); transition: none; }
#touch .tbtn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
#touch.basic-mode .tbtn-jump, #touch.basic-mode .tbtn-kick { border-radius: 22px; }
#touch.basic-mode .tbtn-jump .tdetail { display: none; }
#touch.basic-mode .tbtn-shift, #touch.basic-mode .tbtn-super { width: var(--tb); height: var(--tb); border-radius: 17px; padding: 3px; }
#touch.basic-mode .tbtn-shift { left: calc(var(--tb) * .1); }
#touch.basic-mode .tbtn-super { right: calc(var(--tb) * .1); }
#touch.basic-mode .tbtn-shift .gl, #touch.basic-mode .tbtn-super .gl { font-size: clamp(16px, calc(var(--tb) * .3), 24px); }
#touch.basic-mode .tbtn-shift .tlabel, #touch.basic-mode .tbtn-super .tlabel { font-size: clamp(9px, calc(var(--tb) * .15), 13px); }
#touch.basic-mode .tbtn-shift .tdetail, #touch.basic-mode .tbtn-super .tdetail { font-size: clamp(7px, calc(var(--tb) * .12), 10px); }
#touch .joy { border: 1px solid rgba(221,236,255,.3); background: rgba(17,29,47,.88); box-shadow: inset 0 2px 6px rgba(0,8,24,.25), 0 4px 12px rgba(0,8,24,.24); backdrop-filter: none; -webkit-backdrop-filter: none; }
#touch .joy-knob { border: 1px solid #d3ffea; background: linear-gradient(145deg, #e3fff2, #99eec5); box-shadow: 0 2px 6px rgba(0,8,24,.24), inset 0 1px 0 #fff; }
#touch.basic-mode .joy-knob::after { content: '‹ ›'; position: absolute; inset: 0; display: grid; place-items: center; color: #27533f; font: 700 calc(var(--tb) * .38)/1 var(--body); }
#touch.basic-mode .joy::before { font: 700 10px/1 var(--body); letter-spacing: .1em; top: -19px; color: #e4f0ff; }
@media (prefers-reduced-motion: reduce) { #touch .tbtn { transition: none; } }

/* Botones auxiliares con el mismo acabado del mando. */
.hud-buttons .icon-btn, body.in-match #btn-mute { border-radius: 14px; border: 1px solid rgba(220,235,255,.25); background: rgba(19,31,50,.94); box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 3px 9px rgba(0,8,24,.2); backdrop-filter: none; }
.hud-buttons .aid-chip, body .hud-buttons #btn-ball { font: 700 11px/1.3 var(--body); letter-spacing: .01em; padding: 7px 12px; border-radius: 11px; border: 1px solid rgba(201,228,216,.35); background: rgba(19,37,40,.94); color: #bdedd6; box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
.hud-buttons .aid-chip.off { color: #a9b6c8; border-color: rgba(220,235,255,.2); background: rgba(19,31,50,.94); }
.hud-buttons button:active { transform: scale(.97); }
#scr-pause .btn { border-radius: 14px; border-width: 1px; box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 3px 9px rgba(0,8,24,.18); }
#scr-pause .btn-glow { background: linear-gradient(145deg, #ffeaa3, #ffd063); color: #473009; }
#scr-pause #btn-control-mode { background: #b0f5d3; color: #10372a; border-color: #caffdd; }
#scr-pause #btn-control-mode[aria-pressed='true'] { background: #dac3fc; color: #332046; border-color: #f2e7ff; }
#scr-pause .btn:hover { transform: none; }
#scr-pause .btn:active { transform: scale(.98); }
@media (max-width: 620px) { body.training #training-hint { padding-right: 48px; } }

/* Aviso del primer partido del día, unido al control que explica. */
.aids-guide { position: absolute; top: calc(100% + 10px); left: 0; width: min(300px, calc(100vw - 32px)); padding: 12px 44px 12px 14px; border: 1px solid #91cfb6; border-radius: 14px; background: rgba(17,32,43,.98); color: #eaf5ef; box-shadow: 0 5px 16px rgba(0,8,24,.28); }
.aids-guide strong { display: block; font: 800 11px/1.3 var(--body); letter-spacing: .04em; color: #b0f5d3; }
.aids-guide p { margin: 5px 0 0; font: 500 12px/1.45 var(--body); }
.aids-guide button { position: absolute; right: 2px; top: 2px; width: 40px; height: 40px; border: 0; background: none; color: #b9cdce; font: 24px/1 var(--body); border-radius: 10px; }
.aids-guide button:focus-visible { outline: 2px solid #b0f5d3; outline-offset: -3px; }
.hud-buttons .aid-chip.discover { border-color: #b0f5d3; outline: 2px solid rgba(176,245,211,.35); outline-offset: 3px; color: #d9ffec; }
body:has(.screen.active) .aids-guide { display: none; }
/* Replay: cancha libre, controles fuera del centro de la jugada. */
#scr-replay { justify-content: space-between; pointer-events: none; }
#replay-canvas { position: fixed; inset: 0; width: 100vw; height: 100dvh; z-index: -1; }
.replay-heading { align-self: flex-start; display: flex; flex-direction: column; gap: 3px; max-width: 70%; padding: 8px 12px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; }
.replay-heading b { font-family: var(--display); color: var(--accent); font-size: clamp(20px,3vw,30px); }
.replay-heading span { font-size: clamp(10px,1.5vw,14px); }
.replay-controls { pointer-events: auto; width: min(94vw,620px); padding: 8px 12px; background: var(--panel); border-radius: 12px; }
.replay-controls progress { display: block; width: 100%; height: 5px; margin-bottom: 10px; accent-color: var(--accent); }
.replay-controls > div { display: flex; justify-content: center; gap: 8px; }
.replay-controls .btn { font-size: clamp(16px,2vw,24px); padding-inline: .65em; min-height: 38px; }
.replay-controls .btn:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }

body:has(#scr-replay.active) #btn-mute { display: none; }

#scr-replay { background: transparent; overflow: hidden; transition: none; transform: none; }
#scr-replay.active { transition: none; }
#scr-replay > .replay-controls { margin-bottom: 0; }
#scr-replay > .replay-heading { margin-top: 0; }
#scr-replay.active > #replay-canvas { animation: none; }
body:has(#scr-replay.active) #hud { visibility: hidden; }

#invite-link { width: min(100%, 540px); min-height: 36px; padding: 8px; font-size: 14px; }


/* Mobile match: thumb controls behind each goal, leaving the field full height.
   Portrait keeps its existing rotation prompt and compact fallback controls. */
@media (orientation: landscape) {
  body.touch-match #touch {
    --unit: clamp(44px, calc(12vh * var(--ts)), 60px);
    --secondary: max(44px, calc(var(--unit) * .72));
    --deck-height: calc(var(--unit) + var(--secondary) + 8px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    padding: env(safe-area-inset-top, 0px) var(--safe-right) 0 var(--safe-left);
    touch-action: none;
  }
  body.touch-match #touch::after { display: none; }
  body.touch-match #touch .touch-right {
    display: grid; grid-template-columns: repeat(2, var(--unit)); grid-template-rows: var(--secondary) var(--unit); align-items: center; justify-items: center; gap: 8px; width: auto; height: var(--deck-height);
    right: calc(12px + var(--safe-right)); bottom: calc(8px + var(--safe-bottom));
    pointer-events: none;
  }
  body.touch-match #touch .tbtn {
    position: relative; inset: auto; flex: none; width: var(--secondary); height: var(--secondary);
    border-radius: 50%; border: 2px solid var(--control-edge, #9eacc7);
    box-shadow: 0 3px 0 #040818, inset 0 1px 0 #ffffff40;
    pointer-events: auto; padding: 2px; gap: 0; touch-action: none;
  }
  body.touch-match #touch .tbtn-jump, body.touch-match #touch .tbtn-kick { width: var(--unit); height: var(--unit); }
  body.touch-match #touch .tbtn-shift { grid-column: 1; grid-row: 1; }
  body.touch-match #touch .tbtn-super { grid-column: 2; grid-row: 1; }
  body.touch-match #touch .tbtn-jump { grid-column: 1; grid-row: 2; }
  body.touch-match #touch .tbtn-kick { grid-column: 2; grid-row: 2; }
  body.touch-match #touch .tbtn .gl { font-size: calc(var(--unit) * .35); }
  body.touch-match #touch .tbtn .tlabel { font: 400 14px/1 var(--display); letter-spacing: .04em; }
  body.touch-match #touch .tbtn-shift .gl, body.touch-match #touch .tbtn-super .gl { font-size: 18px; }
  body.touch-match #touch .tbtn .tdetail { display: none; }
  body.touch-match #touch .tbtn-super .tdetail { display: block; font: 400 11px/1.1 var(--display); }
  body.touch-match #touch .tbtn-shift .tlabel { font-size: 12px; }
  body.touch-match #touch .tbtn-super .tlabel { display: block; font-size: 11px; }
  body.touch-match #touch .tbtn-super .gl { font-size: 16px; }
  body.touch-match #touch .tbtn[data-state='unavailable'] { border-style: dashed; }
  body.touch-match #touch .tbtn.on { transform: translateY(3px); border-style: solid; box-shadow: inset 0 2px 6px #0009; outline: 2px solid #fff; outline-offset: 2px; }
  body.touch-match #touch .tbtn-super::before {
    content: ''; position: absolute; inset: -4px; border-radius: 50%; z-index: -1;
    background: conic-gradient(#e6caff var(--charge, 0deg), #36415a 0deg);
  }
  body.touch-match #touch .tbtn-super.ready::after {
    content: '✓'; position: absolute; right: -3px; top: -5px; width: 16px; height: 16px;
    display: grid; place-items: center; background: #f5e9ff; color: #231236; font: bold 12px/1 var(--body); border-radius: 50%;
  }
  body.touch-match #touch .joy {
    left: calc(12px + var(--safe-left)); bottom: calc(8px + var(--safe-bottom));
    width: calc(var(--unit) * 2 + 8px); height: var(--unit); border-radius: 999px;
    background: #131f35; border: 2px solid #8294ad;
  }
  body.touch-match #touch:not(.basic-mode) .joy { width: var(--unit); height: var(--unit); border-radius: 50%; }
  body.touch-match #touch .joy::before {
    content: attr(aria-label); font: 400 12px/1 var(--display); letter-spacing: .08em;
    position: absolute; top: 3px; left: 0; right: 0; text-align: center; color: #dce9ff;
  }
  body.touch-match #touch.basic-mode .joy::before { content: 'DESLIZÁ ← →'; }
  body.touch-match #touch:not(.basic-mode) .joy::before { content: 'JOYSTICK'; }
  body.touch-match #touch .joy-knob {
    width: calc(var(--unit) * .62); height: calc(var(--unit) * .62);
    margin: calc(var(--unit) * -.31) 0 0 calc(var(--unit) * -.31);
    background: linear-gradient(#d5e7ff, #8baacd); border: 2px solid #f0f6ff;
  }
  body.touch-match #touch .touch-left {
    left: calc(12px + var(--safe-left)); bottom: calc(8px + var(--safe-bottom));
    gap: 6px; height: auto; flex-direction: row; align-items: flex-end; pointer-events: none;
  }
  body.touch-match #touch .touch-left::before { content: none; }
  body.touch-match #touch .touch-left .tbtn { width: 44px; height: 44px; }
  body.touch-match #touch .touch-left .gl { font-size: 20px; }
  body.touch-match .own-power, body.touch-match #aid-chip { display: none; }
  body.touch-match .rival-power { top: max(8px, env(safe-area-inset-top)); left: auto; right: calc(68px + env(safe-area-inset-right)); width: 118px; height: 16px; }
  body.touch-match .rival-power .power-icon { min-width: 24px; width: 24px; }
  body.touch-match .rival-power .power-label { font-size: 11px; }
  body.touch-match .hud-buttons { top: max(8px, env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); }
  body.training.touch-match .hud-buttons { top: calc(86px + env(safe-area-inset-top)); }
  body.training.touch-match #training-hint { width: min(440px, calc(100vw - 144px - env(safe-area-inset-left) - env(safe-area-inset-right))); }
  body.touch-match #btn-pause, body.touch-match #btn-mute { width: 44px; height: 44px; border-radius: 50%; }
  body.touch-match #btn-mute { right: calc(12px + env(safe-area-inset-right)); }
  body.touch-match #emoji-bar { top: calc(64px + env(safe-area-inset-top)); bottom: auto; }
}
@media (orientation: landscape) and (max-width: 650px) {
  body.touch-match #touch { --unit: clamp(44px, calc(12vh * var(--ts)), 52px); }
  body.touch-match #touch .touch-right { right: calc(8px + var(--safe-right)); }
  body.touch-match #touch .joy, body.touch-match #touch .touch-left { left: calc(8px + var(--safe-left)); }
  body.touch-match .rival-power { top: 58px; right: calc(12px + env(safe-area-inset-right)); }
}

/* Shared control size: Chico / Mediano / Grande. */
.touch-sizes { grid-column: 1 / -1; width: 100%; padding: 12px; border: 1px solid #596980; border-radius: 14px; background: #131f35; }
.touch-sizes h3 { margin: 0 0 12px; font: 18px var(--display); }
.size-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.size-choices button { min-height: 44px; border: 1px solid #8294ad; border-radius: 9px; color: #dce9ff; background: #080e20; font: 15px var(--body); cursor: pointer; }
.size-choices button[aria-pressed='true'] { background: #b0f5d3; color: #10372a; border-color: #caffdd; font-weight: 700; }
.size-choices button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (orientation: landscape) {
  body.touch-match #touch .touch-right { grid-template-columns: repeat(2, max-content); grid-template-rows: auto auto; width: max-content; height: auto; }
  body.touch-match #touch .tbtn, body.touch-match #touch .joy { --unit: max(44px, calc(clamp(52px, 15vh, 68px) * var(--ts, 1))); --secondary: max(44px, calc(var(--unit) * .72)); }
  body.touch-match #touch .touch-left .tbtn { width: var(--unit); height: var(--unit); }
}
@media (orientation: landscape) and (max-width: 650px) {
  body.touch-match #touch .tbtn, body.touch-match #touch .joy { --unit: max(44px, calc(clamp(48px, 15vh, 58px) * var(--ts, 1))); }
}
@media (orientation: portrait) {
  #touch .joy, #touch .tbtn { --tb: clamp(44px, calc(clamp(44px, 12vw, 60px) * var(--ts, 1)), calc((100vw - 56px) / 4.8)); }
  #touch.basic-mode .touch-right, #touch:not(.basic-mode) .touch-right { display: grid; grid-template-columns: repeat(2, max-content); grid-template-rows: auto auto; gap: 8px; width: max-content; height: auto; align-items: center; justify-items: center; }
  #touch .touch-right .tbtn { position: relative; inset: auto; min-width: 0; }
  #touch .tbtn-shift { grid-column: 1; grid-row: 1; }
  #touch .tbtn-super { grid-column: 2; grid-row: 1; }
  #touch .tbtn-jump { grid-column: 1; grid-row: 2; }
  #touch .tbtn-kick { grid-column: 2; grid-row: 2; }
  #touch:not(.basic-mode) .touch-left { flex-direction: column; }
}

/* Celular: todo botón tocable mide al menos 44 px de alto. */
@media (pointer: coarse) {
  .screen button:not(.char), .aid-chip, .training-result button { min-height: 44px; }
}
/* Práctica en celular horizontal: el chip del rival baja para no quedar bajo la guía. */
@media (orientation: landscape) {
  body.training.touch-match .rival-power { top: calc(58px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); }
}
#scr-training, #scr-training.screen { padding-top: max(64px, calc(env(safe-area-inset-top) + 58px)); }

/* ---------- Copa vs CPU ---------- */
.cup-stage { margin: 0; font-family: var(--display); font-size: calc(var(--u) * 2.6); letter-spacing: 0.08em; color: var(--accent); text-align: center; }
.cup-stage.champ { font-size: calc(var(--u) * 6); color: #ffe14d; text-shadow: 0 0 24px rgba(255,210,63,0.7), 0 4px 0 #7a4d00; animation: bump .6s cubic-bezier(.2,1.8,.4,1); }
.cup-stage.out { color: var(--hot); }
.cup-bracket { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: calc(var(--u) * 2.4); width: min(100%, 900px); }
.cup-col { display: flex; flex-direction: column; gap: calc(var(--u) * 2); }
.cup-label { font-family: var(--display); font-size: calc(var(--u) * 1.8); letter-spacing: 0.12em; color: var(--muted); text-align: center; }
.cup-match { background: var(--panel); border: 2px solid var(--panel-border); border-radius: 14px; overflow: hidden; }
.cup-match.next { border-color: var(--accent); box-shadow: 0 0 22px rgba(255,210,63,0.35); }
.cup-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-family: var(--display); font-size: calc(var(--u) * 2.3); letter-spacing: 0.04em; }
.cup-row + .cup-row { border-top: 1px solid var(--panel-border); }
.cup-row img.cup-head { width: calc(var(--u) * 4); min-width: 26px; aspect-ratio: 1; object-fit: contain; }
.cup-row .cup-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cup-row .cup-score { min-width: 1.4em; text-align: right; color: var(--muted); }
.cup-row.me .cup-name { color: var(--accent2); }
.cup-row.win .cup-score { color: #7dff8f; }
.cup-row.lose { opacity: 0.45; }
.cup-row.tbd .cup-name { color: var(--muted); }
.cup-trophy { font-size: calc(var(--u) * 7); text-align: center; line-height: 1; }
#scr-cup .end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--u) * 1.6); }
#scr-cup #btn-cup-play { min-width: min(320px, 60vw); }
@media (max-height: 460px) {
  #scr-cup .screen-title { font-size: 24px; }
  .cup-stage { font-size: 18px; } .cup-stage.champ { font-size: 34px; }
  .cup-row { font-size: 16px; padding: 3px 10px; }
  .cup-trophy { font-size: 46px; }
}

/* ---------- Próximamente ---------- */
.btn-soon { border-color: rgba(201,160,255,0.55); box-shadow: 0 0 16px rgba(201,160,255,0.25); }
.soon-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(var(--u) * 2); width: min(100%, 1200px); }
.soon-card { --sc: var(--accent); position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; align-items: center; text-align: center; gap: calc(var(--u) * 0.8);
  padding: calc(var(--u) * 2) calc(var(--u) * 1.4) calc(var(--u) * 2.2); border-radius: 20px; cursor: default;
  background: linear-gradient(170deg, color-mix(in srgb, var(--sc) 30%, #1c2560) 0%, rgba(14,18,46,0.96) 65%);
  border: 2px solid color-mix(in srgb, var(--sc) 45%, transparent);
  animation: soonPulse 3.2s ease-in-out infinite; animation-delay: var(--d, 0s); }
.soon-card::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--sc); box-shadow: 0 0 16px var(--sc); }
/* Brillo que cruza la tarjeta de a ratos */
.soon-card::before { content: ''; position: absolute; inset: -20%; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, color-mix(in srgb, var(--sc) 22%, transparent) 50%, transparent 60%);
  transform: translateX(-70%); animation: soonShine 4.5s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes soonPulse { 0%, 100% { box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 0 0 color-mix(in srgb, var(--sc) 0%, transparent); }
  50% { box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 0 26px color-mix(in srgb, var(--sc) 40%, transparent); } }
@keyframes soonShine { 0%, 55% { transform: translateX(-70%); } 85%, 100% { transform: translateX(70%); } }
.soon-badge { font-family: var(--display); font-size: calc(var(--u) * 1.6); letter-spacing: 0.12em; text-transform: uppercase; padding: 0.15em 0.8em 0.05em; border-radius: 999px; background: var(--sc); color: #10142e; }
.soon-icon { font-size: calc(var(--u) * 6.5); line-height: 1.1; filter: drop-shadow(0 6px 8px rgba(0,0,0,0.5)); }
.soon-title { margin: 0; font-family: var(--display); font-weight: 400; font-size: calc(var(--u) * 3); letter-spacing: 0.05em; text-shadow: 0 3px 0 color-mix(in srgb, var(--sc) 55%, #000); }
.soon-text { margin: 0; color: var(--muted); font-size: calc(var(--u) * 1.5); }
.soon-tag { margin-top: auto; font-size: calc(var(--u) * 1.25); font-weight: 600; letter-spacing: 0.03em; color: var(--sc); border: 1px solid color-mix(in srgb, var(--sc) 50%, transparent); border-radius: 8px; padding: 2px 8px; background: rgba(5,8,24,0.5); }
/* Tarjeta misterio: oscura, silueta de cabezón y signos de pregunta */
.soon-card.mystery { background: linear-gradient(170deg, #1a1530 0%, #07060f 70%); border-style: dashed; }
.soon-card.mystery .soon-title { color: #b9a6e6; }
.soon-silhouette { position: relative; width: calc(var(--u) * 7.5); min-width: 52px; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2a2240, #05040a 75%); box-shadow: 0 calc(var(--u) * 3.4) 0 calc(var(--u) * -1.6) #05040a, inset 0 0 0 2px rgba(201,160,255,0.25); }
.soon-silhouette span { position: absolute; font-family: var(--display); color: var(--sc); text-shadow: 0 0 10px var(--sc); animation: soonFloat 2.4s ease-in-out infinite; }
.soon-silhouette span:nth-child(1) { left: 38%; top: 18%; font-size: calc(var(--u) * 4); }
.soon-silhouette span:nth-child(2) { left: -12%; top: 4%; font-size: calc(var(--u) * 2.2); animation-delay: .6s; opacity: .7; }
.soon-silhouette span:nth-child(3) { right: -14%; top: 30%; font-size: calc(var(--u) * 2.6); animation-delay: 1.2s; opacity: .8; }
@keyframes soonFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .soon-card, .soon-card::before, .soon-silhouette span { animation: none; } }
/* Celular / pantallas angostas: 2 por fila */
@media (max-width: 600px) and (orientation: portrait) { .soon-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-height: 460px) {
  .soon-cards { gap: 8px; }
  .soon-card { padding: 8px 10px 10px; gap: 2px; border-radius: 14px; }
  .soon-icon { font-size: 30px; } .soon-silhouette { width: 40px; min-width: 40px; }
  .soon-title { font-size: clamp(15px, 2.6vw, 20px); } .soon-text { font-size: 12px; } .soon-badge { font-size: 12px; } .soon-tag { font-size: 10px; }
}

/* Elegí el modo: las 5 tarjetas en una sola fila en pantallas apaisadas (antes ENTRENAMIENTO quedaba solo abajo y empujaba la ayuda). */
@media (orientation: landscape) {
  .mode-cards { flex-wrap: nowrap; max-width: 100%; }
  .mode-card { flex: 0 1 calc(var(--u) * 22); min-width: 0; }
  .mode-card .mc-title { font-size: min(calc(var(--u) * 3.4), 2.6vw); white-space: nowrap; }
}

/* ---------- Lobby online ---------- */
/* Fondo oscurecido como en Elegí el modo: los carteles del partido de fondo no se mezclan con la sala */
#scr-online, #scr-lobby { background: radial-gradient(ellipse at center, rgba(7,10,28,0.66), rgba(7,10,28,0.92)); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
/* ¡LISTO! siempre a la vista, aunque la sala no entre en la pantalla (celulares chicos) */
#scr-lobby .select-actions { position: sticky; bottom: max(6px, env(safe-area-inset-bottom)); z-index: 3; }
#scr-lobby #btn-ready { box-shadow: 0 6px 18px rgba(0,0,0,0.55), 0 0 0 3px rgba(7,10,28,0.6); }
/* Modo y cancha bloqueados (los elige el anfitrión): que se note que no se pueden tocar */
#scr-lobby .pu-toggle:disabled { opacity: 0.5; filter: saturate(0.5); box-shadow: none; }
.lobby-host-note { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
/* Al cambiar solo el estado (LISTO / eligiendo) las barras no se vuelven a animar */
.stats.still .bar i.on { animation: none; }
@media (max-height: 460px) {
  #scr-lobby .lobby-head { display: flex; align-items: center; justify-content: center; gap: 12px; }
  #scr-lobby #btn-invite { padding: 0.25em 0.8em 0.15em; font-size: 15px; }
  .lobby-host-note { display: none; }
  #scr-lobby .select-actions { flex-wrap: nowrap; gap: 8px; }
  #scr-lobby .select-actions .btn { font-size: 15px; padding: 0.3em 0.8em 0.2em; white-space: nowrap; }
}
/* Celular chico: el botón de sonido tapaba ¡LISTO! (se puede silenciar desde el título) */
@media (max-height: 460px) and (max-width: 700px) { body:has(#scr-lobby.active) #btn-mute { display: none; } }
