/**
 * Generador de cuadros de torneo y llaves eliminatorias (Bracket Maker)
 * fijate.com - Estándares canónicos
 */

:root {
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-title: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Tema oscuro por defecto */
  --bg-app: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #19243d;
  --bg-subtle: #1c263f;
  --bg-input: #0e1626;
  --border-color: #273552;
  --border-subtle: #1e2a42;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #10b981;
  --accent-primary-hover: #059669;
  --accent-primary-glow: rgba(16, 185, 129, 0.25);

  --accent-gold: #f59e0b;
  --accent-gold-hover: #d97706;
  --accent-gold-glow: rgba(245, 158, 11, 0.25);

  --accent-danger: #ef4444;
  --accent-danger-hover: #dc2626;

  --badge-bg: #1e293b;
  --badge-text: #cbd5e1;

  --slot-hover: rgba(255, 255, 255, 0.05);
  --connector-color: #334155;
  --connector-active: #10b981;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.2);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
}

[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-subtle: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --accent-primary: #059669;
  --accent-primary-hover: #047857;
  --accent-primary-glow: rgba(5, 150, 105, 0.2);

  --accent-gold: #d97706;
  --accent-gold-hover: #b45309;
  --accent-gold-glow: rgba(217, 119, 6, 0.2);

  --accent-danger: #dc2626;
  --accent-danger-hover: #b91c1c;

  --badge-bg: #e2e8f0;
  --badge-text: #334155;

  --slot-hover: rgba(0, 0, 0, 0.03);
  --connector-color: #cbd5e1;
  --connector-active: #059669;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 20px rgba(5, 150, 105, 0.15);
}

/* ==========================================================================
   Estructura general y resets
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-base);
  background-color: var(--bg-app);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-title);
  margin: 0;
  font-weight: 700;
  line-height: 1.25;
}

.mono {
  font-family: var(--font-mono);
}

.tool-layout {
  max-width: 1300px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Migas de pan */
.tool-breadcrumbs {
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}

.tool-breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 0.5rem;
}

.tool-breadcrumbs li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.tool-breadcrumbs li:not(:last-child)::after {
  content: "›";
  color: var(--text-dim);
  font-size: 1rem;
}

.tool-breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.tool-breadcrumbs a:hover {
  color: var(--accent-primary);
}

.tool-breadcrumbs li[aria-current="page"] {
  color: var(--text-main);
  font-weight: 600;
}

/* Banner publicitario */
.tools-ad-banner-section {
  margin-bottom: 1.5rem;
  width: 100%;
}

.ad-banner-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.ad-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.ad-banner-card {
  width: 100%;
  min-height: 90px;
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Tarjeta principal */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .card-main {
    padding: 1rem;
    border-radius: var(--radius-lg);
  }
}

/* Hero descriptivo */
.hero-header {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1.25rem;
}

.hero-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.hero-title {
  font-size: 1.5rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--accent-primary-glow);
  color: var(--accent-primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  border: 1px solid var(--accent-primary);
  letter-spacing: 0.02em;
}

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
  max-width: 850px;
}

/* ==========================================================================
   Pestañas de vista principal: Creador vs Cuadro en vivo
   ========================================================================== */
.view-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-input);
  padding: 0.35rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.view-tab-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-base);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.75rem;
}

.view-tab-btn:hover {
  color: var(--text-main);
}

.view-tab-btn.active {
  background: var(--bg-card);
  color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.view-tab-btn svg {
  flex-shrink: 0;
}

/* ==========================================================================
   Panel de configuración de torneo (Paso 1)
   ========================================================================== */
.setup-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

.setup-panel {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-title {
  font-size: 1.1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-title svg {
  color: var(--accent-primary);
}

.participants-counter-badge {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  font-family: var(--font-base);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input {
  min-height: 40px;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-select {
  min-height: 40px;
  appearance: none;
  -webkit-appearance: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.form-select option, .form-select optgroup {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.form-textarea {
  resize: vertical;
  min-height: 220px;
  line-height: 1.5;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* Acciones rápidas de participantes */
.textarea-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-link-action {
  background: none;
  border: none;
  padding: 0.3rem 0.5rem;
  color: var(--accent-primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.btn-link-action:hover {
  background: var(--accent-primary-glow);
}

.btn-link-action.danger {
  color: var(--accent-danger);
}

.btn-link-action.danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

/* Cuadrículas de opciones compactas */
.options-compact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 500px) {
  .options-compact-grid {
    grid-template-columns: 1fr;
  }
}

.radio-card-label {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-card-label:hover {
  border-color: var(--accent-primary);
  background: var(--slot-hover);
}

.radio-card-label input[type="radio"],
.radio-card-label input[type="checkbox"] {
  accent-color: var(--accent-primary);
  margin-top: 0.15rem;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.radio-card-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.radio-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.radio-card-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.35;
}

/* Presets rápidos de participantes */
.presets-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.presets-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 9999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}

.chip-btn:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-primary-glow);
}

/* Botón principal de acción */
.btn-primary-action {
  width: 100%;
  min-height: 48px;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-base);
  font-size: 1rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  cursor: pointer;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  transition: all 0.2s ease;
}

.btn-primary-action:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
}

.btn-primary-action:active {
  transform: translateY(0);
}

/* Resumen proyectado del cuadro */
.bracket-preview-stats {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  text-align: center;
}

.stat-box {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

/* ==========================================================================
   Vista de cuadro eliminatorio interactivo (Paso 2)
   ========================================================================== */
.bracket-view-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Barra de herramientas superior del cuadro */
.bracket-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.85rem;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tournament-info-badge {
  display: flex;
  flex-direction: column;
}

.tournament-current-name {
  font-family: var(--font-title);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tournament-meta-text {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.btn-tool {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  height: 38px;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-tool:hover {
  border-color: var(--accent-primary);
  background: var(--bg-card-hover);
  color: var(--accent-primary);
}

.btn-tool svg {
  flex-shrink: 0;
}

.btn-tool.btn-gold {
  color: var(--accent-gold);
}

.btn-tool.btn-gold:hover {
  border-color: var(--accent-gold);
  background: var(--accent-gold-glow);
}

/* Zoom controls */
.zoom-controls {
  display: inline-flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.15rem;
  gap: 0.15rem;
}

.btn-zoom {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  transition: background 0.15s;
}

.btn-zoom:hover {
  background: var(--slot-hover);
  color: var(--accent-primary);
}

.zoom-level-text {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  min-width: 44px;
  text-align: center;
  padding: 0 0.25rem;
}

/* Selector móvil de rondas */
.mobile-round-selector {
  display: none;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 0.25rem 0;
  gap: 0.4rem;
}

@media (max-width: 900px) {
  .mobile-round-selector {
    display: flex;
  }
}

.round-pill-btn {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 0.85rem;
  border-radius: 9999px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s;
}

.round-pill-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Lienzo y Árbol de competición (SVG + DOM)
   ========================================================================== */
.bracket-viewport {
  position: relative;
  width: 100%;
  min-height: 520px;
  max-height: 820px;
  height: 65vh;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: auto;
  cursor: grab;
  user-select: none;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.bracket-viewport:active {
  cursor: grabbing;
}

/* Tablero interior escalable */
.bracket-canvas {
  position: relative;
  display: inline-flex;
  padding: 2.5rem 2.5rem 4rem;
  gap: 3.5rem;
  min-width: 100%;
  transform-origin: top left;
  transition: transform 0.1s ease-out;
}

/* Columna de ronda */
.bracket-round {
  display: flex;
  flex-direction: column;
  width: 260px;
  flex-shrink: 0;
}

.round-header {
  text-align: center;
  padding: 0.6rem 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

.round-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.round-subtitle {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

/* Lista de cruces en la ronda */
.round-matches {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  flex-grow: 1;
  gap: 1.5rem;
  position: relative;
}

/* Tarjeta individual de cruce (Match Card) */
.match-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  z-index: 2;
}

.match-card:hover {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.match-card.is-active-match {
  border-color: var(--accent-primary);
}

.match-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.6rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.68rem;
  color: var(--text-dim);
}

.match-id-text {
  font-family: var(--font-mono);
  font-weight: 600;
}

.match-score-btn {
  background: none;
  border: none;
  padding: 0.15rem 0.35rem;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.match-score-btn:hover {
  color: var(--accent-primary);
  background: var(--slot-hover);
}

/* Ranura de participante dentro del cruce */
.match-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
  position: relative;
  gap: 0.5rem;
}

.match-slot:first-of-type {
  border-bottom: 1px solid var(--border-subtle);
}

.match-slot:hover {
  background-color: var(--slot-hover);
}

.slot-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex: 1 1 auto;
}

.seed-badge {
  font-size: 0.65rem;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--badge-bg);
  color: var(--badge-text);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  flex-shrink: 0;
}

.participant-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.score-display {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 20px;
  text-align: right;
}

.winner-icon {
  display: none;
  color: var(--accent-primary);
}

/* Estados de ganador y perdedor */
.match-slot.is-winner {
  background: rgba(16, 185, 129, 0.08);
}

.match-slot.is-winner .participant-name {
  font-weight: 700;
  color: var(--accent-primary);
}

.match-slot.is-winner .winner-icon {
  display: inline-block;
}

.match-slot.is-winner .score-display {
  color: var(--accent-primary);
}

.match-slot.is-loser {
  opacity: 0.5;
}

.match-slot.is-loser .participant-name {
  text-decoration: line-through;
  color: var(--text-dim);
}

.match-slot.is-bye {
  font-style: italic;
  opacity: 0.45;
  cursor: default;
}

.match-slot.is-bye .participant-name {
  color: var(--text-dim);
}

.match-slot.is-empty {
  opacity: 0.4;
  cursor: default;
}

.match-slot.is-empty .participant-name {
  color: var(--text-dim);
}

/* ==========================================================================
   Líneas conectoras SVG entre cruces
   ========================================================================== */
.bracket-connectors-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.connector-line {
  fill: none;
  stroke: var(--connector-color);
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s ease;
}

.connector-line.is-active {
  stroke: var(--connector-active);
  stroke-width: 2.5px;
}

/* ==========================================================================
   Tarjeta y Sección del Campeón
   ========================================================================== */
.champion-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 280px;
  flex-shrink: 0;
  padding: 1rem 0;
}

.champion-card {
  position: relative;
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(245, 158, 11, 0.12) 100%);
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-xl);
  padding: 1.75rem 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-lg), 0 0 25px var(--accent-gold-glow);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  animation: championGlow 3s ease-in-out infinite alternate;
}

@keyframes championGlow {
  0% {
    box-shadow: var(--shadow-lg), 0 0 15px rgba(245, 158, 11, 0.2);
  }
  100% {
    box-shadow: var(--shadow-lg), 0 0 35px rgba(245, 158, 11, 0.4);
  }
}

.trophy-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
}

.champion-subtitle {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-gold);
}

.champion-name {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  word-break: break-word;
  line-height: 1.2;
}

.champion-status-pending {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-style: italic;
}

/* Partido por el tercer puesto */
.third-place-box {
  margin-top: 2rem;
  width: 100%;
}

.third-place-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

/* ==========================================================================
   Canvas de confeti para victoria
   ========================================================================== */
.confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* ==========================================================================
   Modales canónicos (Accesibles, sin window.alert)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  transform: scale(0.95);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-modal-close:hover {
  color: var(--text-main);
  background: var(--slot-hover);
}

.modal-body {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
}

@media (max-width: 500px) {
  .modal-footer {
    flex-direction: column;
  }
  .modal-footer button {
    width: 100%;
    min-height: 42px;
  }
}

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  height: 40px;
  padding: 0 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-danger {
  background: var(--accent-danger);
  border: none;
  color: #ffffff;
  height: 40px;
  padding: 0 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover {
  background: var(--accent-danger-hover);
}

/* Lista de torneos guardados en modal */
.tournaments-saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.saved-tournament-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  transition: border-color 0.15s;
}

.saved-tournament-item:hover {
  border-color: var(--accent-primary);
}

.saved-tournament-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.saved-tournament-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.saved-tournament-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: flex;
  gap: 0.5rem;
}

.saved-tournament-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

/* ==========================================================================
   Guía SEO y Preguntas Frecuentes
   ========================================================================== */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-top: 2rem;
  box-shadow: var(--shadow-sm);
}

.seo-guide-title {
  font-size: 1.35rem;
  margin-bottom: 1rem;
  color: var(--text-main);
}

.seo-guide-content p {
  font-size: 0.925rem;
  line-height: 1.65;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.seo-grid-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0 2rem;
}

.seo-feature-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.seo-feature-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.seo-feature-title svg {
  color: var(--accent-primary);
}

.seo-feature-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* FAQ Accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 1rem;
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.faq-answer {
  padding: 0 1rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
  display: none;
}

.faq-item.active .faq-answer {
  display: block;
}

.faq-item.active .faq-question svg {
  transform: rotate(180deg);
}

/* ==========================================================================
   Modo Impresión (@media print)
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .fijate-footer,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .tool-breadcrumbs,
  .view-tabs,
  .bracket-toolbar,
  .mobile-round-selector,
  .seo-guide-section,
  .modal-overlay,
  .btn-tool,
  .zoom-controls {
    display: none !important;
  }

  .tool-layout {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card-main {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    background: #ffffff !important;
  }

  .bracket-viewport {
    height: auto !important;
    max-height: none !important;
    border: none !important;
    overflow: visible !important;
    box-shadow: none !important;
    background: #ffffff !important;
  }

  .bracket-canvas {
    transform: scale(0.9) !important;
    transform-origin: top left !important;
    padding: 0 !important;
  }

  .match-card {
    background: #ffffff !important;
    border: 1px solid #999999 !important;
    color: #000000 !important;
  }

  .match-header-bar {
    background: #eeeeee !important;
    color: #333333 !important;
    border-bottom: 1px solid #cccccc !important;
  }

  .participant-name {
    color: #000000 !important;
  }

  .seed-badge {
    background: #dddddd !important;
    color: #000000 !important;
  }

  .connector-line {
    stroke: #666666 !important;
  }

  .champion-card {
    background: #ffffff !important;
    border: 2px solid #333333 !important;
    color: #000000 !important;
    box-shadow: none !important;
  }

  @page {
    size: landscape;
    margin: 10mm;
  }
}
