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

    /* ── Dark theme (default) ── */
    :root {
      --bg: #0a0a0a;
      --surface: #141414;
      --surface2: #1e1e1e;
      --border: #282828;
      --accent: #c8102e;
      --accent-dim: #8b0b20;
      --accent-glow: rgba(200,16,46,0.18);
      --text: #ebebeb;
      --muted: #666;
      --win: #f0c040;
      --font: 'DM Mono', 'Consolas', monospace;
      --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    }

    /* ── Light theme overrides ── */
    html[data-theme="light"] {
      --bg: #f0f0f0;
      --surface: #ffffff;
      --surface2: #e4e4e4;
      --border: #cccccc;
      --accent: #c8102e;
      --accent-dim: #8b0b20;
      --accent-glow: rgba(200,16,46,0.10);
      --text: #111111;
      --muted: #777777;
      --win: #c49a00;
    }

    html[data-theme="light"] tbody tr:hover { background: rgba(0,0,0,0.03); }
    html[data-theme="light"] mark { color: #8b0020; }
    html[data-theme="light"] .field-group select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23444' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    }
    /* Black belt on light bg needs a subtle border */
    html[data-theme="light"] .belt-btn[data-belt="black"] { box-shadow: 0 0 0 1px #aaa; }

    body {
      background: var(--bg);
      color: var(--text);
      font-family: var(--font);
      font-size: 13px;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      -webkit-text-size-adjust: 100%;
    }

    /* ── Header ── */
    header {
      background: var(--surface);
      border-bottom: 2px solid var(--accent);
      padding: 10px 16px;
      display: flex;
      align-items: center;
      gap: 10px;
      position: sticky;
      top: 0;
      z-index: 100;
      overflow: hidden;
    }

    header h1 {
      font-family: var(--font-display);
      font-size: 20px;
      font-weight: 700;
      letter-spacing: 1px;
      text-transform: uppercase;
      flex-shrink: 0;
    }

    .badge {
      font-family: var(--font-display);
      font-size: 11px;
      font-weight: 700;
      background: var(--accent);
      color: #fff;
      padding: 2px 8px;
      border-radius: 3px;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      max-width: 160px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      flex-shrink: 1;
      min-width: 0;
    }

    #change-source-btn {
      display: none;
      background: none;
      border: 1px solid var(--border);
      color: var(--muted);
      padding: 4px 10px;
      border-radius: 4px;
      cursor: pointer;
      font-family: var(--font-display);
      font-size: 12px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      transition: border-color 0.15s, color 0.15s;
      white-space: nowrap;
      flex-shrink: 0;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }
    #change-source-btn:hover { border-color: var(--accent); color: var(--text); }

    #header-right {
      margin-left: auto;
      display: flex;
      align-items: center;
      gap: 6px;
      flex-shrink: 0;
    }

    #theme-btn {
      background: none;
      border: 1px solid var(--border);
      color: var(--text);
      padding: 4px 8px;
      border-radius: 4px;
      cursor: pointer;
      font-size: 16px;
      line-height: 1;
      flex-shrink: 0;
      transition: border-color 0.15s;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }
    #theme-btn:hover { border-color: var(--accent); }

    #lang-btns { display: flex; gap: 4px; flex-shrink: 0; }
    .lang-btn {
      background: none;
      border: 1px solid var(--border);
      color: var(--text);
      padding: 3px 7px;
      border-radius: 4px;
      cursor: pointer;
      font-size: 14px;
      line-height: 1.4;
      transition: border-color 0.15s, opacity 0.15s;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
      opacity: 0.55;
    }
    .lang-btn:hover { border-color: var(--accent); opacity: 0.85; }
    .lang-btn.active { border-color: var(--accent); opacity: 1; }

    /* ── Championship info bar ── */
    #champ-info {
      display: none;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      padding: 7px 16px;
      flex-wrap: wrap;
      align-items: center;
      gap: 6px 18px;
    }
    #champ-info.visible { display: flex; }

    .ci-label {
      font-family: var(--font-display);
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.6px;
      color: var(--muted);
    }
    .ci-stat {
      font-family: var(--font);
      font-size: 12px;
      color: var(--muted);
    }
    .ci-stat strong { color: var(--text); font-weight: 500; }

    /* ── Drop zone ── */
    #load-zone {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 16px;
      padding: 40px 16px;
    }
    #load-zone.hidden { display: none; }

    .drop-box {
      border: 2px dashed var(--border);
      border-radius: 8px;
      padding: 40px 48px;
      text-align: center;
      cursor: pointer;
      transition: border-color 0.15s, background 0.15s;
      max-width: 400px;
      width: 100%;
    }
    .drop-box:hover, .drop-box.drag-over {
      border-color: var(--accent);
      background: var(--accent-glow);
    }
    .drop-box svg { width: 40px; height: 40px; color: var(--muted); margin-bottom: 10px; }
    .drop-box p { color: var(--muted); font-family: var(--font-display); font-size: 16px; }
    .drop-box p strong { color: var(--text); }
    #file-input { display: none; }

    .btn {
      background: var(--accent);
      color: #fff;
      border: none;
      padding: 10px 22px;
      border-radius: 4px;
      cursor: pointer;
      font-family: var(--font-display);
      font-size: 15px;
      font-weight: 700;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      transition: background 0.15s;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }
    .btn:hover, .btn:active { background: var(--accent-dim); }

    /* ── Main ── */
    #main { display: none; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; }
    #main.visible { display: flex; }

    /* ── Mobile filter toggle ── */
    #filter-toggle {
      display: none;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      padding: 10px 16px;
      align-items: center;
      justify-content: space-between;
      cursor: pointer;
      user-select: none;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }
    .ftog-left { display: flex; align-items: center; gap: 8px; }
    .ftog-label {
      font-family: var(--font-display);
      font-size: 13px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--muted);
    }
    #filter-active-badge {
      background: var(--accent);
      color: #fff;
      font-family: var(--font-display);
      font-size: 11px;
      font-weight: 700;
      padding: 1px 7px;
      border-radius: 10px;
      display: none;
    }
    #filter-active-badge.on { display: inline-block; }
    .ftog-right { display: flex; align-items: center; gap: 8px; }
    #mobile-count { font-family: var(--font); font-size: 12px; color: var(--muted); }
    #mobile-count .n { color: var(--text); font-weight: 500; }
    #filter-chevron {
      color: var(--muted);
      font-size: 18px;
      line-height: 1;
      transition: transform 0.2s;
    }
    #filter-chevron.open { transform: rotate(180deg); }

    /* ── Search bar ── */
    #search-bar {
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      padding: 10px 16px;
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      align-items: flex-end;
      overflow: hidden;        /* prevent horizontal scroll at medium widths */
    }
    #search-bar.mob-collapsed { display: none; }

    .field-group {
      display: flex;
      flex-direction: column;
      gap: 4px;
      flex: 1 1 150px;
      max-width: 220px;
      min-width: 0;
    }
    .field-group label {
      font-family: var(--font-display);
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--muted);
    }
    .field-group input[type="text"],
    .field-group select {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 4px;
      color: var(--text);
      padding: 6px 10px;
      font-family: var(--font);
      font-size: 13px;
      width: 100%;
      height: 32px;
      transition: border-color 0.15s;
      -webkit-appearance: none;
      appearance: none;
    }
    .field-group select {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 9px center;
      padding-right: 26px;
    }
    .field-group input:focus, .field-group select:focus { outline: none; border-color: var(--accent); }
    .field-group input.invalid { border-color: #e06c6c; }

    .quick-filter-group {
      display: flex;
      flex-direction: column;
      gap: 4px;
      flex: 0 0 auto;
    }
    .quick-filter-group > label {
      font-family: var(--font-display);
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--muted);
    }
    .btn-row { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

    .belt-btn {
      font-family: var(--font-display);
      font-size: 13px;
      font-weight: 700;
      padding: 4px 9px;
      border-radius: 4px;
      border: none;
      cursor: pointer;
      outline: 2px solid transparent;
      outline-offset: 2px;
      transition: outline 0.1s;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }
    .belt-btn.active { outline: 2px solid #fff; }
    .belt-btn[data-belt="white"].active  { outline-color: #777; }
    .belt-btn[data-belt="gray"].active   { outline-color: #444; }
    .belt-btn[data-belt="yellow"].active { outline-color: #9a7000; }

    .gender-btn {
      font-family: var(--font-display);
      font-size: 13px;
      font-weight: 700;
      padding: 4px 10px;
      border-radius: 4px;
      border: none;
      cursor: pointer;
      background: var(--border);
      color: var(--text);
      transition: background 0.1s;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
    }
    .gender-btn.active { background: var(--accent); color: #fff; }

    .toggle-group {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 3px;
      color: var(--muted);
      cursor: pointer;
      user-select: none;
      font-family: var(--font-display);
      font-size: 13px;
      flex: 0 0 auto;
    }
    .toggle-group input { accent-color: var(--accent); cursor: pointer; }

    #status {
      margin-left: auto;
      margin-bottom: 3px;
      color: var(--muted);
      font-family: var(--font-display);
      font-size: 13px;
      white-space: nowrap;
      flex: 0 0 auto;
    }
    #status .count { color: var(--text); font-weight: 600; }

    #clear-btn {
      background: none;
      border: 1px solid var(--border);
      color: var(--muted);
      padding: 5px 12px;
      height: 32px;
      border-radius: 4px;
      cursor: pointer;
      font-family: var(--font-display);
      font-size: 12px;
      font-weight: 700;
      letter-spacing: 0.5px;
      text-transform: uppercase;
      transition: border-color 0.15s, color 0.15s;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
      flex: 0 0 auto;
    }
    #clear-btn:hover { border-color: var(--accent); color: var(--text); }

    /* ── Table ── */
    #table-wrap {
      flex: 1;
      overflow: auto;
      -webkit-overflow-scrolling: touch;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      table-layout: fixed;
    }

    thead th {
      position: sticky;
      top: 0;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      padding: 7px 10px;
      text-align: left;
      font-family: var(--font-display);
      font-size: 11px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.8px;
      color: var(--muted);
      white-space: nowrap;
    }

    thead th:nth-child(1) { width: 60px; }
    thead th:nth-child(2) { width: 18%; }
    thead th:nth-child(3) { width: 41%; }
    thead th:nth-child(4) { width: 41%; }

    tbody tr {
      border-bottom: 1px solid var(--border);
      transition: background 0.1s;
    }
    tbody tr:hover { background: #ffffff06; }

    td {
      padding: 8px 10px;
      vertical-align: middle;
      overflow: hidden;
    }

    /* Links cell */
    .td-links { text-align: center; }
    .links-inner {
      display: flex;
      gap: 4px;
      align-items: center;
      justify-content: center;
    }

    .yt-link {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 26px;
      height: 22px;
      background: var(--accent);
      border-radius: 3px;
      color: #fff;
      text-decoration: none;
      font-family: var(--font-display);
      font-size: 11px;
      font-weight: 700;
      transition: background 0.15s;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
      flex-shrink: 0;
    }
    .yt-link:hover, .yt-link:active { background: var(--accent-dim); }
    .yt-link.end { background: var(--surface2); color: var(--muted); }
    .yt-link.end:hover, .yt-link.end:active { background: var(--border); color: var(--text); }

    /* Info cell */
    .info-inner {
      display: flex;
      flex-direction: column;
      gap: 3px;
      overflow: hidden;
    }

    .phase-badge {
      display: inline-block;
      font-family: var(--font-display);
      font-size: 10px;
      font-weight: 700;
      padding: 1px 5px;
      border-radius: 3px;
      background: var(--accent-dim);
      color: #fff;
      text-transform: uppercase;
      letter-spacing: 0.5px;
      white-space: nowrap;
      width: fit-content;
    }

    .div-str {
      font-family: var(--font-display);
      font-size: 12px;
      color: var(--muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* Competitor cells */
    .comp-name-row {
      display: flex;
      align-items: center;
      gap: 4px;
      overflow: hidden;
    }
    .comp-name {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      font-size: 13px;
    }
    .win-star {
      color: var(--win);
      flex-shrink: 0;
      font-size: 12px;
      line-height: 1;
    }
    .comp-team {
      color: var(--muted);
      font-size: 11px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      margin-top: 1px;
    }

    /* Grid areas — used only in mobile where tr is a CSS grid */
    .td-links { grid-area: links; }
    .td-info  { grid-area: info; }
    .td-c1    { grid-area: c1; }
    .td-c2    { grid-area: c2; }

    mark {
      background: rgba(200,16,46,0.25);
      color: #ffb3b3;
      border-radius: 2px;
      padding: 0 1px;
    }

    /* ── Empty state ── */
    #empty {
      display: none;
      padding: 60px 20px;
      text-align: center;
      color: var(--muted);
      font-family: var(--font-display);
      font-size: 18px;
      letter-spacing: 0.5px;
    }
    #empty.visible { display: block; }

    /* ══════════════════════════════════════════════
       MOBILE  ≤ 640 px
    ══════════════════════════════════════════════ */
    @media (max-width: 640px) {
      header h1 { font-size: 17px; }
      header .badge { max-width: 100px; font-size: 10px; }

      #filter-toggle { display: flex; }

      #search-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 14px 16px;
        gap: 14px;
        max-height: 80vh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
      }

      /* Prevent iOS auto-zoom (font-size must be ≥ 16px) */
      .field-group input[type="text"],
      .field-group select {
        width: 100%;
        max-width: none;
        font-size: 16px;
        height: 44px;
        padding: 0 12px;
      }
      .field-group select { padding-right: 32px; }
      .field-group { flex: unset; max-width: none; width: 100%; }
      .quick-filter-group { width: 100%; }

      .belt-btn { padding: 8px 11px; font-size: 14px; }
      .gender-btn { padding: 8px 14px; font-size: 14px; }
      .btn-row { gap: 8px; }

      .toggle-group { font-size: 14px; }
      #status { margin-left: 0; }
      #clear-btn { width: 100%; height: 44px; font-size: 14px; }

      #champ-info { padding: 8px 16px; gap: 4px 14px; }
      .ci-label { font-size: 11px; }
      .ci-stat { font-size: 11px; }

      /* ── Table → fight cards ── */
      #table-wrap { overflow: visible; }
      table { display: block; }
      thead { display: none; }

      tbody {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding: 12px;
      }

      tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto auto;
        grid-template-areas:
          "info  links"
          "c1    links"
          "c2    links";
        border: 1px solid var(--border);
        border-bottom: 1px solid var(--border) !important;
        border-radius: 8px;
        background: var(--surface);
        padding: 12px;
        row-gap: 6px;
        column-gap: 10px;
      }
      tbody tr:hover { background: var(--surface); }

      td {
        padding: 0;
        overflow: visible;
        text-overflow: unset;
        white-space: normal;
      }

      .td-links {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding-left: 6px;
      }
      .links-inner { flex-direction: column; gap: 8px; }
      .yt-link { width: 38px; height: 34px; font-size: 14px; }

      .info-inner {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 8px;
        overflow: visible;
      }
      .div-str {
        white-space: normal;
        word-break: break-word;
        overflow: visible;
        font-size: 12px;
      }

      .comp-name-row { overflow: visible; }
      .comp-name {
        white-space: normal;
        word-break: break-word;
        overflow: visible;
        font-size: 15px;
      }
      .win-star { font-size: 14px; }
      .comp-team {
        font-size: 12px;
        white-space: normal;
        overflow: visible;
        margin-top: 2px;
      }
    }

    /* ── Very small (≤360 px) ── */
    @media (max-width: 360px) {
      header h1 { font-size: 15px; }
      header .badge { display: none; }
      .comp-name { font-size: 14px; }
      .belt-btn { padding: 7px 8px; font-size: 12px; }
    }
