/* ==========================================================================
   Reset
   ========================================================================== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ==========================================================================
   Design tokens — copiados de audio.nidoazulcrema.com para cohesión de brand
   ========================================================================== */
:root {
  /* Brand */
  --primary: #2b6cb0;
  --primary-glow: rgba(43, 108, 176, 0.35);
  --primary-soft: rgba(43, 108, 176, 0.12);
  --secondary: #2d3a50;
  --tertiary: #f0d04a;
  --tertiary-glow: rgba(240, 208, 74, 0.15);
  --tertiary-soft: rgba(240, 208, 74, 0.08);

  /* Surfaces */
  --surface-base: #0c1520;
  --surface-raised: #152233;
  --surface-hover: #1e2f44;
  --surface-glass: rgba(21, 34, 51, 0.65);

  /* Text */
  --text-primary: #f0d04a;
  --text-secondary: #8a9bb5;
  --text-muted: #5a6d85;
  --text-bright: #e8eef7;

  /* Borders */
  --border: #253a55;
  --border-subtle: rgba(37, 58, 85, 0.5);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Z-index */
  --z-toast: 1000;
  --z-popover: 500;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background-color: var(--surface-base);
  color: var(--text-bright);
  min-height: 100dvh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 50% -10%, rgba(43, 108, 176, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 0%, rgba(45, 58, 80, 0.5) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(240, 208, 74, 0.03) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 60%, rgba(43, 108, 176, 0.03) 0%, transparent 40%);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   App shell
   ========================================================================== */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
  background: rgba(12, 21, 32, 0.75);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand__mark {
  color: var(--tertiary);
  font-size: 0.85rem;
  transform: translateY(1px);
  filter: drop-shadow(0 0 8px var(--tertiary-glow));
}
.brand__name {
  color: var(--text-bright);
}
.brand__dim {
  color: var(--text-muted);
  font-weight: 500;
}

.app__actions {
  display: flex;
  gap: var(--space-sm);
}

.app__main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 460px;
  gap: var(--space-xl);
  padding: var(--space-xl);
  align-items: start;
}

@media (max-width: 960px) {
  .app__main {
    grid-template-columns: 1fr;
    padding: var(--space-md);
    gap: var(--space-md);
  }
  .app__header {
    padding: var(--space-md);
  }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-bright);
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease-spring),
              background-color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out);
}
.btn:focus-visible {
  outline: 2px solid var(--tertiary);
  outline-offset: 2px;
}
.btn__icon {
  font-size: 1rem;
  line-height: 1;
}
.btn--ghost {
  border-color: var(--border-subtle);
  background: var(--surface-glass);
  color: var(--text-secondary);
  backdrop-filter: blur(12px);
}
.btn--ghost:hover {
  color: var(--text-bright);
  border-color: var(--border);
  background: var(--surface-hover);
}
.btn--primary {
  background: var(--tertiary);
  color: var(--surface-base);
  box-shadow: 0 4px 18px var(--tertiary-glow);
}
.btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--tertiary-glow);
}
.btn--primary:active {
  transform: translateY(0) scale(0.98);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.link {
  background: none;
  border: none;
  color: var(--tertiary);
  font: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--tertiary-soft);
  transition: text-decoration-color var(--duration-fast) var(--ease-out);
}
.link:hover {
  text-decoration-color: var(--tertiary);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-glass);
  color: var(--text-secondary);
  font: inherit;
  font-weight: 600;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}
.pill:hover {
  color: var(--text-bright);
  border-color: var(--border);
  background: var(--surface-hover);
}
.pill--danger:hover {
  color: #ff8a8a;
  border-color: rgba(255, 100, 100, 0.4);
  background: rgba(255, 100, 100, 0.08);
}

/* ==========================================================================
   Stage (canvas area)
   ========================================================================== */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.stage__wrap {
  position: relative;
  /* Capa el ancho para que la altura derivada (aspect-ratio) no force scroll
     en desktop: disponible = 100dvh menos header (~65) + paddings (64) + tip
     (~20) + gap (~8) + colchón (~40) para asegurar que cabe sin scroll. */
  width: min(100%, calc((100dvh - 200px) * 1456 / 1048));
  aspect-ratio: 1456 / 1048;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background:
    linear-gradient(45deg, #0f1a28 25%, transparent 25%),
    linear-gradient(-45deg, #0f1a28 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #0f1a28 75%),
    linear-gradient(-45deg, transparent 75%, #0f1a28 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  background-color: #0a1119;
  border: 1px solid var(--border-subtle);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.stage__canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* para que funcione drag en mobile */
  cursor: grab;
}
.stage__canvas.is-dragging {
  cursor: grabbing;
}
.stage__canvas.is-empty {
  cursor: default;
}

.stage__hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  pointer-events: none;
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-secondary);
}
.stage__hint[hidden] {
  display: none;
}
.stage__hint-icon {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(8px);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--tertiary);
  letter-spacing: 0.04em;
}
.stage__hint-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-bright);
}
.stage__hint-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stage__drop {
  position: absolute;
  inset: 8px;
  border: 2px dashed var(--tertiary);
  border-radius: var(--radius-md);
  background: rgba(240, 208, 74, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tertiary);
  font-weight: 700;
  font-size: 1rem;
  pointer-events: none;
  backdrop-filter: blur(4px);
  animation: pulse-drop 1.2s var(--ease-in-out) infinite;
}
.stage__drop[hidden] { display: none; }

@keyframes pulse-drop {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

.stage__tip {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.02em;
}

/* ==========================================================================
   Controls panel
   ========================================================================== */
.controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: var(--surface-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3),
              inset 0 1px 0 rgba(255, 255, 255, 0.03);
  max-height: calc(100dvh - 140px);
  overflow-y: auto;
  position: sticky;
  top: calc(64px + var(--space-md));
}
@media (max-width: 960px) {
  .controls {
    position: static;
    max-height: none;
  }
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.control-label,
.control-label-row {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-sm);
}
.control-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.control-help kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-bright);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
}
.control-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}
.control-row--buttons {
  flex-wrap: wrap;
}
.control-row--two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* ── Inputs ── */
.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  color: var(--text-bright);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}
.input:focus {
  outline: none;
  border-color: var(--tertiary);
  box-shadow: 0 0 0 3px var(--tertiary-soft);
}
.input::placeholder {
  color: var(--text-muted);
}
.input--textarea {
  resize: vertical;
  font-family: inherit;
  min-height: 70px;
}
.input--select {
  appearance: none;
  padding-right: 36px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 12px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.input--score {
  width: 64px;
  text-align: center;
  font-weight: 700;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

/* ── Range ── */
.range {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  grid-template-rows: auto auto;
  gap: var(--space-xs) var(--space-sm);
  align-items: center;
  width: 100%;
}
.range__label {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.range__input {
  grid-column: 1;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: var(--radius-full);
  background: linear-gradient(to right, var(--tertiary) 0%, var(--tertiary) var(--range-pct, 50%), var(--border) var(--range-pct, 50%));
  cursor: pointer;
}
.range__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tertiary);
  border: 2px solid var(--surface-base);
  box-shadow: 0 0 8px var(--tertiary-glow);
  cursor: grab;
  transition: transform var(--duration-fast) var(--ease-spring);
}
.range__input::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}
.range__input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tertiary);
  border: 2px solid var(--surface-base);
  cursor: grab;
}
.range__value {
  grid-column: 2;
  text-align: right;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  font-weight: 600;
}

/* ── Segmented control ── */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  gap: 2px;
}
.seg__btn {
  flex: 1;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.75rem;
  border-radius: calc(var(--radius-sm) - 3px);
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.seg__btn:hover:not(.is-active) {
  color: var(--text-bright);
}
.seg__btn.is-active {
  background: var(--tertiary);
  color: var(--surface-base);
  box-shadow: 0 2px 8px var(--tertiary-glow);
}
.seg__btn--icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
}
.seg__btn--icon svg {
  width: 18px;
  height: 18px;
  display: block;
}
.seg-labeled {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}
.seg-labeled__label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.seg-labeled .seg {
  width: 100%;
}

/* ==========================================================================
   Teams layout — stack vertical para que los nombres quepan holgados
   ========================================================================== */
.teams {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.team-slot {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
}
.team-slot__caption {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
}
.score__dash {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 1.1rem;
}
.score.is-hidden {
  display: none;
}

/* Segmented full-width para toggles como VS/Marcador o Portada/Columna */
.seg--full {
  display: flex;
  width: 100%;
}
.seg--full .seg__btn {
  flex: 1;
}

/* ==========================================================================
   Font picker (chips que muestran cada fuente en su propia tipografía)
   ========================================================================== */
.font-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: var(--space-xs);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}
.font-chip {
  padding: 10px 6px;
  border-radius: calc(var(--radius-sm) - 2px);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1;
  cursor: pointer;
  text-align: center;
  transition: all var(--duration-fast) var(--ease-out);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.font-chip:hover:not(.is-active) {
  color: var(--text-bright);
  background: var(--surface-hover);
}
.font-chip.is-active {
  background: var(--tertiary);
  color: var(--surface-base);
  box-shadow: 0 2px 8px var(--tertiary-glow);
}

/* Pill de ancho completo (para swap button) */
.pill--full {
  width: 100%;
  justify-content: center;
}

/* ==========================================================================
   Modo Columna — oculta sección EQUIPOS y revela botón swap
   (default: swap oculto; en modo columna: swap visible + equipos oculto)
   ========================================================================== */
[data-column-swap] {
  display: none;
}
body.mode-column [data-equipos] {
  display: none;
}
body.mode-column [data-column-swap] {
  display: flex;
}

/* ==========================================================================
   Team picker (custom dropdown + live search)
   ========================================================================== */
.team-picker {
  position: relative;
}
.team-picker__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  color: var(--text-bright);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
  text-align: left;
}
.team-picker__trigger:hover {
  border-color: var(--border);
  background: var(--surface-hover);
}
.team-picker__trigger.is-open {
  border-color: var(--tertiary);
  box-shadow: 0 0 0 3px var(--tertiary-soft);
}
.team-picker__shield {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Anton', 'Inter', sans-serif;
  font-size: 10px;
  letter-spacing: 0.02em;
  line-height: 1;
  background: var(--surface-hover);
  color: var(--text-bright);
  box-shadow:
    inset 0 0 0 1.5px var(--ring, rgba(255, 255, 255, 0.35)),
    0 1px 2px rgba(0, 0, 0, 0.4);
}
.team-picker__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-picker__chev {
  color: var(--text-muted);
  font-size: 0.65rem;
  transition: transform var(--duration-fast) var(--ease-out);
}
.team-picker__trigger.is-open .team-picker__chev {
  transform: rotate(180deg);
}

.team-picker__panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-popover);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
  animation: picker-in var(--duration-fast) var(--ease-out);
}
.team-picker__panel[hidden] { display: none; }

@keyframes picker-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.team-picker__search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-base);
  color: var(--text-bright);
  font: inherit;
  font-size: 0.85rem;
}
.team-picker__search:focus {
  outline: none;
  background: var(--surface-hover);
}
.team-picker__search::placeholder {
  color: var(--text-muted);
}

.team-picker__list {
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
}
.team-picker__item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: background-color var(--duration-fast) var(--ease-out);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}
.team-picker__item:hover,
.team-picker__item.is-focused {
  background: var(--surface-hover);
  color: var(--text-bright);
}
.team-picker__item.is-selected {
  color: var(--tertiary);
}
.team-picker__header {
  padding: 10px 12px 4px;
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  user-select: none;
  pointer-events: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.team-picker__header:first-child {
  border-top: 0;
}
.team-picker__empty {
  padding: var(--space-md);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  z-index: var(--z-toast);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-spring);
  pointer-events: none;
  backdrop-filter: blur(12px);
}
.toast[hidden] { display: none; }
.toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast--success {
  border-color: var(--tertiary);
  color: var(--tertiary);
}
.toast--error {
  border-color: rgba(255, 100, 100, 0.5);
  color: #ff8a8a;
}
