/* Viewer + shared tokens. Admin adds admin.css on top of this file. */
:root {
      --bg: #0f0f12;
      --surface: #18181d;
      --surface-hover: #222228;
      --border: #2a2a32;
      --text: #e8e6e3;
      --text-muted: #8b8685;
      --accent: #c9a227;
      --accent-dim: #8b7320;
      --success: #4a9b6e;
      --danger: #c75c5c;
      --warning: #c9a227;
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      font-family: 'Outfit', system-ui, sans-serif;
      background: var(--bg);
      color: var(--text);
      min-height: 100vh;
      min-height: 100dvh;
      line-height: 1.5;
      overflow-x: clip;
      color-scheme: dark;
    }

    .layout {
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    main {
      padding: 2rem;
      max-width: 1200px;
      margin: 0 auto;
      width: 100%;
      flex: 1;
    }

    .site-footer {
      margin-top: auto;
      padding: 0.85rem 1.5rem 1.25rem;
      text-align: center;
      border-top: 1px solid var(--border);
      background: var(--surface);
    }

    .last-updated {
      margin: 0;
      font-size: 0.8rem;
      color: var(--text-muted);
      letter-spacing: 0.01em;
    }

    .last-updated time {
      color: var(--text);
      font-variant-numeric: tabular-nums;
    }

    @media (max-width: 768px) {
      main {
        padding: 1rem;
      }

      .site-footer {
        padding: 0.75rem 1rem 1rem;
      }

      h1 {
        font-size: 1.5rem;
      }

      .subtitle {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
      }

      .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
      }

      .tabs::-webkit-scrollbar {
        display: none;
      }

      .tab {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        white-space: nowrap;
      }

      .search-bar input {
        max-width: 100%;
        font-size: 1rem;
        padding: 0.7rem 1rem;
      }

      .filter-field {
        flex: 1 1 140px;
        min-width: 0;
      }

      .filter-field input[type="date"],
      .filter-field input[type="search"],
      .filter-field select,
      .country-filter,
      .country-filter-toggle {
        min-width: 0;
        width: 100%;
        max-width: 100%;
      }

      .card-search-field,
      .card-search-field input,
      .card-search-controls > input {
        max-width: 100%;
      }

      .tournament-header {
        flex-wrap: wrap;
        padding: 1rem 1.1rem;
      }

      .tournament-name {
        font-size: 0.95rem;
        flex: 1;
        min-width: 0;
      }

      .tournament-meta {
        font-size: 0.75rem;
        gap: 0.75rem;
        flex-wrap: wrap;
      }

      .standings {
        padding: 0.85rem 1rem 1.1rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
      }

      .standings-table {
        font-size: 0.85rem;
        min-width: 0;
      }

      .standings-table th {
        font-size: 0.7rem;
        padding: 0.4rem 0.5rem 0.4rem 0;
      }

      .standings-table td {
        padding: 0.5rem 0.5rem 0.5rem 0;
      }

      .deck-name {
        max-width: none;
        font-size: 0.8rem;
      }

      .deck-icon {
        width: 32px;
        height: 32px;
      }

      .btn-deck-image {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
        min-height: 32px;
      }

      .player-row,
      .deck-row {
        padding: 0.9rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
      }

      .player-row .player-name-link,
      .deck-row .deck-name-link {
        flex: 1;
        min-width: 0;
      }

      .player-row .player-events,
      .deck-row .deck-results-count {
        font-size: 0.85rem;
      }

      .pagination {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-top: 1rem;
      }

      .pagination-info {
        font-size: 0.8rem;
        margin: 0 0.25rem;
      }

      .pagination-btn {
        padding: 0.5rem 0.65rem;
        font-size: 0.85rem;
        min-height: 36px;
      }

      .pagination-page-size {
        margin-left: 0;
        width: 100%;
        justify-content: center;
      }

      .pagination-page-size select {
        min-height: 36px;
      }


      .page-header {
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
      }

      .page-title {
        font-size: 1.25rem;
      }

      .back-button {
        padding: 0.5rem 0.65rem;
        font-size: 0.85rem;
      }

      .player-result-card {
        padding: 0.9rem 1rem;
        margin-bottom: 0.5rem;
        gap: 0.5rem;
      }

      .player-result-card-header {
        gap: 0.75rem;
      }

      .player-result-card .event-name {
        font-size: 0.85rem;
        line-height: 1.3;
      }

      .player-result-card .event-date {
        font-size: 0.7rem;
        margin-bottom: 0.3rem;
      }

      .player-result-card .placing-record {
        font-size: 0.75rem;
      }

      .player-result-card .deck-name {
        font-size: 0.7rem;
        margin-top: 0.2rem;
      }

      .player-result-card-actions {
        gap: 0.4rem;
        margin-top: 0.2rem;
      }

      .player-result-card .btn-deck-image {
        padding: 0.4rem 0.65rem;
        font-size: 0.75rem;
        min-height: 32px;
      }

      .deck-result-card .player-name-inline {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
      }

      .modal-overlay {
        padding: 1rem;
      }

      .modal-content {
        max-height: calc(100vh - 2rem);
      }

      .modal-header {
        padding: 0.875rem 1rem;
      }

      .modal-body {
        padding: 0.75rem;
      }

      .decklist-pre {
        font-size: 0.75rem;
        padding: 0.75rem;
        max-height: 50vh;
      }

      .modal-actions {
        gap: 0.5rem;
      }

      .modal-actions .btn-deck-image {
        padding: 0.5rem 0.65rem;
        font-size: 0.8rem;
        min-height: 36px;
      }

      .decklist-content-row {
        flex-direction: column;
      }

      .deck-image-result {
        max-width: 100%;
      }
    }

    @media (max-width: 480px) {
      main {
        padding: 0.75rem;
      }

      h1 {
        font-size: 1.25rem;
      }

      .tab {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
      }

      .tournament-header {
        padding: 0.95rem 1rem;
      }

      .tournament > .detail-filters,
      .tournament > .deck-sort-controls,
      .tournament > .matchup-note {
        padding-left: 0.95rem;
        padding-right: 0.95rem;
      }

      .tournament > .detail-filters,
      .tournament > .deck-sort-controls {
        padding-top: 0.9rem;
      }

      .tournament-detail-header {
        padding: 1rem;
      }

      .standings {
        padding: 0.75rem 0.95rem 1rem;
      }

      .standings-table {
        min-width: 0;
        font-size: 0.8rem;
      }

      .standings-table th {
        font-size: 0.65rem;
        padding: 0.35rem 0.4rem 0.35rem 0;
      }

      .standings-table td {
        padding: 0.4rem 0.4rem 0.4rem 0;
      }

      .deck-icon {
        width: 28px;
        height: 28px;
      }

      .deck-name {
        max-width: none;
        font-size: 0.75rem;
      }

      .btn-deck-image {
        padding: 0.35rem 0.5rem;
        font-size: 0.65rem;
        min-height: 28px;
      }

      .player-row,
      .deck-row {
        padding: 0.875rem 1rem;
      }

      .pagination-btn {
        padding: 0.45rem 0.6rem;
        font-size: 0.8rem;
        min-height: 32px;
      }

      .modal-overlay {
        padding: 0.5rem;
      }

      .modal-content {
        max-height: calc(100vh - 1rem);
        border-radius: 8px;
      }

      .modal-header {
        padding: 0.75rem;
      }

      .modal-body {
        padding: 0.5rem;
      }

      .decklist-pre {
        font-size: 0.7rem;
        padding: 0.5rem;
        max-height: 40vh;
      }


      .page-header {
        margin-bottom: 0.875rem;
        padding-bottom: 0.625rem;
      }

      .page-title {
        font-size: 1.1rem;
      }

      .back-button {
        padding: 0.45rem 0.6rem;
        font-size: 0.8rem;
      }

      .player-result-card {
        padding: 0.85rem 0.95rem;
        margin-bottom: 0.45rem;
        gap: 0.45rem;
      }

      .player-result-card-header {
        gap: 0.65rem;
      }

      .player-result-card .event-name {
        font-size: 0.8rem;
        line-height: 1.3;
      }

      .player-result-card .event-date {
        font-size: 0.65rem;
        margin-bottom: 0.25rem;
      }

      .player-result-card .placing-record {
        font-size: 0.7rem;
      }

      .player-result-card .deck-name {
        font-size: 0.65rem;
        margin-top: 0.2rem;
      }

      .player-result-card-actions {
        gap: 0.35rem;
        margin-top: 0.15rem;
      }

      .player-result-card .btn-deck-image {
        padding: 0.35rem 0.6rem;
        font-size: 0.7rem;
        min-height: 30px;
      }

      .deck-result-card .player-name-inline {
        font-size: 0.85rem;
        margin-bottom: 0.35rem;
      }
    }

    .tabs {
      display: flex;
      gap: 0;
      margin-bottom: 1.5rem;
      border-bottom: 1px solid var(--border);
    }

    .tab {
      background: none;
      border: none;
      border-bottom: 2px solid transparent;
      color: var(--text-muted);
      padding: 0.75rem 1.25rem;
      font-family: inherit;
      font-size: 1rem;
      font-weight: 500;
      cursor: pointer;
      margin-bottom: -1px;
      text-decoration: none;
      transition: color 0.15s, border-color 0.15s;
    }

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

    .tab:visited {
      color: var(--text-muted);
    }

    .tab.active,
    .tab.active:visited {
      color: var(--accent);
      border-bottom-color: var(--accent);
    }

    .tab-panel {
      display: none;
    }

    .tab-panel.active {
      display: block;
    }

    .page-section-tabs {
      margin-top: 0.15rem;
      margin-bottom: 1.15rem;
    }

    .tournament-pairings .pairing-round {
      margin-top: 0.75rem;
    }

    .pairing-round-nav {
      margin-bottom: 0.35rem;
    }

    .pairing-round-title {
      font-size: 1rem;
      font-weight: 600;
      color: var(--text);
      margin: 0 0 0.5rem;
    }

    .tournament-pairings td.pairing-cell,
    .matchup-games td.pairing-cell {
      border-radius: 4px;
    }

    .tournament-pairings td.pairing-result-win,
    .matchup-games td.pairing-result-win {
      background: rgba(74, 155, 110, 0.18);
    }

    .tournament-pairings td.pairing-result-loss,
    .matchup-games td.pairing-result-loss {
      background: rgba(199, 92, 92, 0.16);
    }

    .tournament-pairings td.pairing-result-tie,
    .matchup-games td.pairing-result-tie {
      background: rgba(201, 162, 39, 0.18);
    }

    .tournament-pairings td.pairing-result-bye {
      background: rgba(139, 134, 133, 0.12);
      color: var(--text-muted);
    }

    .tournament-pairings td.pairing-result-win .player-name,
    .tournament-pairings td.pairing-result-win .deck-name,
    .matchup-games td.pairing-result-win .player-name,
    .matchup-games td.pairing-result-win .deck-name {
      color: var(--success);
      font-weight: 600;
    }

    .tournament-pairings td.pairing-result-loss .player-name,
    .tournament-pairings td.pairing-result-loss .deck-name,
    .matchup-games td.pairing-result-loss .player-name,
    .matchup-games td.pairing-result-loss .deck-name {
      color: var(--danger);
      font-weight: 600;
    }

    .tournament-pairings td.pairing-result-tie .player-name,
    .tournament-pairings td.pairing-result-tie .deck-name,
    .matchup-games td.pairing-result-tie .player-name,
    .matchup-games td.pairing-result-tie .deck-name {
      color: var(--warning);
      font-weight: 600;
    }

    .tournament-pairings td.pairing-result-win .player-name:hover,
    .tournament-pairings td.pairing-result-win .deck-name:hover,
    .matchup-games td.pairing-result-win .player-name:hover,
    .matchup-games td.pairing-result-win .deck-name:hover {
      color: var(--success);
      filter: brightness(1.15);
    }

    .tournament-pairings td.pairing-result-loss .player-name:hover,
    .tournament-pairings td.pairing-result-loss .deck-name:hover,
    .matchup-games td.pairing-result-loss .player-name:hover,
    .matchup-games td.pairing-result-loss .deck-name:hover {
      color: var(--danger);
      filter: brightness(1.15);
    }

    .tournament-pairings td.pairing-result-tie .player-name:hover,
    .tournament-pairings td.pairing-result-tie .deck-name:hover,
    .matchup-games td.pairing-result-tie .player-name:hover,
    .matchup-games td.pairing-result-tie .deck-name:hover {
      color: var(--warning);
      filter: brightness(1.15);
    }

    .tournament-pairings td.pairing-result-bye .player-name {
      color: var(--text-muted);
      cursor: default;
    }

    .player-name.pairing-static-label,
    .player-name.pairing-static-label:hover {
      cursor: default;
      background: transparent;
    }

    .player-name.pairing-round-loss,
    .player-name.pairing-round-loss:hover,
    .tournament-pairings td.pairing-result-loss .player-name.pairing-round-loss,
    .tournament-pairings td.pairing-result-loss .player-name.pairing-round-loss:hover {
      color: var(--danger);
      font-weight: 600;
      cursor: default;
      background: transparent;
      filter: none;
    }

    .deck-sort-controls {
      display: flex;
      gap: 0.55rem;
      align-items: center;
      margin-bottom: 1rem;
      flex-wrap: wrap;
    }

    .deck-sort-label {
      font-size: 0.9rem;
      color: var(--text-muted);
    }

    .tab-panel .matchup-section {
      margin-bottom: 0;
    }

    .player-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.75rem 1rem;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      margin-bottom: 0.5rem;
      cursor: pointer;
      transition: background 0.15s;
    }

    .player-row:hover {
      background: var(--surface-hover);
    }

    .player-row .player-name-link {
      color: var(--accent);
      font-weight: 500;
      text-decoration: none;
    }

    .player-row .player-events {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.9rem;
      color: var(--text-muted);
    }

    .player-aka {
      margin: 0 0 1rem;
      color: var(--text-muted);
      font-size: 0.95rem;
    }

    .deck-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.9rem 1.05rem;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      margin-bottom: 0.5rem;
      cursor: pointer;
      transition: background 0.15s;
    }

    .deck-row:hover {
      background: var(--surface-hover);
    }

    .deck-row .deck-name-link {
      color: var(--accent);
      font-weight: 500;
      text-decoration: none;
    }

    .deck-row .deck-results-count {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.9rem;
      color: var(--text-muted);
    }

    .deck-result-card .player-name-inline {
      font-weight: 600;
      color: var(--accent);
      margin-bottom: 0.2rem;
      font-size: 0.85rem;
    }

    h1 {
      font-weight: 700;
      font-size: 1.75rem;
      letter-spacing: -0.02em;
      margin: 0 0 0.5rem;
      color: var(--accent);
    }

    .subtitle {
      color: var(--text-muted);
      margin-bottom: 1rem;
      font-size: 0.95rem;
      overflow-wrap: anywhere;
    }

    .search-bar {
      margin-bottom: 1.25rem;
    }

    .matchup-rate {
      display: flex;
      align-items: center;
      gap: 0.55rem;
      min-width: 0;
    }

    .search-bar input {
      width: 100%;
      max-width: 320px;
      padding: 0.6rem 0.85rem;
      font-family: inherit;
      font-size: 0.95rem;
      color: var(--text);
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      outline: none;
      transition: border-color 0.15s;
    }

    .filter-bar {
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
      margin-bottom: 1.25rem;
      position: relative;
      z-index: 6;
    }

    .filter-bar .search-bar {
      margin-bottom: 0;
    }

    .filter-row {
      display: flex;
      flex-wrap: wrap;
      gap: 0.85rem;
      align-items: flex-end;
    }

    .filter-field {
      display: grid;
      gap: 0.3rem;
      font-size: 0.85rem;
      color: var(--text-muted);
      min-width: 0;
    }

    .filter-field input[type="date"],
    .filter-field input[type="search"],
    .filter-field select {
      padding: 0.5rem 0.65rem;
      font-family: inherit;
      font-size: 0.9rem;
      color: var(--text);
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      min-width: 150px;
      max-width: 100%;
    }

    .filter-field select {
      min-width: 170px;
    }

    .visually-hidden {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    .country-flag {
      width: 24px;
      height: 18px;
      object-fit: cover;
      flex-shrink: 0;
      border-radius: 2px;
      vertical-align: middle;
    }

    .country-filter {
      position: relative;
      z-index: 5;
      min-width: 190px;
    }

    .country-filter-toggle {
      position: relative;
      display: flex;
      align-items: center;
      width: 100%;
      padding: 0.5rem 2rem 0.5rem 0.65rem;
      font-family: inherit;
      font-size: 0.9rem;
      color: var(--text);
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      cursor: pointer;
      text-align: left;
    }

    .country-filter-toggle:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 2px;
    }

    .country-filter-toggle::after {
      content: '';
      position: absolute;
      right: 0.75rem;
      top: 50%;
      width: 0.4rem;
      height: 0.4rem;
      margin-top: -0.3rem;
      border-right: 2px solid var(--text-muted);
      border-bottom: 2px solid var(--text-muted);
      transform: rotate(45deg);
      pointer-events: none;
    }

    .country-filter-value {
      display: flex;
      align-items: center;
      gap: 0.45rem;
      min-width: 0;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .country-filter-name {
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .country-filter-menu {
      position: absolute;
      z-index: 20;
      top: calc(100% + 4px);
      left: 0;
      min-width: max(100%, 13.5rem);
      width: max-content;
      max-width: min(24rem, calc(100vw - 2rem));
      max-height: 280px;
      overflow-y: auto;
      padding: 0.25rem;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 8px;
      box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    }

    .country-filter-option {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.4rem 0.55rem;
      border-radius: 6px;
      cursor: pointer;
      white-space: nowrap;
    }

    .country-filter-option:hover,
    .country-filter-option.active {
      background: var(--surface-hover);
    }

    .country-filter-option.selected {
      color: var(--accent);
    }

    .detail-filters {
      margin-bottom: 1rem;
    }

    .detail-filters .search-bar {
      margin-bottom: 0.75rem;
    }

    .detail-filters .search-bar input {
      max-width: 100%;
    }

    .card-standings-filter {
      margin-bottom: 0.75rem;
    }

    .card-standings-filter input {
      max-width: 280px;
    }

    .filter-empty {
      color: var(--text-muted);
      text-align: center;
      padding: 1.5rem 1rem;
      font-size: 0.9rem;
    }

    .search-bar input::placeholder {
      color: var(--text-muted);
    }

    .search-bar input:focus {
      border-color: var(--accent-dim);
    }

    .card-search-controls {
      display: flex;
      flex-wrap: wrap;
      gap: 0.75rem;
      align-items: center;
    }

    .card-search-field {
      position: relative;
      flex: 1 1 220px;
      max-width: 320px;
    }

    .card-search-field input,
    .card-search-controls > input {
      width: 100%;
      max-width: 320px;
    }

    .card-ignore-set {
      display: inline-flex;
      align-items: center;
      gap: 0.45rem;
      color: var(--text-muted);
      font-size: 0.9rem;
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
    }

    .card-ignore-set input {
      width: 1rem;
      height: 1rem;
      margin: 0;
      accent-color: var(--accent);
    }

    .card-printing-note {
      color: var(--text-muted);
      font-size: 0.875rem;
      margin: 0.35rem 0 0;
    }

    .cards-filter-note {
      color: var(--text-muted);
      margin-bottom: 1rem;
    }

    .cards-filter-note a {
      color: var(--accent);
      text-decoration: none;
    }

    .cards-filter-note a:hover {
      text-decoration: underline;
    }

    .autocomplete-dropdown {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      min-width: 100%;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      margin-top: 0.25rem;
      max-height: 300px;
      overflow-y: auto;
      z-index: 1000;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .autocomplete-item {
      display: flex;
      align-items: baseline;
      justify-content: space-between;
      gap: 0.75rem;
      min-height: 44px;
      padding: 0.75rem 1rem;
      cursor: pointer;
      border-bottom: 1px solid var(--border);
      color: var(--text);
    }

    .autocomplete-item-main {
      min-width: 0;
    }

    .autocomplete-item-meta {
      color: var(--text-muted);
      font-size: 0.85rem;
      white-space: nowrap;
    }

    .autocomplete-item:last-child {
      border-bottom: none;
    }

    .autocomplete-item:hover,
    .autocomplete-item.highlighted {
      background: var(--surface-hover);
    }

    .loading {
      padding: 2rem;
      color: var(--text-muted);
      font-size: 1rem;
    }

    .error {
      padding: 1rem 1.25rem;
      background: rgba(199, 92, 92, 0.15);
      border: 1px solid var(--danger);
      border-radius: 8px;
      color: #e8a0a0;
      margin-bottom: 1rem;
    }

    .tournament {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      margin-bottom: 0.75rem;
      overflow: hidden;
    }

    .tournament-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 0.75rem;
      padding: 1rem 1.25rem;
      transition: background 0.15s;
    }

    .tournament-header:hover {
      background: var(--surface-hover);
    }

    .tournament-description {
      margin: 1rem 0 0;
      padding-top: 1rem;
      border-top: 1px solid var(--border);
      font-size: 0.95rem;
      line-height: 1.5;
      color: var(--text);
      white-space: pre-wrap;
      word-break: break-word;
    }

    .tournament-info-page {
      display: grid;
      gap: 1.25rem;
    }

    .tournament-info-html {
      padding: 0.25rem 0;
    }

    .tournament-info-links {
      display: grid;
      gap: 0.85rem;
    }

    .tournament-detail-header {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 1.25rem 1.35rem;
      margin-bottom: 1.15rem;
    }

    .tournament-detail-header-top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      gap: 1rem;
    }

    .tournament-detail-date {
      font-size: 0.9rem;
      color: var(--text-muted);
      margin-bottom: 0.25rem;
    }

    .tournament-detail-meta {
      font-size: 0.85rem;
      color: var(--text-muted);
      font-family: 'JetBrains Mono', monospace;
    }

    .tournament-detail-aside {
      display: flex;
      align-items: center;
      gap: 1rem;
      flex-wrap: wrap;
    }

    /* Filters / phase controls sit inside .tournament cards but outside
       .standings — give them the same inset so controls never kiss the rim. */
    .tournament > .detail-filters,
    .tournament > .deck-sort-controls,
    .tournament > .matchup-note {
      padding-left: 1.25rem;
      padding-right: 1.25rem;
    }

    .tournament > .detail-filters,
    .tournament > .deck-sort-controls {
      padding-top: 1rem;
    }

    .tournament > .detail-filters {
      margin-bottom: 0;
    }

    .tournament > .detail-filters + .standings {
      border-top: none;
      padding-top: 0.85rem;
    }

    .tournament > .deck-sort-controls {
      margin-bottom: 0.75rem;
    }

    .tournament > .matchup-note {
      margin-top: 0;
    }

    .tournament-toggle {
      flex-shrink: 0;
      width: 1.5rem;
      height: 1.5rem;
      padding: 0;
      border: none;
      background: transparent;
      color: var(--text-muted);
      cursor: pointer;
      border-radius: 4px;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: transform 0.2s, color 0.15s;
    }

    .tournament-toggle:hover {
      color: var(--text);
    }

    .tournament.collapsed .tournament-toggle {
      transform: rotate(-90deg);
    }

    .tournament-toggle::before {
      content: '';
      width: 0;
      height: 0;
      border-left: 0.35rem solid transparent;
      border-right: 0.35rem solid transparent;
      border-top: 0.4rem solid currentColor;
      margin-bottom: 0.15rem;
    }

    .tournament-name {
      font-weight: 600;
      font-size: 1rem;
      flex: 1;
      min-width: 0;
    }

    .tournament-meta {
      display: flex;
      align-items: center;
      gap: 1rem;
      font-size: 0.85rem;
      color: var(--text-muted);
      font-family: 'JetBrains Mono', monospace;
    }

    .tournament-meta span {
      white-space: nowrap;
    }

    .tournament-body {
      overflow: hidden;
    }

    .tournament.collapsed .tournament-body {
      display: none;
    }

    .standings {
      border-top: 1px solid var(--border);
      padding: 0.75rem 1.25rem 1rem;
    }

    .standings-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.9rem;
    }

    .standings-table th {
      text-align: left;
      padding: 0.5rem 0.75rem 0.5rem 0;
      font-weight: 600;
      color: var(--text-muted);
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .standings-table td {
      padding: 0.5rem 0.75rem 0.5rem 0;
      border-top: 1px solid var(--border);
    }

    .player-name {
      color: var(--accent);
      cursor: pointer;
      text-decoration: none;
      font-weight: 500;
      border-radius: 4px;
      padding: 2px 4px;
      margin: -2px -4px;
      transition: background 0.15s, color 0.15s;
    }

    .player-name:hover {
      background: var(--accent-dim);
      color: var(--bg);
    }

    .player-name.placeholder-player {
      color: var(--text-muted);
      cursor: default;
      font-style: italic;
    }

    .player-name.placeholder-player:hover {
      background: transparent;
      color: var(--text-muted);
    }

    .placeholder-badge {
      display: inline-block;
      margin-left: 0.4rem;
      padding: 0.1rem 0.4rem;
      border-radius: 999px;
      border: 1px solid var(--border);
      font-size: 0.7rem;
      font-style: normal;
      font-weight: 600;
      letter-spacing: 0.02em;
      color: var(--text-muted);
      vertical-align: middle;
    }

    .record {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.85rem;
      color: var(--text-muted);
    }

    .record .w { color: var(--success); }
    .record .l { color: var(--danger); }
    .record .t { color: var(--text-muted); }

    .deck-name {
      font-size: 0.85rem;
      color: var(--text-muted);
      /* Grow with available table/cell space; avoid a fixed 180px clip on wide layouts. */
      max-width: 100%;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      display: flex;
      align-items: center;
      gap: 0.1rem;
    }

    /* Standings columns have room on desktop — show the full archetype name. */
    .standings-table .deck-name {
      max-width: none;
      overflow: visible;
      text-overflow: unset;
    }

    .deck-name[data-deck-name]:not([data-deck-name=""]):not([data-deck-name="—"]):not([data-deck-name="Unknown"]):not([data-deck-name="Unknown Deck"]) {
      color: var(--accent);
      cursor: pointer;
      font-weight: 500;
      border-radius: 4px;
      padding: 2px 4px;
      margin: -2px -4px;
      transition: background 0.15s, color 0.15s;
    }

    .deck-name[data-deck-name]:not([data-deck-name=""]):not([data-deck-name="—"]):not([data-deck-name="Unknown"]):not([data-deck-name="Unknown Deck"]):hover {
      background: var(--accent-dim);
      color: var(--bg);
    }

    .deck-icon {
      width: 40px;
      height: 40px;
      flex-shrink: 0;
      image-rendering: pixelated;
    }

    .page-view {
      display: none;
    }

    .page-view.active {
      display: block;
    }

    .page-header {
      display: flex;
      align-items: center;
      gap: 1rem;
      margin-bottom: 1.5rem;
      padding-bottom: 1rem;
      border-bottom: 1px solid var(--border);
    }

    .back-button {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 0.5rem 0.75rem;
      border-radius: 8px;
      cursor: pointer;
      font-family: inherit;
      font-size: 0.9rem;
      text-decoration: none;
      transition: background 0.15s, border-color 0.15s;
      flex-shrink: 0;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }

    .back-button:hover {
      background: var(--surface-hover);
      border-color: var(--accent-dim);
    }

    .page-title {
      font-weight: 700;
      font-size: 1.5rem;
      color: var(--accent);
      flex: 1;
      min-width: 0;
    }

    .page-title .matchup-vs {
      color: var(--text-muted);
      font-weight: 500;
      margin: 0 0.35rem;
    }

    .page-title .deck-name {
      display: inline-flex;
      align-items: center;
      gap: 0.2rem;
      vertical-align: middle;
    }

    .sort-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 0.4rem 0.75rem;
      border-radius: 6px;
      cursor: pointer;
      font-family: inherit;
      font-size: 0.85rem;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }

    .sort-btn:hover {
      background: var(--surface-hover);
      border-color: var(--accent-dim);
    }

    .sort-btn.active {
      background: var(--accent-dim);
      color: var(--bg);
      border-color: var(--accent);
      font-weight: 600;
    }

    .player-result-card {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 0.9rem 1rem;
      margin-bottom: 0.5rem;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
      transition: border-color 0.15s, background 0.15s;
    }

    .player-result-card:hover {
      border-color: var(--accent-dim);
      background: var(--surface);
    }

    .player-result-card-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 1rem;
    }

    .player-result-card-main {
      flex: 1;
      min-width: 0;
    }

    .player-result-card .event-name {
      font-weight: 600;
      font-size: 0.9rem;
      margin-bottom: 0.2rem;
      word-break: break-word;
      line-height: 1.3;
    }

    .player-result-card .event-date {
      font-size: 0.75rem;
      color: var(--text-muted);
      margin-bottom: 0.35rem;
    }

    .player-result-card .placing-record {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.8rem;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
    }

    .player-result-card .placing-record .place {
      color: var(--accent);
      font-weight: 600;
    }

    .player-result-card .deck-name {
      font-size: 0.75rem;
      color: var(--text-muted);
      margin-top: 0.25rem;
      word-break: break-word;
      display: flex;
      align-items: center;
      gap: 0.25rem;
    }

    .player-result-card .deck-name[data-deck-name]:not([data-deck-name=""]):not([data-deck-name="—"]):not([data-deck-name="Unknown"]):not([data-deck-name="Unknown Deck"]) {
      color: var(--accent);
      font-weight: 500;
      transition: color 0.15s;
    }

    .player-result-card .deck-name[data-deck-name]:not([data-deck-name=""]):not([data-deck-name="—"]):not([data-deck-name="Unknown"]):not([data-deck-name="Unknown Deck"]):hover {
      color: var(--bg);
      background: var(--accent-dim);
      border-radius: 4px;
      padding: 2px 4px;
      margin: -2px -4px;
    }

    .player-result-card-actions {
      display: flex;
      gap: 0.5rem;
      flex-wrap: wrap;
      margin-top: 0.25rem;
    }

    .player-result-card .btn-deck-image {
      width: auto;
      margin: 0;
      padding: 0.4rem 0.75rem;
      font-size: 0.8rem;
      flex-shrink: 0;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }

    .empty-panel {
      color: var(--text-muted);
      font-size: 0.9rem;
      text-align: center;
      padding: 2rem 1rem;
    }

    .pagination {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.5rem;
      margin-top: 1.5rem;
      flex-wrap: wrap;
    }

    .standings .pagination {
      margin-top: 1rem;
    }

    .pagination-info {
      font-size: 0.9rem;
      color: var(--text-muted);
      margin: 0 0.5rem;
      font-family: 'JetBrains Mono', monospace;
    }

    .pagination-page-size {
      display: inline-flex;
      align-items: center;
      gap: 0.4rem;
      margin-left: 0.35rem;
      font-size: 0.85rem;
      color: var(--text-muted);
    }

    .pagination-page-size select {
      padding: 0.4rem 0.5rem;
      font-family: inherit;
      font-size: 0.85rem;
      color: var(--text);
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 6px;
      cursor: pointer;
      min-width: 4.25rem;
    }

    .pagination-page-size select:hover,
    .pagination-page-size select:focus {
      border-color: var(--accent-dim);
      outline: none;
    }

    .pagination-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 0.5rem 0.75rem;
      border-radius: 6px;
      cursor: pointer;
      font-family: inherit;
      font-size: 0.9rem;
      transition: background 0.15s, border-color 0.15s;
    }

    .pagination-btn:hover:not(:disabled) {
      background: var(--surface-hover);
      border-color: var(--accent-dim);
    }

    .pagination-btn:disabled {
      opacity: 0.4;
      cursor: not-allowed;
    }

    .btn-deck-image {
      background: var(--surface-hover);
      border: 1px solid var(--border);
      color: var(--accent);
      padding: 0.35rem 0.5rem;
      border-radius: 6px;
      cursor: pointer;
      font-family: inherit;
      font-size: 0.75rem;
      white-space: nowrap;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
      font-weight: 500;
    }

    .btn-deck-image:hover:not(:disabled) {
      background: var(--accent-dim);
      color: var(--bg);
      border-color: var(--accent);
    }

    .btn-deck-image:disabled {
      opacity: 0.5;
      cursor: wait;
    }

    .btn-deck-image.no-decklist:disabled {
      opacity: 0.4;
      color: var(--text-muted);
      border-color: var(--border);
      background: transparent;
      cursor: not-allowed;
    }

    .modal-overlay {
      position: fixed;
      inset: 0;
      background: rgba(0, 0, 0, 0.8);
      display: flex;
      align-items: center;
      justify-content: center;
      z-index: 1000;
      padding: 2rem;
      box-sizing: border-box;
    }

    .modal-overlay[hidden] {
      display: none;
    }

    .modal-content {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      max-width: 100%;
      max-height: calc(100vh - 4rem);
      display: flex;
      flex-direction: column;
      overflow: hidden;
    }

    #deck-image-modal .modal-content {
      width: min(960px, 100%);
    }

    #deck-image-modal .modal-body {
      align-items: stretch;
      justify-content: flex-start;
    }

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

    .modal-title {
      font-weight: 600;
      font-size: 1rem;
      color: var(--text);
      min-width: 0;
      overflow-wrap: anywhere;
    }

    .modal-close {
      background: none;
      border: none;
      color: var(--text-muted);
      cursor: pointer;
      padding: 0.25rem;
      font-size: 1.5rem;
      line-height: 1;
      border-radius: 4px;
      transition: color 0.15s, background 0.15s;
    }

    .modal-close:hover {
      color: var(--text);
      background: var(--surface-hover);
    }

    .modal-body {
      padding: 1rem;
      overflow: auto;
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 200px;
    }

    .modal-body img {
      max-width: 100%;
      height: auto;
      display: block;
    }

    .modal-body .modal-loading,
    .modal-body .modal-error {
      color: var(--text-muted);
      padding: 2rem;
    }

    .modal-body .modal-error {
      color: var(--danger);
    }

    .decklist-modal-inner {
      display: flex;
      flex-direction: column;
      align-items: flex-start;
      width: 100%;
      gap: 1rem;
    }

    .decklist-content-row {
      display: flex;
      flex-direction: column;
      gap: 1rem;
      width: 100%;
      align-items: stretch;
    }

    .deck-view-toggle {
      display: flex;
      gap: 0.4rem;
      flex-wrap: wrap;
    }

    .deck-preview-list {
      width: 100%;
      max-height: 60vh;
      overflow-y: auto;
      padding-right: 0.15rem;
    }

    #deck-preview-text {
      width: 100%;
    }

    .deck-preview-section + .deck-preview-section {
      margin-top: 1rem;
    }

    .deck-preview-section-title {
      margin: 0 0 0.55rem;
      font-size: 0.82rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--text-muted);
      display: flex;
      justify-content: space-between;
      gap: 0.5rem;
    }

    .deck-preview-section-title span {
      font-family: 'JetBrains Mono', monospace;
      color: var(--text);
      letter-spacing: 0;
      text-transform: none;
    }

    .deck-preview-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
      gap: 0.55rem;
    }

    .deck-preview-card {
      position: relative;
      display: flex;
      flex-direction: column;
      gap: 0.25rem;
      min-width: 0;
      cursor: pointer;
    }

    .deck-preview-card img,
    .deck-preview-fallback {
      width: 100%;
      aspect-ratio: 2.5 / 3.5;
      object-fit: cover;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--bg);
      display: block;
    }

    .deck-preview-fallback {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0.4rem;
      text-align: center;
      font-size: 0.68rem;
      color: var(--text-muted);
      line-height: 1.25;
    }

    .deck-preview-count {
      position: absolute;
      top: 0.3rem;
      left: 0.3rem;
      min-width: 1.35rem;
      padding: 0.05rem 0.28rem;
      border-radius: 4px;
      background: rgba(0, 0, 0, 0.78);
      color: #fff;
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.72rem;
      text-align: center;
    }

    .deck-preview-name {
      font-size: 0.7rem;
      line-height: 1.2;
      color: var(--text-muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .decklist-pre-hover {
      display: flex;
      flex-direction: column;
      gap: 0.1rem;
    }

    .decklist-section-label {
      color: var(--text-muted);
      font-weight: 600;
      margin-top: 0.35rem;
    }

    .decklist-line {
      display: block;
      border-radius: 4px;
      padding: 0.05rem 0.2rem;
      margin: 0 -0.2rem;
    }

    .decklist-line:hover {
      background: var(--surface-hover);
      color: var(--accent);
    }

    @media (max-width: 800px) {
      .deck-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
      }
      .deck-image-result {
        max-width: 100%;
      }
    }

    .decklist-pre {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.8rem;
      white-space: pre-wrap;
      word-break: break-word;
      margin: 0;
      padding: 1rem;
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      overflow-y: auto;
      color: var(--text);
      flex: 1;
      min-width: 0;
      box-sizing: border-box;
      max-height: 60vh;
    }

    .deck-image-result {
      flex: 0 0 auto;
      max-width: 100%;
    }

    .deck-image-result img {
      max-width: 100%;
      height: auto;
      display: block;
      border-radius: 8px;
      border: 1px solid var(--border);
    }

    .modal-actions {
      display: flex;
      gap: 0.75rem;
      flex-wrap: wrap;
      margin: 0;
    }

    .modal-actions .btn-deck-image {
      margin: 0;
    }

    .modal-actions a.btn-deck-image {
      text-decoration: none;
      display: inline-block;
    }

    .deck-actions-cell {
      display: flex;
      gap: 0.4rem;
      flex-wrap: nowrap;
      white-space: nowrap;
    }

    .deck-actions-cell .btn-deck-image {
      flex-shrink: 0;
      margin: 0;
    }

    /* Stats & richer list metrics */
    .stats-summary {
      display: flex;
      flex-wrap: wrap;
      gap: 0.65rem;
      margin-bottom: 1.25rem;
    }

    .stats-pill {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      padding: 0.85rem 1rem;
      min-width: 110px;
      display: grid;
      gap: 0.25rem;
    }

    .stats-pill-label {
      font-size: 0.72rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--text-muted);
      font-weight: 600;
    }

    .stats-pill-value {
      font-size: 1rem;
      font-weight: 600;
    }

    .stats-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 1rem;
    }

    .stats-card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 1rem;
      min-width: 0;
    }

    .stats-card-wide {
      grid-column: 1 / -1;
    }

    .stats-section-title {
      margin: 0 0 0.85rem;
      font-size: 0.95rem;
    }

    .meta-bar-row {
      display: grid;
      grid-template-columns: minmax(120px, 1.2fr) 1.4fr auto;
      gap: 0.55rem;
      align-items: center;
      padding: 0.35rem 0.15rem;
      cursor: pointer;
      border-radius: 6px;
    }

    .meta-bar-row:hover {
      background: var(--surface-hover);
    }

    .meta-bar-label {
      display: flex;
      align-items: center;
      gap: 0.15rem;
      font-size: 0.88rem;
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .meta-bar-track {
      height: 8px;
      background: var(--bg);
      border-radius: 999px;
      overflow: hidden;
      border: 1px solid var(--border);
    }

    .meta-bar-fill {
      height: 100%;
      background: var(--accent);
      border-radius: 999px;
    }

    .meta-bar-fill.conversion {
      background: var(--success);
    }

    .meta-bar-value {
      font-size: 0.78rem;
      color: var(--text-muted);
      font-family: 'JetBrains Mono', monospace;
      white-space: nowrap;
    }

    .tournament-meta-block {
      margin-top: 0.5rem;
      padding-top: 0.75rem;
      border-top: 1px solid var(--border);
    }

    .player-stats-inline,
    .deck-stats-inline {
      display: flex;
      align-items: center;
      gap: 0.45rem;
      flex-wrap: wrap;
      justify-content: flex-end;
    }

    .stat-chip {
      font-size: 0.75rem;
      color: var(--text-muted);
      border: 1px solid var(--border);
      border-radius: 999px;
      padding: 0.15rem 0.45rem;
      white-space: nowrap;
    }

    @media (max-width: 768px) {
      /* minmax(0, 1fr): plain 1fr is minmax(auto, 1fr) and expands to the
         matrix min-width, so overflow-x never scrolls and body clips it. */
      .stats-grid {
        grid-template-columns: minmax(0, 1fr);
      }

      .meta-bar-row {
        grid-template-columns: 1fr;
        gap: 0.25rem;
      }

      .player-stats-inline,
      .deck-stats-inline {
        justify-content: flex-start;
        width: 100%;
      }
    }

    .stats-date-filter {
      display: flex;
      flex-wrap: wrap;
      gap: 0.75rem;
      align-items: flex-end;
      margin-bottom: 1.25rem;
      padding: 0.85rem 1rem;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
    }

    .stats-date-field {
      display: grid;
      gap: 0.3rem;
      font-size: 0.85rem;
      color: var(--text-muted);
    }

    .stats-date-field input[type="date"] {
      padding: 0.5rem 0.65rem;
      font-family: inherit;
      font-size: 0.9rem;
      color: var(--text);
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 8px;
      min-width: 150px;
    }

    .stats-date-optional {
      font-size: 0.75rem;
      color: var(--text-muted);
      font-weight: 400;
      text-transform: none;
      letter-spacing: 0;
    }

    .stats-date-range-label {
      font-size: 0.85rem;
      color: var(--text-muted);
      margin-left: auto;
      align-self: center;
    }

    .muted {
      color: var(--text-muted);
      font-size: 0.9rem;
    }

    .matchup-section {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      padding: 1rem;
      margin-bottom: 1.25rem;
    }

    .matchup-section-header {
      display: flex;
      flex-wrap: wrap;
      gap: 0.65rem;
      align-items: center;
      margin-bottom: 0.75rem;
    }

    .matchup-section-header .stats-section-title {
      margin: 0;
      flex: 1;
      min-width: 8rem;
    }

    .matchup-note {
      margin: 0 0 0.85rem;
      font-size: 0.82rem;
      color: var(--text-muted);
    }

    .matchup-bar {
      display: flex;
      height: 8px;
      min-width: 72px;
      background: var(--bg);
      border-radius: 999px;
      overflow: hidden;
      border: 1px solid var(--border);
    }

    .matchup-bar-win {
      background: var(--success);
      height: 100%;
    }

    .matchup-bar-tie {
      background: var(--text-muted);
      height: 100%;
      opacity: 0.55;
    }

    .matchup-bar-loss {
      background: var(--danger);
      height: 100%;
    }

    .matchup-wr {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.82rem;
      white-space: nowrap;
    }

    .matchup-wr.good { color: var(--success); }
    .matchup-wr.bad { color: var(--danger); }

    .matchup-matrix-wrap {
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior-x: contain;
      max-width: 100%;
    }

    .matchup-matrix-filters {
      display: grid;
      gap: 0.55rem;
      margin: 0 0 0.85rem;
    }

    .matchup-matrix-filter-head {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.45rem 0.65rem;
      font-size: 0.82rem;
      color: var(--text-muted);
    }

    .matchup-matrix-filter-chips {
      display: flex;
      flex-wrap: wrap;
      gap: 0.4rem;
    }

    .matchup-deck-chip {
      display: inline-flex;
      align-items: center;
      gap: 0.2rem;
      max-width: 100%;
      padding: 0.28rem 0.55rem;
      font-family: inherit;
      font-size: 0.78rem;
      font-weight: 500;
      color: var(--text-muted);
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 999px;
      cursor: pointer;
      line-height: 1.2;
    }

    .matchup-deck-chip:hover {
      color: var(--text);
      border-color: var(--accent-dim);
    }

    .matchup-deck-chip[aria-pressed="true"] {
      color: var(--text);
      border-color: var(--accent);
      background: rgba(201, 162, 39, 0.12);
    }

    .matchup-deck-chip .deck-icon {
      width: 18px;
      height: 18px;
    }

    .matchup-deck-chip-label {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: 9.5rem;
    }

    .matchup-matrix {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.8rem;
      min-width: 520px;
    }

    .matchup-section .deck-name {
      max-width: none;
      overflow: visible;
      text-overflow: unset;
    }

    .matchup-opponent {
      display: flex;
      align-items: center;
      gap: 0.4rem;
      min-width: 0;
    }

    .typical-list-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 1.1rem 1.4rem;
    }

    .typical-col-title {
      margin: 0 0 0.55rem;
      font-size: 0.82rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--text-muted);
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      gap: 0.5rem;
    }

    .typical-col-avg {
      font-family: 'JetBrains Mono', monospace;
      color: var(--text);
      letter-spacing: 0;
      text-transform: none;
      font-size: 0.85rem;
    }

    .typical-card-row {
      display: grid;
      grid-template-columns: 3.15rem minmax(0, 1fr) 2.4rem;
      gap: 0.4rem;
      align-items: center;
      padding: 0.16rem 0.15rem;
      border-radius: 4px;
      cursor: pointer;
      color: inherit;
      text-decoration: none;
    }

    .typical-card-row:hover {
      background: var(--surface-hover);
    }

    .typical-count {
      font-family: 'JetBrains Mono', monospace;
      font-weight: 600;
      font-size: 0.82rem;
      color: var(--accent);
      text-align: right;
    }

    .typical-card-row.tech .typical-count {
      color: var(--text-muted);
      font-weight: 400;
    }

    .typical-name {
      min-width: 0;
      display: flex;
      align-items: baseline;
      gap: 0.4rem;
      font-size: 0.86rem;
    }

    .typical-card-title {
      min-width: 0;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .typical-card-row:hover .typical-card-title {
      color: var(--accent);
    }

    .typical-set {
      flex: 0 0 auto;
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.7rem;
      letter-spacing: 0.02em;
      color: var(--text-muted);
      white-space: nowrap;
    }

    .typical-play {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.72rem;
      color: var(--text-muted);
      text-align: right;
    }

    .card-preview {
      position: fixed;
      z-index: 1200;
      width: 240px;
      pointer-events: none;
      filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.55));
    }

    .card-preview[hidden] {
      display: none !important;
    }

    .card-preview-art {
      position: relative;
      width: 100%;
      border-radius: 10px;
      overflow: hidden;
      background: var(--surface);
    }

    .card-preview img {
      width: 100%;
      border-radius: 10px;
      display: block;
    }

    .card-preview.is-loading .card-preview-art {
      aspect-ratio: 63 / 88;
      background: var(--surface-hover);
      border: 1px solid var(--border);
    }

    .card-preview.is-loading img {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      opacity: 0;
    }

    .card-preview-loading {
      display: none;
    }

    .card-preview.is-loading .card-preview-loading {
      display: flex;
      position: absolute;
      inset: 0;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 0.65rem;
      color: var(--text-muted);
      font-size: 0.78rem;
      letter-spacing: 0.02em;
    }

    .card-preview.is-loading .card-preview-loading::before {
      content: "";
      position: absolute;
      inset: 0;
      background: linear-gradient(
        110deg,
        transparent 25%,
        rgba(201, 162, 39, 0.14) 50%,
        transparent 75%
      );
      background-size: 200% 100%;
      animation: card-preview-shimmer 1.15s ease-in-out infinite;
    }

    .card-preview-spinner {
      width: 22px;
      height: 22px;
      border: 2px solid var(--border);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: card-preview-spin 0.7s linear infinite;
      position: relative;
      z-index: 1;
    }

    .card-preview-loading-label {
      position: relative;
      z-index: 1;
    }

    @keyframes card-preview-shimmer {
      0% { background-position: 120% 0; }
      100% { background-position: -120% 0; }
    }

    @keyframes card-preview-spin {
      to { transform: rotate(360deg); }
    }

    @media (prefers-reduced-motion: reduce) {
      .card-preview-spinner,
      .card-preview.is-loading .card-preview-loading::before {
        animation: none;
      }
    }

    .card-preview-meta {
      margin-top: 0.35rem;
      font-size: 0.78rem;
      color: var(--text);
      text-shadow: 0 1px 2px #000;
    }

    @media (max-width: 768px) {
      .typical-list-grid {
        grid-template-columns: 1fr;
      }

      .typical-card-row {
        min-height: 40px;
      }
    }

    .matchup-matrix th,
    .matchup-matrix td {
      border: 1px solid var(--border);
      padding: 0.4rem 0.35rem;
      text-align: center;
      min-width: 3.4rem;
    }

    .matchup-matrix th {
      background: var(--bg);
      font-weight: 600;
      font-size: 0.72rem;
    }

    .matchup-matrix .matchup-matrix-corner,
    .matchup-matrix .matchup-matrix-rowhead {
      text-align: left;
      min-width: 8.5rem;
    }

    .matchup-matrix .matchup-matrix-rowhead {
      position: sticky;
      left: 0;
      background: var(--surface);
      z-index: 1;
    }

    .matchup-matrix td.matchup-cell {
      font-family: 'JetBrains Mono', monospace;
      cursor: pointer;
    }

    .matchup-matrix td.matchup-cell:hover {
      outline: 1px solid var(--accent);
    }

    .matchup-matrix td.matchup-cell.good {
      background: rgba(74, 155, 110, 0.18);
      color: var(--success);
    }

    .matchup-matrix td.matchup-cell.bad {
      background: rgba(199, 92, 92, 0.16);
      color: var(--danger);
    }

    .matchup-matrix td.matchup-cell.mirror {
      color: var(--text-muted);
      cursor: pointer;
    }

    .matchup-matrix td.matchup-cell.mirror.empty,
    .matchup-matrix td.matchup-cell.empty {
      color: var(--text-muted);
      cursor: default;
    }

    .matchup-matrix .matrix-deck {
      display: flex;
      align-items: center;
      gap: 0.15rem;
      cursor: pointer;
      color: var(--accent);
      font-weight: 500;
    }

    .matchup-matrix .matrix-deck:hover {
      text-decoration: underline;
    }

    .matchup-matrix .deck-icon {
      width: 22px;
      height: 22px;
    }

    @media (max-width: 768px) {
      .stats-date-range-label {
        margin-left: 0;
        width: 100%;
      }
    }

    /* —— Mobile layout —— */
    @media (max-width: 768px) {
      html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
      }

      body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
      }

      main {
        padding: 1rem;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
      }

      .site-footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
      }

      input,
      select,
      textarea {
        font-size: 1rem;
        max-width: 100%;
      }

      button,
      .tab,
      .sort-btn,
      .pagination-btn,
      .back-button,
      .btn-deck-image {
        touch-action: manipulation;
      }

      .tabs {
        display: flex;
        flex-wrap: wrap;
        gap: 0;
        margin-bottom: 1.15rem;
        overflow: visible;
      }

      .tab {
        flex: 1 1 30%;
        min-width: 5.25rem;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0.55rem 0.45rem;
        font-size: 0.82rem;
      }

      .page-header {
        align-items: flex-start;
        gap: 0.75rem;
      }

      .page-title {
        overflow-wrap: anywhere;
        word-break: break-word;
        line-height: 1.25;
      }

      .back-button,
      .sort-btn,
      .pagination-btn {
        min-height: 44px;
      }

      .btn-deck-image {
        min-height: 40px;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
      }

      .search-bar input,
      .card-search-field,
      .card-search-field input,
      .card-search-controls > input,
      .card-standings-filter input,
      .detail-filters .search-bar input {
        max-width: 100%;
        width: 100%;
      }

      .card-search-controls {
        flex-direction: column;
        align-items: stretch;
      }

      /* flex-basis: 220px is for desktop row width; in a column it reserves
         vertical space and leaves a large gap above the deck filter. */
      .card-search-field {
        flex: 0 0 auto;
      }

      .card-ignore-set {
        min-height: 44px;
      }

      .filter-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: end;
      }

      .filter-field {
        min-width: 0;
        flex: none;
        width: 100%;
        max-width: 100%;
      }

      .filter-field input[type="date"],
      .filter-field input[type="search"],
      .filter-field select,
      .country-filter,
      .country-filter-toggle {
        min-width: 0 !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
      }

      /* Native date inputs refuse to shrink on iOS — stack From/To full-width
         so they never collide or spill past the card/screen edge. */
      .filter-field:has(input[type="date"]) {
        grid-column: 1 / -1;
      }

      /* A trailing select alone on a row (Organizer, Deck filter) should span
         both columns instead of leaving an empty half-width cell. */
      .filter-row > .filter-field:has(select):nth-child(odd):last-of-type,
      .filter-row > .filter-field:has(.country-filter):nth-child(odd):last-of-type {
        grid-column: 1 / -1;
      }

      .filter-row > .sort-btn {
        grid-column: 1 / -1;
        width: 100%;
      }

      .stats-date-filter {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.75rem;
        align-items: end;
        overflow: hidden;
      }

      .stats-date-field {
        grid-column: 1 / -1;
        min-width: 0;
        width: 100%;
        max-width: 100%;
      }

      .stats-date-field input[type="date"] {
        min-width: 0 !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
      }

      .stats-date-filter > .sort-btn {
        width: 100%;
      }

      .stats-date-range-label {
        grid-column: 1 / -1;
        width: 100%;
        margin-left: 0;
      }

      .tournament-header {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
        gap: 0.45rem 0.75rem;
        padding: 1.05rem 1.15rem;
      }

      .tournament-header:has(.tournament-toggle) {
        grid-template-columns: auto minmax(0, 1fr);
      }

      .tournament-toggle {
        grid-row: 1 / span 2;
        width: 2.5rem;
        height: 2.5rem;
        align-self: start;
        margin: 0;
      }

      .tournament-name {
        overflow-wrap: anywhere;
      }

      .tournament-meta {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.45rem 0.85rem;
      }

      .tournament > .detail-filters,
      .tournament > .deck-sort-controls,
      .tournament > .matchup-note {
        padding-left: 1rem;
        padding-right: 1rem;
      }

      .tournament > .detail-filters,
      .tournament > .deck-sort-controls {
        padding-top: 1rem;
      }

      .tournament-detail-header {
        padding: 1.1rem 1.15rem;
      }

      .standings {
        padding: 0.85rem 1rem 1.1rem;
      }

      .deck-sort-controls {
        gap: 0.55rem;
      }

      .player-row,
      .deck-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.55rem;
        padding: 1rem 1.05rem;
      }

      .player-stats-inline,
      .deck-stats-inline {
        justify-content: flex-start;
        width: 100%;
      }

      .stats-summary {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.65rem;
      }

      .stats-pill {
        min-width: 0;
        padding: 0.9rem 1rem;
      }

      .stats-date-optional {
        display: none;
      }

      .pagination {
        gap: 0.55rem;
        padding: 0.15rem 0 0.1rem;
      }

      .pagination-page-size {
        margin-top: 0.15rem;
      }

      .pagination-info + .pagination-info {
        display: none;
      }

      .standings {
        overflow-x: visible;
      }

      .standings-table.table-stack {
        min-width: 0;
        width: 100%;
      }

      .standings-table.table-stack thead {
        display: none;
      }

      .standings-table.table-stack,
      .standings-table.table-stack tbody {
        display: block;
      }

      .standings-table.table-stack tbody {
        display: flex;
        flex-direction: column;
        gap: 0.65rem;
      }

      .standings-table.table-stack tr {
        display: block;
        background: var(--bg);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 1rem 1.05rem;
      }

      .standings-table.table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 0.75rem;
        padding: 0.28rem 0;
        border-top: none;
        text-align: right;
      }

      .standings-table.table-stack td + td {
        border-top: 1px solid var(--border);
      }

      .standings-table.table-stack td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.7rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        text-align: left;
        flex: 0 0 auto;
      }

      .standings-table.table-stack td:not([data-label])::before {
        content: none;
      }

      .standings-table.table-stack td.deck-actions-cell,
      .standings-table.table-stack td:not([data-label]) {
        justify-content: flex-start;
        flex-wrap: wrap;
        white-space: normal;
        text-align: left;
        padding-top: 0.55rem;
      }

      .standings-table.table-stack .deck-name,
      .standings-table.table-stack .player-name,
      .standings-table.table-stack .tournament-name,
      .standings-table.table-stack .matchup-opponent {
        max-width: none;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        justify-content: flex-end;
        text-align: right;
      }

      .standings-table.table-stack .matchup-rate {
        justify-content: flex-end;
        flex-wrap: wrap;
      }

      .standings-table.table-compact-result tbody tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 0.2rem 0.65rem;
        align-items: center;
      }

      .standings-table.table-compact-result td {
        border-top: none;
        padding: 0;
        text-align: left;
      }

      .standings-table.table-compact-result td[data-label="Place"] {
        grid-column: 1;
        grid-row: 1;
        font-weight: 700;
        color: var(--accent);
        font-family: 'JetBrains Mono', monospace;
      }

      .standings-table.table-compact-result td[data-label="Player"] {
        grid-column: 2;
        grid-row: 1;
        justify-content: flex-start;
      }

      .standings-table.table-compact-result td[data-label="Record"] {
        grid-column: 3;
        grid-row: 1;
        justify-content: flex-end;
      }

      .standings-table.table-compact-result td[data-label="Deck"] {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
      }

      .standings-table.table-compact-result td.deck-actions-cell {
        grid-column: 1 / -1;
        grid-row: 3;
        padding-top: 0.4rem;
      }

      .standings-table.table-compact-result td[data-label="Place"]::before,
      .standings-table.table-compact-result td[data-label="Player"]::before,
      .standings-table.table-compact-result td[data-label="Record"]::before,
      .standings-table.table-compact-result td[data-label="Deck"]::before {
        content: none;
      }

      .standings-table.table-compact-result .deck-name,
      .standings-table.table-compact-result .player-name {
        justify-content: flex-start;
        text-align: left;
      }

      .modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
      }

      .modal-content {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
      }

      .modal-header {
        padding: 0.75rem 0.9rem;
        padding-top: max(0.75rem, env(safe-area-inset-top));
      }

      .modal-close {
        min-width: 44px;
        min-height: 44px;
      }

      .modal-body {
        padding: 0.85rem;
        padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
        align-items: stretch;
      }

      .modal-actions {
        position: sticky;
        bottom: 0;
        background: var(--surface);
        padding-top: 0.5rem;
      }

      .modal-actions .btn-deck-image {
        flex: 1 1 calc(50% - 0.5rem);
        text-align: center;
      }

      .matchup-matrix-wrap {
        margin-inline: -0.25rem;
        padding-bottom: 0.25rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        max-width: calc(100% + 0.5rem);
      }

      .matchup-matrix-wrap::after {
        content: 'Swipe sideways to see more matchups';
        display: block;
        margin-top: 0.55rem;
        font-size: 0.75rem;
        color: var(--text-muted);
      }

      .matchup-deck-chip-label {
        max-width: 7.5rem;
      }

      .matchup-matrix {
        min-width: 420px;
      }

      .matchup-matrix th,
      .matchup-matrix td {
        min-width: 2.6rem;
        padding: 0.3rem 0.2rem;
      }

      .matchup-matrix .matchup-matrix-corner,
      .matchup-matrix .matchup-matrix-rowhead {
        min-width: 6.25rem;
      }

      .card-preview {
        display: none !important;
      }
    }

    @media (max-width: 480px) {
      main {
        padding: 0.75rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
      }

      .tab {
        padding: 0.5rem 0.35rem;
        font-size: 0.78rem;
      }

      .modal-actions .btn-deck-image {
        flex-basis: 100%;
      }
    }

/* Footer links */
.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem 1.25rem;
}

.site-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: center;
}

.site-footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
}

.site-footer-nav a:hover,
.site-footer-nav a[aria-current="page"] {
  color: var(--text);
  text-decoration: underline;
}

/* Home */
.home-hero {
  margin: 0 0 1.5rem;
}

.home-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.home-hero h1 {
  margin: 0 0 0.75rem;
  font-size: 2rem;
  line-height: 1.15;
}

.home-overview {
  max-width: 46rem;
}

.home-grid {
  display: grid;
  gap: 1rem;
  align-items: start;
}

.home-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1rem 0.75rem;
  min-width: 0;
}

.home-panel h2 {
  margin: 0;
  font-size: 1.05rem;
}

.home-panel .subtitle {
  margin: 0.2rem 0 0.75rem;
}

.home-card {
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.home-card-title {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.home-card-title:hover {
  color: var(--accent);
}

.home-meta {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.home-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.home-list-row .btn-deck-image {
  flex-shrink: 0;
}

.home-list-main .player-name,
.home-list-main .deck-name {
  cursor: pointer;
}

.home-list-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  min-width: 0;
}

.home-place {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.home-empty {
  margin: 0.25rem 0 0.5rem;
  color: var(--text-muted);
}

.home-more {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.9rem;
}

.home-more a {
  color: var(--accent);
}

@media (min-width: 960px) {
  .home-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* FAQ page */
.faq-page-content {
  max-width: 48rem;
  line-height: 1.6;
}

.faq-page-content h1,
.faq-page-content h2,
.faq-page-content h3,
.faq-page-content h4 {
  margin: 1.25rem 0 0.5rem;
  line-height: 1.25;
}

.faq-page-content p,
.faq-page-content ul,
.faq-page-content ol,
.faq-page-content blockquote {
  margin: 0.55rem 0;
}

.faq-page-content ul,
.faq-page-content ol {
  padding-left: 1.35rem;
}

.faq-page-content a {
  color: var(--accent, #7c8cff);
}

.faq-page-content blockquote {
  border-left: 3px solid var(--border);
  padding-left: 0.85rem;
  color: var(--text-muted);
}

.faq-empty {
  color: var(--text-muted);
  padding: 1.5rem 0;
}

.rule-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.35rem;
}

.rule-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.15rem 1.1rem;
  background: var(--surface, transparent);
}

.rule-item-title {
  margin: 0 0 0.45rem;
  font-size: 1.15rem;
  line-height: 1.3;
}

.rule-item-first-turn {
  border-color: color-mix(in srgb, var(--accent, #e8c547) 35%, var(--border));
}

.rule-item-source {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.rule-item-source:hover {
  color: var(--accent, #e8c547);
}

#compendium-first-turn {
  margin-bottom: 1.15rem;
}

.rule-item-body {
  margin-top: 0.65rem;
  max-width: none;
}

.rule-item-body > :first-child {
  margin-top: 0;
}

.resource-rich-desc {
  line-height: 1.45;
}

.resource-rich-desc p,
.resource-rich-desc ul,
.resource-rich-desc ol {
  margin: 0.35rem 0;
}

.resource-rich-desc ul,
.resource-rich-desc ol {
  padding-left: 1.2rem;
}

.resource-rich-desc > :first-child {
  margin-top: 0;
}

.resource-rich-desc > :last-child {
  margin-bottom: 0;
}

/* Resources tab */
.resource-tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.15rem;
}

.resource-tag-filter {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.28rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.resource-tag-filter:hover,
.resource-tag-filter.active {
  color: var(--text);
  border-color: var(--text-muted);
}

.resource-tag-filter.active {
  background: color-mix(in srgb, var(--accent, #7c8cff) 18%, var(--surface));
  border-color: var(--accent, #7c8cff);
  color: var(--text);
}

.resource-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 860px) {
  /* Resources page: two cards per row on desktop. */
  #resources-list.resource-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
}

.resource-item {
  display: grid;
  gap: 0.35rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  margin: 0;
  min-width: 0;
}

.resource-item-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.resource-item-title a {
  color: var(--text);
  text-decoration: none;
}

.resource-item-title a:hover {
  color: var(--accent, #7c8cff);
  text-decoration: underline;
}

.resource-item-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.resource-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.resource-item-url {
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-all;
}

.resource-item-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.resource-item .resource-tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}

.resource-item .resource-tag:hover,
.resource-item .resource-tag.active {
  color: var(--text);
  border-color: var(--accent, #7c8cff);
}

/* Discord-style resource embeds */
.resource-embed {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, 180px);
  gap: 0.85rem 1rem;
  align-items: start;
  padding: 0.95rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 4px solid var(--accent, #7c8cff);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  margin: 0;
  min-width: 0;
}

.resource-list .resource-embed {
  height: 100%;
}

.resource-embed-body {
  min-width: 0;
  display: grid;
  gap: 0.35rem;
}

.resource-embed-provider {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.resource-embed-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
}

.resource-embed-title a {
  color: var(--accent, #7c8cff);
  text-decoration: none;
}

.resource-embed-title a:hover {
  text-decoration: underline;
}

.resource-embed-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.resource-embed-media {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
  aspect-ratio: 16 / 9;
  max-height: 140px;
}

.resource-embed-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.resource-embed-media-video {
  max-height: none;
  aspect-ratio: 16 / 9;
}

.resource-embed-media-video iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.deck-window-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.deck-window-note {
  margin-top: -0.55rem;
}

.trend-chart-wrap {
  overflow-x: auto;
  margin: 0.2rem 0 0.75rem;
}

.trend-chart {
  width: 100%;
  min-width: 520px;
  height: auto;
  display: block;
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
  margin: 0.15rem 0 0.85rem;
}

.trend-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.15rem 0.25rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}

.trend-legend-item:hover {
  background: var(--surface-hover);
}

.trend-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  flex: 0 0 auto;
}

.trend-delta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  white-space: nowrap;
}

.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--text-muted); }

.trend-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1.25rem;
}

.trend-subhead {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.trend-table {
  margin-top: 0.85rem;
}

.trend-pills {
  margin-bottom: 0.85rem;
}

.trend-callout {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
}

.sparkline {
  width: 96px;
  height: 28px;
  display: block;
}

.sparkline-empty {
  color: var(--text-muted);
}

a.trend-card-link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

a.trend-card-link:hover .typical-card-title {
  color: var(--accent);
}

@media (max-width: 768px) {
  .trend-split {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .resource-embed {
    grid-template-columns: 1fr;
  }

  .resource-embed-media {
    order: -1;
    max-height: 180px;
  }
}
