/* ============================================================
   LEYENDA — Simulador de Carrera Futbolística
   Tema oscuro deportivo · Mobile-first
   ============================================================ */

:root {
  --color-bg: #07111f;
  --color-surface: #101c2e;
  --color-surface-light: #182840;
  --color-primary: #32d583;
  --color-primary-hover: #28b970;
  --color-accent: #f4c542;
  --color-danger: #f04438;
  --color-info: #38bdf8;
  --color-text: #f8fafc;
  --color-text-secondary: #a9b4c5;
  --color-border: rgba(255, 255, 255, 0.1);
  --color-overlay: rgba(3, 9, 18, 0.78);
  --color-control-border: rgba(255, 255, 255, 0.26);
  --color-primary-soft: rgba(50, 213, 131, 0.12);
  --color-accent-soft: rgba(244, 197, 66, 0.12);
  --color-danger-soft: rgba(240, 68, 56, 0.12);
  --color-info-soft: rgba(56, 189, 248, 0.12);
  --color-control-text: #041a10;
  --color-accent-text: #2d2101;
  --color-danger-deep: #7f1d1d;
  --color-error-surface: #7f1d1d;
  --color-white: #ffffff;
  --color-black-shadow: rgba(0, 0, 0, 0.28);

  /* Alias semánticos para componentes existentes. */
  --bg: var(--color-bg);
  --bg-soft: #0b1728;
  --card: var(--color-surface);
  --card-2: var(--color-surface-light);
  --border: var(--color-border);
  --control-border: var(--color-control-border);
  --text: var(--color-text);
  --text-dim: var(--color-text-secondary);
  --text-faint: #8492a8;
  --accent: var(--color-primary);
  --accent-dark: var(--color-primary-hover);
  --accent-soft: var(--color-primary-soft);
  --gold: var(--color-accent);
  --gold-soft: var(--color-accent-soft);
  --red: var(--color-danger);
  --blue: var(--color-info);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --control-height: 48px;
  --control-height-lg: 54px;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-card: 0 8px 24px var(--color-black-shadow);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --ease-out: cubic-bezier(0.2, 0.7, 0.25, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
.ui-icon { display: inline-block; width: 1.15em; text-align: center; }
.ui-icon + .ui-icon { margin-left: 0.12em; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;                        /* el shell nunca scrollea */
  overscroll-behavior: none;               /* sin rebote ni pull-to-refresh */
  touch-action: manipulation;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  color-scheme: dark;
}

body {
  position: fixed; inset: 0;               /* anti-rebote iOS: el body no se mueve */
  background: var(--bg);
  color: var(--text);
  font-family: "Poppins", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5;
  background-image:
    radial-gradient(ellipse 80% 45% at 50% -20%, var(--color-primary-soft), transparent),
    linear-gradient(180deg, var(--color-bg), #081525 70%, var(--color-bg));
}

/* Única zona de scroll: ocupa exactamente el viewport visible */
#app {
  width: 100%; max-width: 760px; margin: 0 auto;
  height: 100dvh; min-height: 100svh;
  display: flex; flex-direction: column;
  overflow: hidden;
}

#app-foot {
  display: none;
}

/* ---------- Pantallas ---------- */
.screen {
  display: none; flex: 1 1 auto; min-height: 0; width: 100%; overflow: hidden;
  padding: calc(16px + var(--sat)) calc(14px + var(--sar)) calc(16px + var(--sab)) calc(14px + var(--sal));
  animation: screenIn 0.24s var(--ease-out);
}
.screen.active { display: flex; flex-direction: column; }
.screen[hidden] { display: none !important; }

.screen > .container {
  width: 100%; min-height: 0; flex: 1; overflow-y: auto; overflow-x: clip;
  overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--control-border) transparent;
  padding: 2px 2px 8px;
}
.screen > .container::-webkit-scrollbar { width: 5px; }
.screen > .container::-webkit-scrollbar-thumb { background: var(--control-border); border-radius: 999px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.storage-warning {
  position: fixed; z-index: 100; left: max(12px, var(--sal)); right: max(12px, var(--sar));
  bottom: calc(12px + var(--sab)); max-width: 620px; margin: 0 auto;
  padding: 12px 44px 12px 16px; border-radius: var(--radius-sm); color: var(--color-white);
  background: var(--color-error-surface); border: 1px solid var(--color-danger); box-shadow: var(--shadow-card);
  font-size: 0.875rem; line-height: 1.45;
}
.storage-warning.success { background: var(--color-surface); border-color: var(--accent); }
.storage-warning button {
  position: absolute; top: 6px; right: 6px; width: 36px; height: 36px;
  border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer;
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Entrada escalonada de tarjetas: sutil, transform+opacity (GPU) */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.fx-stagger > * { animation: riseIn 0.38s var(--ease-out) both; }
.fx-stagger > *:nth-child(2) { animation-delay: 0.04s; }
.fx-stagger > *:nth-child(3) { animation-delay: 0.08s; }
.fx-stagger > *:nth-child(4) { animation-delay: 0.12s; }
.fx-stagger > *:nth-child(5) { animation-delay: 0.16s; }
.fx-stagger > *:nth-child(6) { animation-delay: 0.20s; }
.fx-stagger > *:nth-child(7) { animation-delay: 0.24s; }
.fx-stagger > *:nth-child(n+8) { animation-delay: 0.28s; }

/* Canvas de partículas (confetti) */
#fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

/* Pestaña oculta: congelar TODA animación CSS (batería) */
.fx-paused *, .fx-paused *::before, .fx-paused *::after { animation-play-state: paused !important; }

.container { max-width: 640px; margin: 0 auto; }

.screen-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 16px; }
.screen-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.screen-topline .screen-title { margin-bottom: 12px; }

/* ---------- Inicio ---------- */
#screen-home { display: none; text-align: center; }
#screen-home.active { display: flex; flex-direction: column; justify-content: center; overflow-y: auto; }

.home-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; min-width: 0; }
.home-inner > * { max-width: 100%; }

.home-ball { font-size: 3.4rem; animation: bounce 2.2s ease infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-14px) rotate(4deg); }
}

.home-title {
  font-size: 3rem; font-weight: 800; letter-spacing: 0.12em;
  background: linear-gradient(135deg, #f4f4f5 30%, var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(34, 197, 94, 0.22));
}

.home-tagline { align-self: stretch; color: var(--accent); font-weight: 600; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; overflow-wrap: anywhere; }
.home-desc { align-self: stretch; color: var(--text-dim); font-size: 1rem; line-height: 1.55; margin-bottom: 8px; overflow-wrap: anywhere; }
.home-foot { margin-top: 22px; color: var(--text-faint); font-size: 0.875rem; }
.home-secondary-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.home-minigames { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; min-height: 40px; color: var(--gold); border-color: rgba(250,204,21,0.35); }
.home-minigames small { padding-left: 8px; border-left: 1px solid var(--control-border); color: var(--text-faint); font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.home-save-card {
  width: min(100%, 420px); text-align: center; padding: 16px;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--border);
}
.home-save-player { display: flex; align-items: center; justify-content: center; gap: 10px; }
.home-save-player strong { min-width: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.home-save-ovr {
  display: inline-flex; align-items: baseline; gap: 4px; margin: 0; padding: 4px 8px;
  color: var(--color-control-text); background: var(--accent); border-radius: 999px;
}
.home-save-ovr b { font-size: 1rem; line-height: 1; }
.home-save-ovr small { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.home-save-club { display: flex; align-items: center; justify-content: center; gap: 2px; margin-top: 9px; font-size: 0.95rem; font-weight: 600; }
.home-save-club .mini-logo { margin-right: 4px; }
.home-save-meta { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 3px; color: var(--text-dim); font-size: 0.875rem; }

/* ---------- Botones ---------- */
.btn {
  font-family: inherit; font-weight: 600; border: none; cursor: pointer;
  min-height: var(--control-height); border-radius: 999px; padding: 12px 24px; font-size: 1rem;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:where(button, input, select, [tabindex]):focus-visible {
  outline: 3px solid var(--gold); outline-offset: 3px;
}
:where(.screen, .step-title, .block-title, .event-title)[tabindex="-1"]:focus { outline: none; }

.btn-primary {
  background: var(--color-primary); color: var(--color-control-text);
  box-shadow: 0 4px 14px rgba(50, 213, 131, 0.22);
}
.btn-gold {
  background: var(--color-accent); color: var(--color-accent-text);
  box-shadow: 0 4px 14px rgba(244, 197, 66, 0.20);
}
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--control-border); }

.btn-lg { min-height: var(--control-height-lg); padding: 14px 32px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.875rem; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Tarjetas / formularios ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.field { display: block; margin-bottom: 18px; }
.fieldset-reset { border: 0; min-width: 0; }
.field-label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--text-dim); letter-spacing: 0.02em; margin-bottom: 8px; }
.field-hint { font-size: 0.875rem; color: var(--text-faint); margin-bottom: 10px; }

#screen-setup .screen-title,
#screen-setup .step-title,
#screen-setup .field-label,
#screen-setup .field-hint { text-align: center; }
#screen-setup .screen-title { flex: 1; margin-left: 44px; }
#screen-setup input,
#screen-setup select { text-align: center; text-align-last: center; }
#screen-setup .pills { justify-content: center; }
#screen-setup .start-path { text-align: center; }
#screen-setup .starter-picker-head { justify-content: center; }
#screen-setup .club-card > div:nth-child(2) { flex: 1; text-align: center; }

.field-row { display: grid; grid-template-columns: 110px 1fr; gap: 14px; }

input[type="text"], input[type="number"], select {
  width: 100%; background: var(--bg-soft); border: 1px solid var(--control-border);
  color: var(--text); border-radius: var(--radius-sm); padding: 12px 14px;
  font-family: inherit; font-size: 1rem; outline: none;
  transition: border-color 0.15s ease;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }

/* Badge de club con logo real (la imagen tapa las iniciales) */
.club-badge { position: relative; overflow: hidden; }
.club-badge img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #ffffff; border-radius: 50%;
  padding: 4px; box-sizing: border-box;
}
.mini-logo {
  width: 20px; height: 20px; object-fit: contain;
  vertical-align: -4px; margin-right: 6px;
}

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  background: var(--bg-soft); border: 1px solid var(--control-border); color: var(--text-dim);
  border-radius: 999px; padding: 9px 16px; font-family: inherit; font-size: 0.85rem;
  font-weight: 500; cursor: pointer; transition: all 0.15s ease;
}
.pill.selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,0.12); }

/* ---------- Apariencia del jugador ---------- */
.appearance-preview {
  width: min(100%, 360px); margin: 0 auto 16px; padding: 12px;
  background: linear-gradient(#173b31 0 50%, #20513c 50%); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.appearance-preview canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.appearance-club { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 24px; margin: -8px 0 14px; font-size: 0.82rem; }
.appearance-club .mini-logo { margin-right: 0; }
.kit-swatch { width: 14px; height: 14px; border-radius: 50%; background: var(--kit); border: 1px solid rgba(255,255,255,0.35); }
.appearance-label { line-height: 1.8; }
.appearance-label output {
  display: inline-block; min-width: 72px; margin-left: 6px; padding: 1px 9px;
  color: var(--gold); background: var(--gold-soft); border: 1px solid rgba(250,204,21,0.35); border-radius: 999px;
}
.appearance-hairs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-width: 380px; margin: 0 auto; }
.appearance-hair {
  position: relative; min-width: 0; padding: 7px 4px 6px; color: var(--text-dim); background: var(--bg-soft);
  border: 1px solid var(--control-border); border-radius: 14px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.appearance-hair:active { transform: scale(0.96); }
.appearance-hair canvas { display: block; width: 50px; height: 57px; margin: 0 auto 2px; image-rendering: pixelated; }
.appearance-hair-name { display: block; font-family: inherit; font-size: 0.68rem; font-weight: 700; }
.appearance-hair.selected { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px rgba(34,197,94,0.15); }
.appearance-colors { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.appearance-color {
  position: relative; width: 42px; height: 42px; padding: 0; border-radius: 12px; cursor: pointer;
  background: var(--swatch); border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--control-border);
  transition: transform 0.12s, box-shadow 0.15s;
}
.appearance-color:active { transform: scale(0.92); }
.appearance-color.selected { box-shadow: 0 0 0 3px var(--gold); }
.appearance-check {
  display: none; position: absolute; top: 3px; right: 5px; z-index: 2;
  color: #fff; font-size: 0.72rem; font-weight: 900; text-shadow: 0 1px 3px #000;
}
.selected > .appearance-check { display: block; }
#appearance-boots { display: grid; grid-template-columns: repeat(4, 52px); gap: 9px; }
.appearance-boot {
  width: 52px; height: 46px; border-radius: 12px; background: var(--bg-soft); border: 1px solid var(--control-border); box-shadow: none;
}
.appearance-boot.selected { border-color: var(--gold); background: var(--gold-soft); box-shadow: 0 0 0 2px rgba(250,204,21,0.18); }
.boot-shape {
  display: block; width: 37px; height: 26px; margin: 8px auto 0; background: var(--swatch);
  clip-path: polygon(8% 5%, 58% 5%, 62% 48%, 90% 63%, 96% 90%, 22% 90%, 5% 70%);
  filter: drop-shadow(0 1px 0 rgba(255,255,255,0.32)) drop-shadow(0 2px 2px rgba(0,0,0,0.45));
}
@media (max-width: 340px) {
  .appearance-hairs { grid-template-columns: repeat(3, 1fr); }
  .appearance-hair canvas { width: 56px; height: 64px; }
}

/* ---------- Selector de posición sobre la cancha ---------- */
.pitch-wrap { margin-top: 4px; }
.pitch {
  position: relative; width: 100%; max-width: 340px; margin: 0 auto;
  /* En pantallas bajas la altura manda: la cancha nunca empuja el paso 2
     fuera del viewport (fallback: la línea de arriba en browsers viejos) */
  max-width: min(340px, 44dvh);
  padding-top: 133.33%;                       /* 3:4 — más compatible que aspect-ratio */
  background: repeating-linear-gradient(180deg, #14532d 0 12.5%, #166534 12.5% 25%);
  border: 2px solid rgba(255,255,255,0.22); border-radius: 10px; overflow: hidden;
}
.pitch-half { position: absolute; left: 0; right: 0; top: 50%; border-top: 2px solid rgba(255,255,255,0.18); }
.pitch-circle {
  position: absolute; left: 50%; top: 50%; width: 34%; padding-top: 25.5%;
  transform: translate(-50%, -50%); border: 2px solid rgba(255,255,255,0.18); border-radius: 50%;
}
.pitch-area { position: absolute; left: 22%; width: 56%; height: 13%; border: 2px solid rgba(255,255,255,0.18); }
.pitch-area-top { top: 0; border-top: 0; border-radius: 0 0 4px 4px; }
.pitch-area-bot { bottom: 0; border-bottom: 0; border-radius: 4px 4px 0 0; }

.pos-dot {
  position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%);
  transform: translate(-50%, -50%);
  /* Ancho FIJO, no min-width: con min-width los nombres largos ("Carrilero
     izquierdo") ensanchan la ficha y la sacan del campo. */
  width: 52px; min-height: 44px; padding: 6px 3px; border-radius: 8px; font-family: inherit;
  background: var(--color-overlay); border: 1px solid var(--color-control-border);
  color: var(--text); font-weight: 700; font-size: 0.72rem; line-height: 1.15;
  text-align: center; cursor: pointer; transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.pos-dot:focus-visible { border-color: var(--gold); color: var(--gold); outline: none; z-index: 2; }
.pos-dot.selected {
  background: var(--accent); color: #052e16; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.30); z-index: 3;
}
.pos-dot .pos-name { display: none; }        /* en móvil solo el código; el nombre va en el caption */

.pitch-caption {
  text-align: center; font-size: 0.82rem; color: var(--text-dim);
  margin-top: 10px; min-height: 1.3em;
}
.pitch-caption b { color: var(--accent); }

@media (min-width: 640px) {
  .pos-dot { width: 64px; }
  .pos-dot .pos-name {
    display: block; font-size: 0.54rem; font-weight: 400; color: var(--text-dim);
    margin-top: 1px; word-break: break-word;   /* que envuelva, nunca que ensanche */
  }
  .pos-dot.selected .pos-name { color: #064e3b; }
}
@media (max-width: 340px) {
  .pitch { max-width: 100%; max-width: min(100%, 44dvh); }
  .pos-dot { width: 44px; min-height: 44px; font-size: 0.66rem; padding: 5px 2px; }
}

/* Pantallas bajas (iPhone SE, landscape): el paso 2 entra sin scroll */
@media (max-height: 600px) {
  .pitch { max-width: min(300px, 42dvh); }
  #screen-setup .field-hint { display: none; }
  #screen-setup .step-title { margin-bottom: 8px; }
  .steps-dots { margin-bottom: 12px; }
  .pitch-caption { margin-top: 6px; }
}
@media (prefers-reduced-motion: reduce) { .pos-dot { transition: none; } }

.club-cards { display: flex; flex-direction: column; gap: 8px; }
.start-paths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.start-path {
  min-width: 0; min-height: 78px; padding: 11px 12px; text-align: left;
  font-family: inherit; color: var(--text); cursor: pointer;
  background: var(--bg-soft); border: 1px solid var(--control-border); border-radius: var(--radius-sm);
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.start-path b { display: block; font-size: 0.82rem; margin-bottom: 4px; }
.start-path small { display: block; color: var(--text-dim); font-size: 0.875rem; line-height: 1.4; }
.start-path.selected { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,0.10); }
.starter-picker { margin-top: 14px; }
.starter-picker-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.starter-picker-head .field-label { margin: 0; }
.club-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-soft); border: 1px solid var(--control-border); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; transition: all 0.15s ease; text-align: left;
  font-family: inherit; color: var(--text); width: 100%;
}
.club-card.selected { background: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,197,94,0.10); }
.club-card .club-badge {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.72rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.club-card .club-name { font-weight: 600; font-size: 0.92rem; }
.club-card .club-meta { font-size: 0.74rem; color: var(--text-dim); }
.club-card .club-start-info { margin-left: auto; text-align: right; flex-shrink: 0; }
.club-tier { display: block; color: var(--text-faint); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.club-tier.second { color: var(--gold); }
.club-bonus { display: block; color: var(--accent); font-size: 0.75rem; margin-top: 2px; }

@media (max-width: 560px) {
  .start-paths { grid-template-columns: 1fr; }
  .start-path { min-height: 0; padding: 9px 11px; }
  .start-path small { margin-top: 2px; }
}

.form-error { color: var(--red); font-size: 0.84rem; margin-bottom: 12px; text-align: center; }

/* ---------- Wizard de creación (4 pasos, sin scroll) ---------- */
.steps-dots { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.step-dot {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700; color: var(--text-faint);
  background: var(--bg-soft); border: 1px solid var(--border);
  transition: all 0.25s ease;
}
.step-dot.active {
  background: var(--accent); border-color: var(--accent); color: #052e16;
  box-shadow: 0 0 0 4px rgba(34,197,94,0.15);
}
.step-dot.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.step { display: none; }
.step.active { display: block; animation: stepIn 0.3s var(--ease-out); }
.step.active.back { animation-name: stepInBack; }
@keyframes stepIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes stepInBack {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
.step-title { font-size: 0.95rem; font-weight: 700; margin-bottom: 14px; }

.steps-nav {
  flex: 0 0 auto; z-index: 8; display: flex; gap: 8px; align-items: center;
  margin: 8px -4px -4px; padding: 10px 4px 4px; background: var(--card);
}
.steps-nav .btn { white-space: nowrap; }
#btn-back { flex: 0 0 auto; }
#btn-next { flex: 1; }
#btn-create { flex: 1; font-size: 0.95rem; padding: 12px 18px; }

@media (max-width: 560px) {
  .steps-nav { flex-wrap: wrap; }
  #btn-cancel-setup, #btn-back { flex: 1 1 0; }
  #btn-create { flex: 1 0 100%; }
}

/* ---------- Header de partida ---------- */
.game-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px;
  box-shadow: 0 5px 14px var(--color-black-shadow);
}
.game-header .avatar {
  width: 58px; height: 58px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.14), 0 2px 8px rgba(0,0,0,0.4);
  overflow: hidden;
}
.game-header .avatar canvas { width: 44px; height: 58px; image-rendering: pixelated; }
.game-header .gh-name { font-weight: 700; font-size: 0.98rem; line-height: 1.25; text-align: center; }
.game-header .gh-sub { font-size: 0.875rem; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-header .gh-player { flex: 1; min-width: 0; text-align: center; overflow-wrap: anywhere; }
.game-header .gh-club { display: flex; align-items: center; justify-content: center; }
.game-header .gh-meta { color: var(--text-faint); font-size: 0.75rem; }
.game-header .gh-right { flex: 0 0 auto; margin-left: auto; }
.sound-toggle {
  flex-shrink: 0; align-self: center;
  width: 44px; height: 44px; min-height: 44px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--control-border);
  font-size: 0.85rem; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s ease, transform 0.12s ease;
}
.career-toggle { font-size: 1.05rem; }
.sound-toggle:active { transform: scale(0.92); }
.game-header .gh-ovr {
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--accent); border-radius: 12px; background: var(--accent-soft);
  color: var(--accent); font-size: 1.25rem; font-weight: 800; line-height: 1;
}

.career-progress { height: 5px; background: var(--card); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.career-progress-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 999px; transition: width 0.5s ease; }

/* ---------- Rasgo (tag) ---------- */
.trait-tag {
  display: inline-block; font-size: 0.75rem; font-weight: 700; color: var(--blue);
  background: rgba(56,189,248,0.12); border: 1px solid rgba(56,189,248,0.4);
  border-radius: 999px; padding: 2px 8px; vertical-align: 1px; margin-right: 4px;
}

/* ---------- Barras de atributos ---------- */
.attr-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin-top: 14px; }
.attr-item { display: flex; align-items: center; gap: 8px; font-size: 0.76rem; }
.attr-item .attr-k { color: var(--text-dim); width: 62px; flex-shrink: 0; }
.attr-item .attr-track { flex: 1; height: 6px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.attr-item .attr-fill { display: block; height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.attr-item .attr-v { width: 22px; text-align: right; font-weight: 700; color: var(--text); }

/* ---------- Prácticas de la etapa formativa ---------- */
/* minmax(0, 1fr): sin esto, una card con contenido largo irrompible
   (badge de rasgo, "clave") estira su columna más del 50% */
.drill-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.drill-cell {
  min-width: 0;
  text-align: left; font-family: inherit; cursor: pointer; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 12px; transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.drill-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 700; font-size: 0.85rem; }
.drill-head .drill-ico { font-size: 1rem; }
.drill-head .drill-name { flex: 1; min-width: 0; }
.drill-key {
  flex-shrink: 0;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--gold); background: var(--gold-soft); border: 1px solid rgba(250,204,21,0.4);
  border-radius: 999px; padding: 1px 6px;
}
.drill-desc { color: var(--text-dim); font-size: 0.875rem; line-height: 1.4; margin: 5px 0 8px; }
.drill-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-faint); }
.drill-attr b { font-weight: 800; }
.drill-badge { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; min-width: 0; overflow-wrap: anywhere; color: var(--text-faint); }
.drill-badge.owned { color: var(--blue); font-weight: 700; }
.drill-pip { width: 6px; height: 6px; border-radius: 50%; background: var(--border); display: inline-block; }
.drill-pip.on { background: var(--gold); box-shadow: 0 0 6px rgba(250,204,21,0.6); }

/* Parte de la práctica */
.training-result {
  border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 12px;
  background: var(--accent-soft); border: 1px solid rgba(34,197,94,0.35);
}
.training-result.lose { background: rgba(239,68,68,0.10); border-color: rgba(239,68,68,0.35); }
.tr-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.tr-text { color: var(--text-dim); font-size: 0.82rem; line-height: 1.5; margin-bottom: 10px; }
.tr-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.8rem; color: var(--text-dim); padding: 4px 0; border-top: 1px solid var(--border);
}
.tr-row b { font-weight: 800; }
.tr-up { color: var(--accent); }
.tr-down { color: var(--red); }
.tr-flat { color: var(--text-dim); }
.tr-hint { font-size: 0.78rem; color: var(--text-dim); text-align: center; margin-bottom: 12px; }

.trait-unlocked {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  background: var(--gold-soft); border: 1px solid rgba(250,204,21,0.5);
  border-radius: var(--radius-sm); padding: 13px 15px;
}
.trait-unlocked .tu-ico { font-size: 1.7rem; flex-shrink: 0; }
.trait-unlocked .tu-title { font-weight: 800; font-size: 0.9rem; color: var(--gold); }
.trait-unlocked .tu-desc { color: var(--text-dim); font-size: 0.76rem; line-height: 1.4; margin-top: 2px; }

/* ---------- Bloque de temporadas ---------- */
.block-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 4px; }
.block-sub { color: var(--text-dim); font-size: 0.875rem; margin-bottom: 14px; }
.block-summary-head > .block-title,
.block-summary-head > .block-sub { text-align: center; }

.season-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 4px; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.season-row:last-child { border-bottom: none; }
.season-row .s-year { font-weight: 700; width: 44px; flex-shrink: 0; }
.season-row .s-stats { min-width: 0; color: var(--text-dim); font-size: 0.875rem; overflow-wrap: anywhere; }
.season-row .s-rating { margin-left: auto; font-weight: 700; }
.season-row .s-rating.good { color: var(--accent); }
.season-row .s-rating.mid { color: var(--gold); }
.season-row .s-rating.bad { color: var(--red); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; font-size: 0.72rem; color: var(--text-dim);
}
.chip.gold { background: var(--gold-soft); border-color: rgba(250,204,21,0.4); color: var(--gold); }
.chip.green { background: var(--accent-soft); border-color: rgba(34,197,94,0.4); color: var(--accent); }
.chip.red { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: var(--red); }
.chip.blue { background: rgba(56,189,248,0.12); border-color: rgba(56,189,248,0.4); color: var(--blue); }

.period-achievements { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.period-achievements > .section-h { margin: 0 0 12px; text-align: center; }
.period-achievement-group + .period-achievement-group { margin-top: 14px; }
.period-achievement-label { margin-bottom: 6px; text-align: center; color: var(--text-dim); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.period-achievement-group.titles .period-achievement-label { color: var(--gold); }
.period-achievement-group.awards .period-achievement-label { color: var(--accent); }
.period-achievement-list { display: grid; gap: 6px; }
.period-achievement-row { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); text-align: center; }
.period-achievement-icon { width: 30px; flex: 0 0 30px; display: flex; align-items: center; justify-content: center; }
.period-achievement-icon .trophy-ico { width: 26px; height: 26px; }
.period-achievement-name { min-width: 0; font-size: 0.82rem; overflow-wrap: anywhere; }

.news-item { display: flex; gap: 9px; padding: 8px 0; font-size: 0.85rem; color: var(--text-dim); align-items: flex-start; }
.news-item .news-icon { flex-shrink: 0; }
.news-card .section-h { text-align: center; }

/* ---------- Clasificación final ---------- */
.league-table-card .section-h { margin-top: 0; text-align: center; }
.league-champion { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px; font-size: 0.84rem; margin-bottom: 10px; text-align: center; }
.league-move { font-size: 0.76rem; line-height: 1.45; padding: 7px 9px; border-left: 3px solid var(--border); background: var(--bg-soft); text-align: center; }
.league-move + .league-move { margin-top: 5px; }
.league-move.up { border-color: var(--accent); }
.league-move.down { border-color: var(--red); }
.league-move.neutral { color: var(--text-dim); }
.league-table-card details { margin-top: 12px; }
.league-table-card summary { color: var(--accent); font-size: 0.8rem; font-weight: 700; cursor: pointer; min-height: 44px; display: flex; align-items: center; justify-content: center; text-align: center; }
.league-table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); touch-action: pan-x pan-y; }
.league-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; white-space: nowrap; }
.league-table { table-layout: fixed; }
.league-table th { color: var(--text-faint); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; text-align: right; padding: 8px; border-bottom: 1px solid var(--border); }
.league-table th:nth-child(2) { text-align: left; }
.league-table td { text-align: right; padding: 7px 8px; border-bottom: 1px solid rgba(255,255,255,0.045); }
.league-table th:nth-child(1), .league-table td:nth-child(1) { width: 30px; }
.league-table th:nth-child(3), .league-table td:nth-child(3) { width: 38px; }
.league-table th:nth-child(4), .league-table td:nth-child(4) { width: 42px; }
.league-table th:nth-child(5), .league-table td:nth-child(5) { width: 44px; }
.league-table tr:last-child td { border-bottom: 0; }
.league-table .lt-pos { width: 26px; color: var(--text-faint); text-align: center; }
.league-table .lt-club { display: flex; align-items: center; gap: 6px; min-width: 180px; text-align: left; }
.league-table tr.player { color: var(--text); outline: 1px solid rgba(255,255,255,0.5); outline-offset: -1px; }
.league-table tr.player .lt-club { font-weight: 800; }
.league-table tr.champion { box-shadow: inset 3px 0 var(--gold); }
.league-table tr.promoted { box-shadow: inset 3px 0 var(--accent); }
.league-table tr.relegated { box-shadow: inset 3px 0 var(--red); }
.league-table tr.qualified.continental { background: rgba(59,130,246,0.16); }
.league-table tr.qualified.continental2 { background: rgba(250,204,21,0.13); }
.league-table tr.qualified.continental3 { background: rgba(34,197,94,0.13); }
.league-table tr.qualified.continental td:first-child { border-left: 3px solid #3b82f6; }
.league-table tr.qualified.continental2 td:first-child { border-left: 3px solid var(--gold); }
.league-table tr.qualified.continental3 td:first-child { border-left: 3px solid var(--accent); }
.player-qualified { margin-top: 9px; color: var(--blue); font-size: 0.78rem; text-align: center; }
.league-color-key { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 5px; margin-top: 9px; color: var(--text-faint); font-size: 0.75rem; text-align: center; }
.league-color-key span { width: 9px; height: 9px; border-radius: 2px; margin-left: 5px; }
.league-color-key span:first-child { margin-left: 0; }
.league-color-key .blue { background: #3b82f6; }
.league-color-key .yellow { background: var(--gold); }
.league-color-key .green { background: var(--accent); }

/* ---------- Ofertas / decisiones ---------- */
.offer-card {
  display: block; width: 100%; text-align: left; font-family: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0) 40%), var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 10px; cursor: pointer; color: var(--text);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  box-shadow: var(--shadow-card);
}
.offer-card:active { transform: scale(0.985); border-color: var(--accent); }

.offer-card .offer-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.offer-card .offer-head > div:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }
.offer-card .club-badge {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.8rem; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.offer-card .offer-club { font-weight: 700; font-size: 1rem; }
.offer-card .offer-league { font-size: 0.76rem; color: var(--text-dim); }
.offer-card .offer-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.offer-card .offer-wage { margin-left: auto; text-align: right; font-weight: 700; color: var(--gold); font-size: 0.9rem; white-space: nowrap; }
.offer-card .offer-wage small { display: block; color: var(--text-faint); font-weight: 400; font-size: 0.66rem; }

.event-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0) 40%), var(--card);
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: var(--radius); padding: 20px; margin-bottom: 14px;
  box-shadow: var(--shadow-card), 0 0 30px rgba(250, 204, 21, 0.05);
}
.event-card .event-tag { color: var(--gold); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.event-card .event-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.event-card .event-text { color: var(--text-dim); font-size: 1rem; line-height: 1.55; margin-bottom: 16px; }

.event-option {
  display: block; width: 100%; text-align: left; font-family: inherit;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 13px 15px; margin-bottom: 8px; cursor: pointer; color: var(--text);
  font-size: 1rem; font-weight: 500; transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.event-option:active { border-color: var(--gold); transform: scale(0.99); }

.event-option small { display: block; color: var(--text-faint); font-weight: 400; font-size: 0.875rem; margin-top: 3px; }

.event-result {
  background: var(--accent-soft); border: 1px solid rgba(34,197,94,0.35);
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: 0.88rem;
  color: var(--text); margin-bottom: 14px; line-height: 1.55;
}
/* Nombre del destino que salió, encabezando el resultado */
.event-result-title {
  color: var(--gold); font-weight: 800; font-size: 0.95rem;
  padding: 0 2px; margin-bottom: 8px; line-height: 1.35;
}

/* ==================== Minijuegos ==================== */
.minigame { margin: 4px 0 6px; }
.minigame .mg-prompt { font-size: 0.86rem; color: var(--text-dim); line-height: 1.5; margin-bottom: 14px; text-align: center; }
.minigame .mg-prompt b { color: var(--gold); }

/* barra de puntería */
.mg-bar {
  position: relative; height: 26px; border-radius: 999px; overflow: hidden;
  background: var(--bg-soft); border: 1px solid var(--border); margin-bottom: 16px;
}
.mg-zone { position: absolute; top: 0; bottom: 0; background: rgba(34,197,94,0.35); border-left: 2px solid var(--accent); border-right: 2px solid var(--accent); }
.mg-marker { position: absolute; left: 0; top: -2px; bottom: -2px; width: 5px; margin-left: -2px; background: var(--gold); border-radius: 3px; box-shadow: 0 0 8px var(--color-accent-soft); transition: background 0.1s; will-change: transform; }
.mg-marker.mg-hit { background: var(--accent); box-shadow: 0 0 12px rgba(34,197,94,0.9); }
.mg-marker.mg-miss { background: var(--red); box-shadow: 0 0 12px rgba(239,68,68,0.9); }

/* rondas encadenadas (gambeta) */
.mg-rounds { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.mg-round { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.mg-round.mg-round-now { background: var(--gold); box-shadow: 0 0 8px rgba(250,204,21,0.7); }
.mg-round.mg-round-ok { background: var(--accent); box-shadow: 0 0 8px rgba(34,197,94,0.7); }

/* circuito de pases (memoria) */
.mg-seq-status { text-align: center; font-weight: 700; font-size: 0.82rem; color: var(--text-dim); margin-bottom: 10px; }
.mg-seq-status.mg-seq-win { color: var(--accent); }
.mg-seq-status.mg-seq-lose { color: var(--red); }
.mg-seq { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.mg-seq-cell {
  aspect-ratio: 3/2; font-family: inherit; font-size: 0.85rem; font-weight: 800; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-faint); transition: background 0.1s, border-color 0.1s, transform 0.1s, color 0.1s;
}
.mg-seq-cell:disabled { cursor: default; opacity: 0.75; }

.mg-seq-cell.mg-seq-on { background: var(--gold); border-color: var(--gold); color: #1c1601; transform: scale(1.05); }
.mg-seq-cell.mg-seq-ok { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.mg-seq-cell.mg-seq-bad { background: rgba(239,68,68,0.18); border-color: var(--red); color: var(--red); }

/* cartas del destino */
.mg-cards { display: flex; gap: 10px; justify-content: center; }
.mg-card {
  flex: 1; max-width: 92px; aspect-ratio: 3/4; font-family: inherit; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-faint); font-size: 1.8rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
  transition: transform 0.12s ease, border-color 0.15s, background 0.15s;
}

.mg-card:disabled { cursor: default; }
.mg-card-win { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.mg-card-lose { background: rgba(239,68,68,0.12); border-color: var(--red); color: var(--red); }
.mg-card-picked { transform: translateY(-6px) scale(1.04); box-shadow: 0 6px 18px rgba(0,0,0,0.4); }
/* Carta revelada con nombre de destino: ícono arriba, título abajo */
.mg-card-named { flex-direction: column; gap: 5px; padding: 8px 5px; justify-content: center; }
.mg-card-named .mg-card-ico { font-size: 1.5rem; line-height: 1; }
.mg-card-named .mg-card-name {
  font-size: 0.6rem; font-weight: 700; line-height: 1.15; text-align: center;
  overflow-wrap: anywhere; hyphens: auto;
}

/* machaque */
.mg-meter { height: 22px; border-radius: 999px; overflow: hidden; background: var(--bg-soft); border: 1px solid var(--border); margin-bottom: 8px; }
.mg-fill { height: 100%; width: 0%; background: var(--gold); transition: width 0.05s linear; }
.mg-fill-win { background: var(--accent); }
.mg-fill-lose { background: var(--red); }
.mg-count { text-align: center; font-weight: 800; color: var(--text-dim); font-size: 0.9rem; margin-bottom: 12px; }

.minigame-host { margin-top: 4px; }

/* reflejos */
.mg-reflex { font-weight: 800; font-size: 1.05rem; color: #fff; transition: background 0.05s; min-height: 72px; }
.mg-reflex.mg-wait { background: #7f1d1d; }
.mg-reflex.mg-go { background: var(--accent); color: #052e16; }
.mg-reflex.mg-fail { background: var(--red); }
.mg-reflex.mg-win2 { background: var(--accent); color: #052e16; }

/* penal Canvas: resolución lógica baja y escalado vecino-cercano */
.mg-pixel-stage {
  position: relative; overflow: hidden; border: 2px solid rgba(250,204,21,0.5);
  border-radius: var(--radius-sm); background: #173b31; box-shadow: inset 0 0 0 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.28);
}
.mg-pixel-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 5/3; cursor: crosshair;
  touch-action: none; image-rendering: pixelated; image-rendering: crisp-edges; outline: none;
}
.mg-pixel-canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--gold); }
.mg-pixel-callout {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); pointer-events: none;
  padding: 5px 9px; border: 1px solid rgba(255,255,255,0.35); background: rgba(7,17,31,0.86);
  color: #fff; font-size: 0.64rem; font-weight: 900; letter-spacing: 0.08em; white-space: nowrap;
  text-shadow: 1px 1px #000; box-shadow: 2px 2px 0 rgba(0,0,0,0.45);
}
.mg-pixel-callout.mg-pixel-win { color: var(--gold); border-color: var(--gold); }
.mg-pixel-controls { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.mg-pixel-power { flex: 1; height: 13px; padding: 2px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 2px; }
.mg-pixel-power span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold) 72%, var(--red)); transition: width 0.05s linear; }
.mg-pixel-kick { min-width: 92px; padding: 9px 13px; }
.mg-keeper-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 10px; }
.mg-keeper-controls .btn { min-width: 0; padding: 9px 5px; border-radius: var(--radius-sm); font-size: 0.78rem; }
.mg-action-controls { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 10px; }
.mg-action-controls .btn { min-width: 0; padding: 9px 5px; border-radius: var(--radius-sm); font-size: 0.76rem; }
.mg-action-controls .btn.selected { color: var(--gold); border-color: var(--gold); background: rgba(250,204,21,0.08); }
.mg-pixel-callout.mg-pixel-go { color: #052e16; background: var(--accent); border-color: #86efac; text-shadow: none; }
.mg-pixel-help { margin-top: 7px; color: var(--text-faint); text-align: center; font-size: 0.68rem; }
.quality-low .mg-pixel-stage { box-shadow: none; }
.reduce-motion .mg-pixel-power span { transition: none; }

/* laboratorio temporal de minijuegos */
.minigame-lab-head { justify-content: flex-start; margin-bottom: 12px; }
.minigame-lab-head > div { flex: 1; text-align: center; }
.minigame-lab-head .screen-title { margin: 2px 0 0; }
.minigame-lab-head-spacer { width: 44px; }
.minigame-lab-card { width: 100%; min-width: 0; max-width: 560px; margin-inline: auto; overflow: hidden; }
.minigame-lab-intro { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.minigame-lab-intro > div { min-width: 0; }
.minigame-lab-icon { display: grid; place-items: center; flex: 0 0 52px; width: 52px; height: 52px; border-radius: 14px; background: rgba(250,204,21,0.1); border: 1px solid rgba(250,204,21,0.3); font-size: 1.6rem; }
.minigame-lab-intro h3 { margin-bottom: 3px; font-size: 1.05rem; }
.minigame-lab-intro p { color: var(--text-dim); font-size: 0.82rem; line-height: 1.45; overflow-wrap: anywhere; }
.minigame-lab-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 12px; }
.minigame-lab-options .field { margin-bottom: 14px; }
.minigame-lab-result { margin-bottom: 14px; padding: 13px 15px; border: 1px solid; border-radius: var(--radius-sm); font-size: 0.88rem; line-height: 1.45; }
.minigame-lab-result.success { color: var(--accent); background: var(--accent-soft); border-color: rgba(34,197,94,0.4); }
.minigame-lab-result.miss { color: #fca5a5; background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.35); }

@media (max-width: 480px) {
  .minigame-lab-options { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- Banderas ---------- */
.flag {
  height: 0.95em; width: auto; border-radius: 2px; vertical-align: -1px;
  margin-right: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
}

/* ---------- Selección nacional (tarjetas) ---------- */
.nt-event { border-color: rgba(34,197,94,0.35); }
.nt-event .event-title .nt-title-flag { height: 1.1em; margin-right: 6px; }
.nt-body { color: var(--text-dim); font-size: 0.88rem; line-height: 1.6; margin: 8px 0 16px; }
.nt-head { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
.nt-head .nt-flag { height: 30px; width: auto; border-radius: 3px; margin: 0; }
.nt-country { font-weight: 700; font-size: 1rem; }
.nt-meta { color: var(--text-dim); font-size: 0.82rem; margin-top: 2px; }
.nt-result { font-weight: 600; font-size: 0.82rem; }

/* ---------- Palmarés: sub-encabezados de grupo ---------- */
.pal-subhead {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); margin: 12px 2px 4px; padding-top: 8px; border-top: 1px solid var(--border);
}
.pal-subhead:first-child { border-top: none; padding-top: 0; margin-top: 0; }

/* ---------- Hitos ---------- */
.milestone-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border); font-size: 0.86rem; }
.milestone-row:last-child { border-bottom: none; }
.milestone-ico { font-size: 1.1rem; width: 1.4em; text-align: center; flex-shrink: 0; }
.milestone-year { margin-left: auto; color: var(--text-faint); font-size: 0.78rem; font-weight: 600; }

/* ---------- Salón de la Fama ---------- */
.hall-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: 10px;
}
.hall-rank { font-size: 1.1rem; font-weight: 800; color: var(--text-faint); width: 1.6em; text-align: center; flex-shrink: 0; }
.hall-player { width: 42px; height: 56px; image-rendering: pixelated; flex-shrink: 0; }
.hall-main { flex: 1; min-width: 0; }
.hall-name { font-weight: 700; font-size: 0.98rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hall-badge { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gold); background: var(--gold-soft); border: 1px solid rgba(250,204,21,0.4); border-radius: 999px; padding: 2px 8px; }
.hall-sub { color: var(--text-dim); font-size: 0.8rem; margin-top: 3px; }
.hall-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 0.82rem; color: var(--text-dim); }
.hall-epi { margin-top: 6px; font-size: 0.8rem; color: var(--text-faint); font-style: italic; }
.hall-score { text-align: center; font-weight: 800; font-size: 1.3rem; color: var(--accent); flex-shrink: 0; }
.hall-score small { display: block; font-size: 0.6rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }

/* ---------- Resumen ---------- */
.summary-hero { text-align: center; padding: 26px 10px 10px; }
.summary-player { display: block; width: 72px; height: 96px; margin: -10px auto 8px; image-rendering: pixelated; }
.summary-hero .legacy-label {
  display: inline-block; font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--gold); background: var(--gold-soft);
  border: 1px solid rgba(250,204,21,0.4); border-radius: 999px; padding: 6px 18px; margin-bottom: 12px;
}
.summary-hero h2 { font-size: 2rem; font-weight: 800; }
.summary-hero .summary-sub { color: var(--text-dim); font-size: 0.9rem; margin-top: 6px; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stat-cell { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 8px; text-align: center; }
.stat-cell .stat-val { font-size: 1.45rem; font-weight: 800; color: var(--accent); }
.stat-cell .stat-val.gold { color: var(--gold); }
.stat-cell .stat-name { font-size: 0.68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 3px; }

.section-h { font-size: 0.82rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.09em; margin: 22px 0 10px; }

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 18px 12px; }
.timeline-item::before {
  content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.timeline-item .t-club { font-weight: 700; font-size: 0.95rem; }
.timeline-item .t-years { font-size: 0.74rem; color: var(--text-faint); }
.timeline-item .t-detail { font-size: 0.8rem; color: var(--text-dim); margin-top: 3px; }
.timeline-item .t-titles { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

.trophy-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.trophy-row:last-child { border-bottom: none; }
.trophy-row .trophy-count { font-weight: 800; color: var(--gold); }
.trophy-row .trophy-name { display: inline-flex; align-items: center; gap: 9px; }
.trophy-row .trophy-ico { height: 30px; width: 30px; }

/* Imagen real de copa/liga (fallback a emoji si no carga) */
.trophy-ico {
  height: 16px; width: 16px; object-fit: contain;
  vertical-align: -3px; border-radius: 3px; flex-shrink: 0;
}

#chart-canvas { width: 100%; height: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }

.share-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }

/* ---------- Acciones y secciones progresivas ---------- */
.primary-action {
  position: sticky; bottom: 0; z-index: 20; margin-top: 14px;
  box-shadow: 0 -12px 24px var(--color-bg), 0 4px 14px rgba(50, 213, 131, 0.22);
}
.disclosure { margin: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: clip; }
.disclosure > summary { min-height: 48px; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; font-weight: 700; }
.disclosure > summary::after { content: "+"; color: var(--accent); font-size: 1.2rem; }
.disclosure[open] > summary::after { content: "−"; }
.disclosure-body { padding: 0 14px 14px; }
.selection-actions { display: flex; gap: 8px; margin-top: 12px; }
.selection-actions .btn { flex: 1; }
.offer-card.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.status-message { min-height: 20px; color: var(--text-dim); font-size: 0.875rem; text-align: center; margin-top: 8px; }

/* ---------- Hojas modales ---------- */
.sheet-dialog {
  width: min(100% - 16px, 560px); max-height: min(88dvh, 720px); margin: auto auto 0;
  padding: 10px 16px calc(18px + var(--sab)); color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 22px 22px 0 0; box-shadow: 0 -12px 40px var(--color-black-shadow);
  overflow-y: auto; overscroll-behavior: contain;
}
.sheet-dialog::backdrop { background: var(--color-overlay); }
.sheet-dialog[open] { animation: sheetIn 0.22s var(--ease-out); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 12px; border-radius: 99px; background: var(--control-border); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.sheet-head h2 { font-size: 1.35rem; line-height: 1.2; }
.eyebrow { display: block; color: var(--accent); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.icon-button { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; border: 1px solid var(--control-border); background: var(--bg-soft); color: var(--text); font: inherit; cursor: pointer; }
.settings-list { border-top: 1px solid var(--border); margin-bottom: 14px; }
.setting-row { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.setting-row > span { min-width: 0; }
.setting-row b, .setting-row small { display: block; }
.setting-row b { font-size: 0.95rem; }
.setting-row small { color: var(--text-dim); font-size: 0.8rem; margin-top: 2px; }
.setting-row input[type="checkbox"] { width: 48px; height: 28px; flex: 0 0 48px; accent-color: var(--accent); }
.setting-select { align-items: flex-start; flex-direction: column; }
.setting-select select { min-height: 44px; }
.career-dialog .sheet-head > div:first-child { flex: 1; margin-left: 44px; text-align: center; }
.career-overview { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.career-metric { padding: 12px; border-radius: var(--radius-sm); background: var(--bg-soft); border: 1px solid var(--border); text-align: center; }
.career-metric b { display: block; font-size: 1.1rem; color: var(--accent); overflow-wrap: anywhere; }
.career-metric span { display: block; color: var(--text-dim); font-size: 0.8rem; }
.career-profile { text-align: center; }
.career-profile-main { line-height: 1.6; }
.career-contract { margin-top: 4px; font-size: 0.875rem; }
.career-contract:empty { display: none; }
.career-profile-traits { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.career-profile-traits .block-sub { margin-bottom: 0; }
.career-menu-actions { display: grid; gap: 8px; }

/* ---------- Trofeo o premio recién ganado ---------- */
.achievement-dialog {
  width: min(calc(100% - 32px), 360px); max-height: calc(100dvh - 32px); margin: auto;
  padding: 28px 22px 24px; overflow-y: auto; text-align: center; color: var(--text);
  background: var(--card); border: 1px solid rgba(244, 197, 66, 0.42);
  border-radius: 20px; box-shadow: 0 18px 48px var(--color-black-shadow);
}
.achievement-dialog::backdrop { background: var(--color-overlay); }
.achievement-dialog[open] { animation: achievementIn 0.22s var(--ease-out); }
@keyframes achievementIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.achievement-close { position: absolute; top: 10px; right: 10px; }
.achievement-kicker {
  margin: 0 44px 18px; color: var(--gold); font-size: 0.75rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.achievement-art {
  width: 92px; height: 92px; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 4rem; border-radius: 50%;
  background: var(--gold-soft); border: 1px solid rgba(244, 197, 66, 0.28);
}
.achievement-art .trophy-ico { width: 70px; height: 70px; object-fit: contain; }
.achievement-dialog h2 { font-size: 1.35rem; line-height: 1.25; overflow-wrap: anywhere; }
.achievement-dialog p { margin-top: 8px; color: var(--text-dim); font-size: 0.875rem; }

@media (max-width: 340px) {
  .achievement-dialog { width: calc(100% - 20px); padding: 24px 16px 20px; }
  .achievement-art { width: 82px; height: 82px; }
  .achievement-art .trophy-ico { width: 62px; height: 62px; }
}

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important; scroll-behavior: auto !important;
}
.quality-low .game-header, .quality-low .card, .quality-low .event-card, .quality-low .offer-card { box-shadow: none; }
.quality-low .home-ball { animation: none; }

.hidden { display: none !important; }

/* ---------- Accesibilidad táctil / anti-overflow ---------- */
.event-option, .club-card, .offer-card, .btn, .mg-action, .pill, .mg-seq-cell { min-height: 44px; }
.event-option, .mg-action { touch-action: manipulation; }
button { touch-action: manipulation; }

/* Feedback de toque inmediato (sin hover en táctil) */
.club-card:active, .pill:active, .drill-cell:active { transform: scale(0.98); }

/* ---------- Hover sólo donde hay puntero real (en táctil queda "pegado") ---------- */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { filter: brightness(1.08); }
  .btn-gold:hover { filter: brightness(1.06); }
  .btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }
  .pill:hover { border-color: var(--text-faint); color: var(--text); }
  .pos-dot:hover { border-color: var(--gold); color: var(--gold); z-index: 2; }
  .club-card:hover { border-color: var(--text-faint); }
  .drill-cell:hover { border-color: var(--gold); transform: translateY(-2px); }
  .offer-card:hover { border-color: var(--accent); transform: translateY(-1px); }
  .event-option:hover { border-color: var(--gold); }
  .mg-seq-cell:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
  .mg-card:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--gold); color: var(--gold); }
}

/* ---------- Movimiento reducido: todo instantáneo ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Móvil chico (≤380px) ---------- */
@media (max-width: 380px) {
  .screen { padding: calc(16px + var(--sat)) calc(12px + var(--sar)) calc(26px + var(--sab)) calc(12px + var(--sal)); }
  .home-title { font-size: 2.7rem; }
  .home-desc { font-size: 0.86rem; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card, .event-card { padding: 15px; }
  .game-header { gap: 8px; padding: 12px; }
  .game-header .gh-ovr { font-size: 1.15rem; }
  .mg-cards { gap: 7px; }
  .mg-card { max-width: none; }
  .mg-prompt { font-size: 0.82rem; }
  .drill-cell { padding: 9px 10px; }
  .hall-card { padding: 11px; gap: 9px; }
  .hall-score { font-size: 1.1rem; }
  .hall-stats { gap: 8px; font-size: 0.78rem; }
  .offer-head { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .home-tagline, .home-desc { width: calc(100vw - 32px); }
  .drill-grid { grid-template-columns: 1fr; }
  .league-table .lt-club { display: table-cell; min-width: 0; overflow: hidden; white-space: nowrap; }
  .league-table .lt-club > span:not(.sr-only) {
    display: inline-block; max-width: calc(100% - 27px); overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
  }
  .league-table th, .league-table td { padding: 7px 5px; }
  .league-table-card { padding: 14px 12px; }
  .sheet-dialog { width: 100%; border-left: 0; border-right: 0; }
}

@media (max-width: 380px) {
  .attr-bars { grid-template-columns: 1fr; }
  .league-table th:nth-child(3), .league-table td:nth-child(3),
  .league-table th:nth-child(4), .league-table td:nth-child(4) { display: none; }
  .league-table .lt-pos { width: 24px; }
  .game-header .avatar { width: 52px; height: 52px; }
  .game-header .avatar canvas { width: 39px; height: 52px; }
  .career-toggle { width: 44px; height: 44px; min-height: 44px; }
}

@media (max-height: 600px) {
  #screen-home.active { justify-content: flex-start; }
  #screen-home .home-inner { gap: 6px; }
  #screen-home .home-ball { font-size: 2rem; animation: none; }
  #screen-home .home-title { font-size: 2.4rem; }
  #screen-home .home-tagline { font-size: 0.8rem; }
  #screen-home .home-desc, #screen-home .home-foot { display: none; }
  .screen { padding-top: calc(8px + var(--sat)); padding-bottom: calc(8px + var(--sab)); }
  .game-header { position: relative; }
  .sheet-dialog { max-height: 96dvh; }
}

/* Wizard: contenido desplazable, navegación siempre al alcance del pulgar. */
#screen-setup > .container { display: flex; flex-direction: column; overflow: hidden; }
#setup-form { flex: 1; min-height: 0; display: flex; flex-direction: column; margin-bottom: 0; }
#setup-form .step.active { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px 6px; }
#setup-form .steps-dots { flex: 0 0 auto; }
#setup-form .form-error:not(.hidden) { flex: 0 0 auto; }

/* ---------- Desktop ---------- */
@media (min-width: 640px) {
  .screen { padding: calc(30px + var(--sat)) calc(24px + var(--sar)) calc(40px + var(--sab)) calc(24px + var(--sal)); }
  .home-title { font-size: 3.8rem; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .share-actions { flex-direction: row; flex-wrap: wrap; }
  .share-actions .btn { flex: 1; white-space: nowrap; }
}
