:root {
      color-scheme: light;
      --bg: #ffffff;
      --text: #000000;
      --muted: #555555;
      --border: #c0c0c0;
      --th-bg: #f0f0f0;
      --th-bg-hover: #d0d0d0;
      --positive: #1a7a1a;
      --negative: #b30000;
    }

    html.dark {
      color-scheme: dark;
      --bg: #121212;
      --text: #e6e6e6;
      --muted: #9e9e9e;
      --border: #3d3d3d;
      --th-bg: #242424;
      --th-bg-hover: #383838;
      --positive: #66bb6a;
      --negative: #ef5350;
    }

    body {
      background-color: var(--bg);
      color: var(--text);
    }

    table {
      border-collapse: separate;
      border-spacing: 0;
      border-top: 1px solid var(--border);
      border-left: 1px solid var(--border);
    }
    th, td {
      border-right: 1px solid var(--border);
      border-bottom: 1px solid var(--border);
    }

    th {
      position: sticky;
      top: 0;
      z-index: 1;
      cursor: pointer;
      background-color: var(--th-bg);
    }
    th:hover {
      background-color: var(--th-bg-hover);
    }

    #last-updated {
      font-size: 0.9em;
      color: var(--muted);
    }

    .site-header {
      position: relative;
      text-align: center;
      padding: 40px 16px 24px;
    }

    #theme-toggle {
      cursor: pointer;
      padding: 4px 12px;
      font-size: 0.9em;
      border: 1px solid var(--border);
      border-radius: 4px;
      background-color: var(--th-bg);
      color: var(--text);
    }
    #theme-toggle:hover {
      background-color: var(--th-bg-hover);
    }

    .table-scroll {
      max-width: 100%;
      max-height: 75vh;
      overflow: auto;
    }

    .wp-high {
      color: var(--positive);
      font-weight: bold;
    }
    .wp-low {
      color: var(--negative);
    }

    .change-up {
      color: var(--positive);
    }
    .change-down {
      color: var(--negative);
    }
  
    body { margin: 0; font-family: system-ui, sans-serif; }
    .site-header h1 { margin: 0 0 16px; font-size: clamp(1.7rem, 5vw, 2.25rem); }
    nav { display: flex; justify-content: center; gap: 24px; }
    nav a { color: var(--muted); text-decoration: none; padding: 6px 0; }
    nav a:hover, nav a[aria-current="page"] { color: var(--text); }
    nav a[aria-current="page"] { border-bottom: 2px solid var(--text); font-weight: 600; }
    #theme-toggle { position: absolute; top: 16px; right: 16px; }
    main { box-sizing: border-box; width: 100%; margin: 0 auto; padding: 0 16px 32px; }
    .rankings-page { max-width: 880px; }
    .games-page { max-width: 1120px; }
    #last-updated, .games-page h2, .games-note { text-align: center; }
    #last-updated { margin: 0 0 20px; }
    .games-page h2 { margin: 0 0 20px; font-size: 1.25rem; }
    table { width: 100%; font-size: 0.9rem; }
    th, td { padding: 10px 12px; white-space: nowrap; }
    th { font-weight: 600; }
    td { text-align: right; }
    #csvTable td:nth-child(3), #gamesTable td:first-child, #gamesTable td:nth-child(3) { text-align: left; }
    .games-note { font-style: italic; font-size: 0.85rem; color: var(--muted); }
    :focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
    .mobile-table-hint, .mobile-games-sort { display: none; }
    @media (max-width: 600px) {
      .site-header { display: flex; flex-direction: column; align-items: center; padding: 24px 12px 20px; }
      .site-header h1 { font-size: clamp(1.4rem, 7vw, 1.9rem); }
      nav { gap: 20px; flex-wrap: wrap; }
      nav a { display: flex; align-items: center; min-height: 44px; padding: 0 4px; }
      #theme-toggle { position: static; min-height: 44px; margin-top: 16px; }
      main { padding: 0 12px 24px; min-width: 0; }
      th, td { padding: 10px 8px; }
      th { min-width: 44px; }
      .mobile-table-hint { display: block; margin: 0 0 12px; text-align: center; color: var(--muted); font-size: 0.8rem; }
      .table-scroll { -webkit-overflow-scrolling: touch; }
      #csvTable td:nth-child(3), #csvTable th:nth-child(3) { position: sticky; left: 0; background: var(--bg); }
      #csvTable th:nth-child(3) { background: var(--th-bg); z-index: 2; }
      .mobile-games-sort { display: grid; gap: 8px; margin-bottom: 16px; font-size: 0.9rem; }
      #games-sort { box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px; padding: 8px; font: inherit; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 4px; }
      .games-page .table-scroll { max-height: none; overflow: visible; }
      #gamesTable { display: block; border: 0; }
      #gamesTable thead { display: none; }
      #gamesBody { display: grid; gap: 16px; }
      #gamesBody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
      #gamesBody td { border: 0; padding: 12px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
      #gamesBody td::before { content: attr(data-label); display: block; margin-bottom: 4px; font-size: 0.75rem; font-weight: normal; color: var(--muted); }
      #gamesBody td:first-child, #gamesBody td:nth-child(4) { grid-column: 1 / -1; }
      #gamesBody td:first-child { background: var(--th-bg); font-weight: 600; }
      #gamesBody td[colspan]::before { content: none; }
    }
