/* ════════════════════════════════════════════════════════════════════
   ORBITAL SIEGE — Selección de piloto y nave (estilo arcade juguetón)
   Contornos gruesos, sombras duras, franja diagonal con el color del
   personaje y un único momento de impacto al cambiar de personaje.
   ════════════════════════════════════════════════════════════════════ */
:root {
  --font-display: 'Lilita One', 'Baloo 2', system-ui, sans-serif;
  --font-ui:      'Baloo 2', system-ui, sans-serif;
  --night:  #1a1145;      /* fondo */
  --outline:#140b33;      /* contornos y sombras duras */
  --cream:  #fff6e0;      /* texto */
  --go:     #ffd23f;      /* acción principal */
  --sky:    #62e3ff;
  --acc:    #ff5454;      /* color del personaje (lo cambia JS) */
  --ink: var(--cream);
  --ink-dim: #b9b0e0;
}
body { background: var(--night); }

/* ── Estructura ── */
#app.sel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(4px, 1.4vh, 14px);
  overflow: hidden;
}
.sel-screen { display: none; min-height: 0; position: relative; z-index: 2; }
.sel-screen.active { display: grid; }

/* ── Franja diagonal del personaje ── */
.slab-wrap { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.slab {
  position: absolute; inset: 0;
  background: var(--acc);
  clip-path: polygon(0 18%, 62% 0, 100% 0, 100% 34%, 42% 100%, 0 100%);
  opacity: 0.9;
  transition: background .3s;
}
.slab::before {   /* rayas de cómic sobre la franja */
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(-58deg, rgba(255,255,255,0.13) 0 14px, transparent 14px 46px);
}
.slab::after {    /* borde oscuro que la recorta como un sticker */
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 30% 60%, transparent 55%, rgba(20,11,51,0.55));
}
.slab-in { animation: slabWipe .5s cubic-bezier(.2,.9,.25,1) both; }
@keyframes slabWipe {
  from { clip-path: polygon(0 18%, 0 18%, 0 18%, 0 34%, 0 100%, 0 100%); }
  to   { clip-path: polygon(0 18%, 62% 0, 100% 0, 100% 34%, 42% 100%, 0 100%); }
}
#bg-canvas { opacity: 0.8; }

/* ── Cabecera: logo + pasos ── */
/* Logo y pasos a la izquierda: la derecha queda libre para la barra de sugerencias/sesión */
.sel-top { display: flex; align-items: center; justify-content: flex-start; gap: clamp(16px, 4vw, 56px); position: relative; z-index: 3; }
.sel-logo {
  display: flex; flex-direction: column; line-height: .82;
  font-family: var(--font-display); font-size: clamp(22px, 4.4vh, 38px); color: var(--cream);
  transform: rotate(-4deg); transform-origin: left center;
  -webkit-text-stroke: 5px var(--outline); paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--outline);
}
.sel-logo span:last-child { color: var(--go); margin-left: .6em; }
.sel-steps { display: flex; gap: 8px; list-style: none; }
.step-pill {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px; padding: 4px 14px 4px 6px; border-radius: 999px; cursor: pointer;
  font-family: var(--font-display); font-size: clamp(13px, 2.2vh, 17px); color: var(--ink-dim);
  background: rgba(20,11,51,0.6); border: 3px solid var(--outline);
  transition: transform .15s, background .15s, color .15s;
}
.step-pill .num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,0.12); color: var(--cream); font-size: 14px;
}
.step-pill.done { color: var(--cream); }
.step-pill.done .num { background: var(--sky); color: var(--outline); }
.step-pill.active { background: var(--cream); color: var(--outline); transform: translateY(-2px); box-shadow: 0 4px 0 var(--outline); }
.step-pill.active .num { background: var(--acc); color: var(--outline); }
.step-pill:focus-visible, .tile:focus-visible, .cta:focus-visible, .chip-btn:focus-visible, .pk-namefield input:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }

/* ── Pantalla de selección ── */
.picker {
  grid-template-columns: minmax(0, 1fr) clamp(250px, 30vw, 380px);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "stage card" "roster actions";
  column-gap: clamp(12px, 3vw, 40px); row-gap: clamp(6px, 1.6vh, 16px);
}
.pk-stage { grid-area: stage; position: relative; min-height: 0; }
.pk-title { position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; max-width: 70%; }
.pk-role {
  display: inline-block; padding: 2px 12px; border-radius: 8px; margin-bottom: 4px;
  font-family: var(--font-display); font-size: clamp(13px, 2.2vh, 18px); color: var(--outline);
  background: var(--cream); box-shadow: 0 3px 0 var(--outline); transform: rotate(-3deg);
}
.pk-name {
  font-family: var(--font-display); font-weight: 400; line-height: .95;
  font-size: clamp(36px, 10vh, 92px); color: var(--cream);
  transform: rotate(-4deg); transform-origin: left bottom;
  -webkit-text-stroke: clamp(5px, 1vh, 9px) var(--outline); paint-order: stroke fill;
  text-shadow: 0 clamp(4px, .9vh, 8px) 0 var(--outline);
}
.pk-name.slam { animation: nameSlam .42s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes nameSlam {
  0%   { transform: rotate(-4deg) translateX(-40px) scale(1.5); opacity: 0; }
  60%  { transform: rotate(-4deg) translateX(0) scale(.94); opacity: 1; }
  100% { transform: rotate(-4deg) scale(1); }
}

/* Plataforma giratoria bajo el héroe */
.pad {
  /* Disco visto en perspectiva: un círculo aplastado (así el anillo gira centrado) */
  position: absolute; left: 50%; bottom: calc(4% - min(29%, 26vh)); transform: translateX(-50%) scaleY(.32);
  width: min(58%, 52vh); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255,255,255,0.35), rgba(255,255,255,0.06) 70%, transparent),
              var(--outline);
  border: 8px solid var(--outline);
  box-shadow: 0 24px 0 rgba(20,11,51,0.7), 0 0 0 10px var(--acc) inset;
}
.pad-ring {
  position: absolute; inset: 10%; border-radius: 50%;
  border: 8px dashed rgba(255,246,224,0.55);
  animation: padSpin 9s linear infinite;
}
@keyframes padSpin { to { transform: rotate(360deg); } }

/* Héroe */
.hero-slot { position: absolute; inset: 6% 8% 9%; z-index: 3; }
.hero {
  position: absolute; inset: 0; isolation: isolate;
  filter: drop-shadow(0 10px 0 rgba(20,11,51,0.55));
  animation: heroIdle 2.4s ease-in-out infinite;
}
.hero-img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
.hero-tint {
  position: absolute; inset: 0; background: var(--acc); mix-blend-mode: multiply; pointer-events: none;
  -webkit-mask: var(--src) center / contain no-repeat; mask: var(--src) center / contain no-repeat;
}
.is-ship .hero-slot { inset: 22% 4% 4%; }   /* la nave flota justo sobre la plataforma */
.is-ship.hero { inset: 0 -4%; }
@keyframes heroIdle { 0%,100% { translate: 0 0; } 50% { translate: 0 -10px; } }
.hero.enter { animation: heroDrop .62s cubic-bezier(.3,1.5,.5,1) both, heroIdle 2.4s ease-in-out .62s infinite; transform-origin: 50% 100%; }
@keyframes heroDrop {
  0%   { transform: translateY(-70%) scale(.7, 1.2); opacity: 0; }
  45%  { transform: translateY(0) scale(1.18, .82); opacity: 1; }
  70%  { transform: translateY(-4%) scale(.95, 1.06); }
  100% { transform: none; }
}
.hero.leave { animation: heroLeave .26s ease-in both; }
@keyframes heroLeave { to { transform: translateX(calc(var(--dir, 1) * -60%)) rotate(calc(var(--dir, 1) * -14deg)) scale(.6); opacity: 0; } }

/* Confeti */
.burst { position: absolute; left: 50%; top: 55%; z-index: 5; pointer-events: none; }
.burst i {
  position: absolute; width: 16px; height: 16px; opacity: 0; background: var(--c);
  clip-path: polygon(50% 0, 62% 38%, 100% 38%, 69% 60%, 80% 100%, 50% 75%, 20% 100%, 31% 60%, 0 38%, 38% 38%);
}
.burst.go i { animation: starPop .8s cubic-bezier(.15,.8,.3,1) both; }
@keyframes starPop {
  0%   { transform: translate(0, 0) scale(0) rotate(0); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translate(var(--x), var(--y)) scale(var(--s)) rotate(var(--r)); opacity: 0; }
}

/* Ficha de estadísticas */
.pk-card {
  grid-area: card; align-self: center; position: relative; z-index: 3;
  display: flex; flex-direction: column; gap: clamp(6px, 1.4vh, 12px);
  padding: clamp(10px, 2vh, 18px); border-radius: 20px;
  background: var(--cream); color: var(--outline);
  border: 4px solid var(--outline); box-shadow: 0 8px 0 var(--outline);
  transform: rotate(1.2deg);
}
.card-bars { display: flex; flex-direction: column; gap: clamp(3px, .8vh, 7px); }
.bar { display: grid; grid-template-columns: minmax(80px, 42%) 1fr; align-items: center; gap: 8px; }
.bar-k { font-weight: 800; font-size: clamp(13px, 2vh, 16px); line-height: 1.1; }
.bar-v { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.bar-v i {
  height: clamp(10px, 1.8vh, 14px); border-radius: 4px; background: rgba(20,11,51,0.12);
  border: 2px solid rgba(20,11,51,0.2);
}
.bar-v i.on { background: var(--acc); border-color: var(--outline); animation: barFill .35s calc(var(--i) * 45ms) both cubic-bezier(.3,1.6,.5,1); }
@keyframes barFill { from { transform: scaleY(0); } to { transform: none; } }
.perk { display: flex; gap: 10px; align-items: flex-start; }
.perk-ic {
  flex-shrink: 0; width: clamp(34px, 6vh, 44px); height: clamp(34px, 6vh, 44px); border-radius: 12px;
  display: grid; place-items: center; color: var(--outline);
  background: var(--sky); border: 3px solid var(--outline);
}
.perk-skill .perk-ic { background: var(--go); }
.perk-ic svg { width: 60%; height: 60%; }
.perk b { display: block; font-family: var(--font-display); font-weight: 400; font-size: clamp(15px, 2.4vh, 20px); line-height: 1.1; }
.perk b em { font-family: var(--font-ui); font-style: normal; font-weight: 700; font-size: .7em; color: #6a5e98; margin-left: 4px; }
.perk span { display: block; font-size: clamp(13px, 2vh, 16px); line-height: 1.25; font-weight: 600; color: #3e3470; }

/* Fila de retratos */
.pk-roster { grid-area: roster; display: flex; gap: clamp(8px, 1.4vw, 14px); align-items: flex-end; z-index: 3; }
.tile {
  position: relative; width: clamp(62px, 13vh, 104px); padding: 0; cursor: pointer;
  border-radius: 16px; border: 4px solid var(--outline); background: var(--tc);
  box-shadow: 0 5px 0 var(--outline); overflow: hidden;
  transition: transform .15s cubic-bezier(.3,1.6,.5,1), box-shadow .15s;
  -webkit-tap-highlight-color: transparent;
}
.tile::before { /* rayas */
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(-58deg, rgba(255,255,255,0.16) 0 8px, transparent 8px 22px);
}
.tile-art { position: relative; display: block; aspect-ratio: 1; isolation: isolate; }
.tile-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 8%; }
.tile-art.is-ship img { object-fit: contain; object-position: center; transform: scale(1.2); }
.tile-art .hero-tint { background: var(--tc); -webkit-mask-size: cover; mask-size: cover; -webkit-mask-position: 50% 8%; mask-position: 50% 8%; }
.tile-name {
  position: relative; display: block; padding: 2px 4px 4px;
  font-family: var(--font-display); font-size: clamp(11px, 1.9vh, 15px); color: var(--cream);
  background: var(--outline); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile:hover { transform: translateY(-3px); }
.tile[aria-checked="true"] { transform: translateY(-8px) rotate(-3deg); box-shadow: 0 9px 0 var(--outline), 0 0 0 4px var(--cream); }

/* Acciones */
.pk-actions { grid-area: actions; display: flex; gap: 10px; align-items: flex-end; justify-content: flex-end; z-index: 3; flex-wrap: wrap; }
.pk-namefield { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 120px; font-weight: 800; font-size: 14px; color: var(--cream); text-shadow: 0 2px 0 var(--outline); }
.pk-namefield input {
  height: 48px; padding: 0 12px; border-radius: 14px; width: 100%;
  font: 700 18px var(--font-ui); color: var(--outline); background: var(--cream);
  border: 4px solid var(--outline); box-shadow: 0 4px 0 var(--outline) inset;
}
.pk-namefield input[readonly] { opacity: .85; }
.cta {
  min-height: 56px; padding: 6px clamp(16px, 2.4vw, 28px); border-radius: 16px; cursor: pointer;
  font-family: var(--font-display); font-size: clamp(18px, 3.2vh, 26px); color: var(--outline);
  background: var(--go); border: 4px solid var(--outline); box-shadow: 0 7px 0 var(--outline);
  transition: transform .1s, box-shadow .1s, filter .15s; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.cta:hover { filter: brightness(1.06); transform: translateY(-2px); box-shadow: 0 9px 0 var(--outline); }
.cta:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--outline); }
.cta-ghost { background: var(--cream); font-size: clamp(15px, 2.6vh, 20px); }
.cta-alt { background: var(--sky); }
.cta-big { font-size: clamp(22px, 4vh, 32px); min-height: 64px; }

/* ── Despegue (piloto + nave juntos) ── */
.ready { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; gap: clamp(12px, 3vw, 40px); }
.rd-stage { position: relative; height: 100%; min-height: 0; }
.rd-slot { position: absolute; }
.rd-robot { left: 0; bottom: 8%; width: 36%; height: 72%; z-index: 3; }
.rd-ship  { right: 0; top: 10%; width: 66%; height: 66%; z-index: 2; }
.rd-ship .hero { animation: heroIdle 2s ease-in-out infinite; }
.rd-link {   /* rayo que une piloto y nave */
  position: absolute; left: 28%; top: 38%; width: 30%; height: 26%; z-index: 1;
  background: var(--go); border: 4px solid var(--outline);
  clip-path: polygon(0 40%, 55% 25%, 48% 0, 100% 55%, 42% 72%, 50% 100%);
  filter: drop-shadow(0 6px 0 var(--outline));
}
.rd-stage .burst { left: 45%; top: 50%; }
.rd-stage.intro .rd-robot .hero { animation: robotHop .7s cubic-bezier(.3,1.5,.5,1) both, heroIdle 2.4s ease-in-out .7s infinite; transform-origin: 50% 100%; }
.rd-stage.intro .rd-ship .hero  { animation: shipZoom .7s .12s cubic-bezier(.2,1.2,.4,1) both, heroIdle 2s ease-in-out .9s infinite; }
.rd-stage.intro .rd-link        { animation: linkZap .4s .5s cubic-bezier(.3,1.8,.5,1) both; }
@keyframes robotHop { 0% { transform: translateY(40%) scale(.6); opacity: 0; } 55% { transform: translateY(-12%) scale(1.08, .92); opacity: 1; } 100% { transform: none; } }
@keyframes shipZoom { 0% { transform: translateX(80%) scale(.5) rotate(10deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes linkZap  { 0% { transform: scale(0) rotate(-20deg); } 100% { transform: none; } }
.rd-info { display: flex; flex-direction: column; gap: clamp(6px, 1.6vh, 14px); align-items: flex-start; z-index: 3; }
.rd-name { font-size: clamp(34px, 9vh, 80px); max-width: 100%; overflow-wrap: anywhere; }
.rd-load { font-size: clamp(16px, 2.8vh, 22px); font-weight: 700; color: var(--cream); text-shadow: 0 2px 0 var(--outline); }
.rd-load b { font-family: var(--font-display); font-weight: 400; color: var(--go); }
.rd-edit { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  min-height: 40px; padding: 4px 14px; border-radius: 999px; cursor: pointer;
  font: 800 15px var(--font-ui); color: var(--outline); background: var(--cream);
  border: 3px solid var(--outline); box-shadow: 0 4px 0 var(--outline);
}
.chip-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.rd-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: clamp(4px, 1.4vh, 12px); }

/* ── Elementos compartidos del menú con el nuevo estilo ── */
.auth-user, .auth-logout { font-family: var(--font-ui); border: 3px solid var(--outline); background: rgba(20,11,51,0.7); color: var(--cream); }
.auth-inner, .fb-slot { display: contents; }
.auth-bar { top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
.auth-bar .ofb-trigger { font-family: var(--font-ui); border: 3px solid var(--outline); background: var(--cream); color: var(--outline); box-shadow: 0 4px 0 var(--outline); }
.auth-bar .ofb-trigger:hover { color: var(--outline); background: var(--go); border-color: var(--outline); }
.ofb-title, .ofb-send { font-family: var(--font-display) !important; letter-spacing: .5px !important; text-transform: none !important; }
.login-logo { font-family: var(--font-display); -webkit-text-stroke: 4px var(--outline); paint-order: stroke fill; text-shadow: 0 4px 0 var(--outline); }

/* ── Móvil en horizontal (poca altura) ── */
@media (max-height: 500px) {
  .auth-bar .ofb-trigger span { display: none; }   /* solo el icono */
  .auth-bar .ofb-trigger { min-height: 36px; padding: 4px 10px; }
  .sel-logo { font-size: 20px; -webkit-text-stroke-width: 4px; }
  .step-pill { min-height: 32px; font-size: 13px; padding-right: 10px; }
  .step-pill .num { width: 22px; height: 22px; font-size: 12px; }
  .picker { grid-template-columns: minmax(0, 1fr) clamp(220px, 36vw, 300px); }
  .pk-card { padding: 8px 10px; gap: 6px; border-radius: 16px; }
  .perk span { font-size: 12px; }
  .bar-v i { height: 9px; }
  .tile { width: 56px; border-radius: 12px; border-width: 3px; }
  .tile-name { font-size: 10px; }
  .cta { min-height: 46px; font-size: 18px; box-shadow: 0 5px 0 var(--outline); }
  .cta-big { min-height: 50px; font-size: 20px; }
  .pk-namefield { min-width: 100px; font-size: 12px; }
  .pk-namefield input { height: 42px; font-size: 16px; }
  .rd-actions .cta { min-height: 46px; }
}
@media (max-width: 720px) {
  .pk-namefield { display: none; }   /* el nombre llega de Hubmy o del paso anterior */
  .tile-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pad-ring, .hero, .rd-ship .hero { animation: none !important; }
  .bar-v i.on { animation: none; }
}

/* Pantallas estrechas: la barra superior derecha se compacta para no pisar los pasos */
@media (max-width: 1100px) {
  .auth-user { display: none; }          /* tu nombre ya aparece en la selección */
  .auth-bar .ofb-trigger span { display: none; }
}
