/* --- Variables de Diseño --- */
    :root {
      --bg-principal: #f4f6f9;
      --bg-card: #ffffff;
      --primary: #1e3a8a;
      --primary-hover: #172554;
      --accent: #dc2626;
      --accent-hover: #991b1b;
      --text-main: #1f2937;
      --text-muted: #4b5563;
      --border-color: #94a3b8;
      --line-color: #94a3b8;
      --radius: 8px;
      --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background-color: var(--bg-principal);
      color: var(--text-main);
      padding: 20px;
      transform-origin: top left;
      transform: scale(var(--zoom));
    }

    /* --- Buscador --- */
    #buscador {
      display: flex;
      flex-wrap: wrap;
      flex-direction: column;
      gap: 16px;
      padding: 20px;
      background: var(--bg-card);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      align-items: center;
      margin-bottom: 30px;
    }

    /* --- Buscador --- */
    #buscador div {
      display: flex;
      flex-direction: row;
      gap: 16px;
      padding: 20px;
      background: var(--bg-card);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      align-items: center;
    }

    #buscador label {
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--text-muted);
      text-transform: uppercase;
    }

    #buscador select {
      font-size: 0.95rem;
      padding: 8px 12px;
      border: 1px solid var(--border-color);
      border-radius: 6px;
      width: 100%;
    }

    #buscador div select {
      font-size: 0.95rem;
      padding: 8px 12px;
      border: 1px solid var(--border-color);
      border-radius: 6px;
    }

    #buscador button {
      padding: 9px 20px;
      background: var(--primary);
      color: white;
      border: none;
      border-radius: 6px;
      font-weight: bold;
      cursor: pointer;
      width: stretch;
    }

    #buscador button:hover {
      background: var(--primary-hover);
    }

    /* --- Estructura del Torneo --- */
    .titulo {
      font-size: 1rem;
      font-weight: 800;
      color: var(--primary);
      margin: 20px 0;
      border-left: 5px solid var(--primary);
      padding-left: 12px;
    }

    .pantalla {
      max-width: 100%;
      width: fit-content;
      height: fit-content;
      overflow-x: auto;
      /* Permite scroll si el árbol es muy ancho */
      background: var(--bg-card);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 5px;
      padding-top: 0px;
      padding-bottom: 50px;
      margin-bottom: 40px;
    }

    /* Envoltorio para alinear correctamente el Grid y el SVG */
    .bracket-wrapper {
      position: relative;
      width: fit-content;
      min-width: 100%;
    }

    .grid {
      display: grid;
      direction: rtl;
      justify-items: start;
      gap: 0px 20px;
      width: fit-content;
      /* 50px de espacio horizontal para las líneas SVG */
      position: relative;
      z-index: 2;
      /* El Grid va por encima de las líneas */
    }

    /* Capa SVG para las líneas de unión */
    .lineas-svg {
      position: absolute;
      top: 0;
      left: 0;
      z-index: 1;
      pointer-events: none;
      /* Que no estorbe los clics en los vídeos */
    }

    /* --- Celdas de Combate --- */
    .celda {
      justify-content: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0px;
      height: 40px;
      width: 300px;
      min-width: 200px;

    }

    .celda-ronda {
      justify-content: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0px;
      height: 40px;
      width: 300px;
      min-width: 200px;
      position: relative;
      top: 10px;
      color: var(--text-muted);
      border-bottom: 2px solid var(--border-color);
      font-weight: 600;
    }

    .celda-div {
      justify-content: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      height: fit-content;
      width: fit-content;
      min-width: 200px;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);

      background: #fafafa;
      border: 2px solid var(--border-color);

      border-radius: 12px;
      padding: 3px;
      gap: 3px;
      padding-left: 5px;
    }

    .celda-row {
      justify-content: center;
      display: flex;
      flex-direction: row-reverse;
      align-items: center;
      min-width: 200px;
      text-align: center;
      width: stretch;
      background: #fafafa;
      color: inherit;
      cursor: pointer;
      text-decoration: inherit;

    }

    .nombre-txt {
      font-size: 0.8rem;
      font-weight: 400;
      width: 200px;
      height: fit-content;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
      direction: ltr;
      padding-left: 5px;
      text-decoration: underline;
    }

    .com-txt {
      font-size: 0.8rem;
      font-weight: 400;
      width: 40px;
      padding: 2px;
    }

    .com-img {
      width: 100%;
      height: 100%;
      display: block;
      box-shadow: 0 2px 4px rgb(51 56 93 / 62%);
    }

    .res-txt {
      font-size: 0.8rem;
      font-weight: 400;
      width: 25px;
    }

    .combate-img {
      width: 100%;
      max-height: 70px;
      object-fit: contain;
      height: 100px;
    }

    .boton-video {
      font-size: 0.75rem;
      font-weight: 600;
      background: var(--accent);
      color: white;
      padding: 6px 12px;
      border: none;
      border-radius: 0px;
      cursor: pointer;
      width: 100%;
      text-align: center;
    }

    .cascada {
      margin-left: 5%;
    }

    .boton-video:hover {
      background: var(--accent-hover);
    }