<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <title><%= title %></title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #dceafd;
      margin: 0;
      padding: 20px;
    }

    .chart-title {
      text-align: center;
      font-size: 24px;
      font-weight: bold;
      padding: 10px 0;
    }

    table.grid-container {
      width: 100%;
      border-collapse: collapse;
      background-color: #ffffff;
      table-layout: fixed;
    }

    table.grid-container th,
    table.grid-container td {
      border: 1px solid #aaa;
      padding: 10px;
      text-align: center;
      vertical-align: middle;
      font-size: 14px;
      word-wrap: break-word;
    }

    table.grid-container th {
      background-color: #f2f2f2;
      font-weight: bold;
    }

    table.grid-container td p {
      margin: 2px 0;
    }

    table.grid-container th:first-child,
    table.grid-container td:first-child {
      background-color: #f9f9f9;
      font-weight: bold;
      width: 150px;
      max-width: 150px;
      white-space: normal;
    }
  </style>
</head>

<body>
  <div class="chart-title"><%= banner_title %></div>

  <table class="grid-container">
    <!-- Header row -->
    <tr>
      <th>Date</th>
      <% chartData.forEach(game => { %>
      <th><%= game.game_name %></th>
      <% }) %>
    </tr>

    <!-- Data rows -->
    <% 
      const totalDates = chartData[0]?.data.length || 0;
      for (let i = 0; i < totalDates; i++) { 
    %>
    <tr>
      <td><%= chartData[0].data[i].result_date %></td>

      <% chartData.forEach(game => { 
          const entry = game.data[i];
        %>
      <td>
        <p><%= entry.open_number || '***' %></p>
        <p><%= entry.digit || '*' %></p>
      </td>
      <% }) %>
    </tr>
    <% } %>
  </table>
</body>

</html>