:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --paper: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.07);
  --line-strong: rgba(15, 23, 42, 0.11);
  --accent: #0a66ff;
  --accent-hover: #0047c7;
  --accent-soft: rgba(10, 102, 255, 0.09);
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 28px -16px rgba(15, 35, 75, 0.12);
  --font: "Iowan Old Style", "Palatino Linotype", "Songti TC", "Noto Serif TC",
    "PingFang TC", Georgia, serif;
  --sans: "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei",
    system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1200px 480px at 12% -10%, rgba(10, 102, 255, 0.06), transparent 55%),
    radial-gradient(900px 420px at 92% 0%, rgba(15, 23, 42, 0.035), transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.grain { display: none; }

.shell {
  width: min(1040px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 3.75rem;
}

.site-header { margin-bottom: 2rem; }
.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1.05rem;
  border-bottom: 1px solid var(--line);
}
.brand-block {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-width: 0;
}
.mark {
  font-family: var(--font);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  flex: 0 0 auto;
}
.tagline {
  color: #0f172a;
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.35;
}
.site-nav {
  display: flex;
  align-items: center;
  gap: 0.2rem 1.5rem;
  flex: 0 0 auto;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 650;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  line-height: 1.3;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.site-nav a:hover { color: var(--accent); }
.site-nav a.is-active,
.site-nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.hero {
  padding: 0.35rem 0 0.15rem;
}
.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}
.hero h1 {
  margin: 0;
  font-family: var(--font);
  font-weight: 600;
  font-size: clamp(2.05rem, 4.8vw, 2.75rem);
  letter-spacing: 0.03em;
  line-height: 1.18;
  color: var(--ink);
}
.lede {
  max-width: 38rem;
  color: var(--muted);
  line-height: 1.7;
  margin: 0.8rem 0 1.35rem;
  font-size: 1.02rem;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 36rem;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0.4rem 0.4rem 0.4rem 1rem;
  box-shadow: var(--shadow);
}
.search:focus-within {
  border-color: rgba(10, 102, 255, 0.35);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  outline: none;
  min-width: 0;
  padding: 0.55rem 0;
}
.search input::placeholder { color: #94a3b8; }
.search button {
  border: 0;
  border-radius: 10px;
  padding: 0.7rem 1.2rem;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s ease;
}
.search button:hover { background: var(--accent-hover); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.section { margin-top: 2.6rem; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.05rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.75rem;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.28rem;
  letter-spacing: 0.03em;
}
.hint { color: var(--muted); font-size: 0.9rem; font-weight: 550; }

.event-list { display: grid; gap: 0.85rem; }
.event-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1.2rem 1.3rem;
  border-radius: var(--radius-lg);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.event-item:hover {
  border-color: rgba(10, 102, 255, 0.28);
  transform: translateY(-1px);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 18px 36px -18px rgba(15, 35, 75, 0.16);
}
.event-item .event-main {
  min-width: 0;
}
.event-item .title {
  font-family: var(--font);
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: 0.015em;
  color: var(--ink);
}
.event-item .dates {
  margin-top: 0.38rem;
  color: var(--muted);
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  font-weight: 550;
}
.event-item .updated {
  justify-self: end;
  text-align: right;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 550;
}
.event-item .updated-empty {
  display: none;
}

.status, .empty {
  color: var(--muted);
  padding: 2.1rem 1.35rem;
  text-align: center;
  background: var(--paper);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  line-height: 1.7;
}
.empty strong {
  display: block;
  color: var(--ink);
  font-weight: 650;
  margin-bottom: 0.35rem;
  font-size: 1.05rem;
}
.error {
  color: #b42318;
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.foot {
  margin-top: 3.25rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}
.foot-brand {
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 750;
  letter-spacing: 0.045em;
}

.page-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0.35rem 1.15rem 0.55rem;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.02rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.85rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table th {
  color: var(--ink);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  text-transform: none;
  font-weight: 750;
  white-space: nowrap;
}
.table a { color: var(--ink); text-decoration: none; font-weight: 600; }
.table a:hover { color: var(--accent); }
.chip {
  display: inline-block;
  padding: 0.18rem 0.58rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 0.84rem;
  font-weight: 650;
}

@media (max-width: 560px) {
  .shell { width: min(1040px, calc(100% - 1.25rem)); padding-top: 1.25rem; }
  .event-item {
    grid-template-columns: 1fr auto;
    gap: 0.55rem 0.75rem;
    align-items: start;
  }
  .event-item .updated {
    padding-top: 0.15rem;
    font-size: 0.84rem;
  }
  .foot { flex-direction: column; gap: 0.35rem; }
  .tagline { font-size: 0.84rem; }
  .site-nav a { font-size: 0.95rem; }
  .search { max-width: none; }
}

/* Player cross-event history */
.player-history { display: block; }
.player-hist-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.2rem 0.35rem 0.45rem;
}
.player-hist-table {
  min-width: 720px;
  font-size: 1.05rem;
}
.player-hist-table thead th {
  font-size: 1.08rem;
  letter-spacing: 0.015em;
  font-weight: 750;
  color: var(--ink);
  text-transform: none;
  padding: 0.95rem 0.75rem;
}
.player-hist-table tbody td {
  padding: 0.9rem 0.75rem;
  vertical-align: middle;
  font-size: 1.05rem;
}
.player-hist-table th:last-child,
.player-hist-table td.col-hist { min-width: 16rem; }
.player-hist-table .col-event { font-weight: 650; max-width: 16rem; font-size: 1.05rem; }
.player-hist-table .col-event a {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}
.player-hist-table .col-group {
  white-space: nowrap;
  font-size: 1.05rem;
  font-weight: 650;
  color: #0f172a;
}
.player-hist-table .col-num {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  text-align: center;
  width: 4.2rem;
  font-size: 1.05rem;
  white-space: nowrap;
  color: #0f172a;
}
.player-hist-table tbody td.col-group,
.player-hist-table tbody td.col-num,
.player-hist-table tbody td.col-score {
  font-size: 1.05rem;
  color: #0f172a;
  font-weight: 650;
}
.player-hist-table tbody td.col-num {
  font-weight: 750;
}
.player-hist-table .col-group a,
.player-hist-table .col-group .group-link {
  color: #0f172a !important;
  font-size: 1.05rem;
  font-weight: 650;
  text-decoration: none;
}
.player-hist-table .col-group a:hover,
.player-hist-table .col-group .group-link:hover {
  color: var(--accent) !important;
  text-decoration: underline;
}
.player-hist-table thead th:nth-child(2),
.player-hist-table thead th:nth-child(3),
.player-hist-table thead th:nth-child(4) {
  font-size: 1.08rem;
  font-weight: 750;
  color: #0f172a;
}
.player-hist-table th.col-num,
.player-hist-table thead th:nth-child(3),
.player-hist-table thead th:nth-child(4) { text-align: center; }

.rank-hist {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 0.35rem;
  align-items: flex-start;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 0.15rem;
}
.hist-cell {
  flex: 0 0 auto;
  width: clamp(3.2rem, 4.2vw, 4.4rem);
  min-width: 3.2rem;
  text-align: center;
}
.hist-icon {
  height: clamp(2.7rem, 3.6vw, 3.6rem);
}
.hist-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.hist-opp {
  font-size: 0.88rem;
  color: #334155;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}
.hist-opp.bye,
.hist-cell.bye .hist-opp {
  font-size: 0.78rem;
  letter-spacing: -0.02em;
  color: #64748b;
}
.hist-opp a.player-link {
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
  border-bottom: none;
}
.hist-opp a.player-link:hover {
  color: var(--accent, #0f766e);
  text-decoration: underline;
}
.muted { color: var(--muted); font-size: 0.95rem; }

.group-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 650;
}
.group-link:hover { text-decoration: underline; }

.players-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sort-pills {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.22rem;
  background: #e8ecf2;
  border-radius: 999px;
}
.sort-pill {
  appearance: none;
  border: 0;
  background: transparent;
  color: #64748b;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.42rem 1.05rem;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.25;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.sort-pill:hover { color: var(--ink); }
.sort-pill.is-active {
  background: #fff;
  color: #0f172a;
  font-weight: 750;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 1px rgba(15, 23, 42, 0.04);
}
.sort-pill:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 1.1rem;
  flex-wrap: wrap;
}
.pager-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}
.pager-btn:hover:not(:disabled) { border-color: rgba(10, 102, 255, 0.35); color: var(--accent); }
.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager-meta {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.table .col-num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  text-align: center;
  width: 5.5rem;
}
.table thead th.col-num {
  font-size: 1.05rem;
  font-weight: 750;
}

.col-event .event-title {
  display: block;
  font-weight: 650;
  color: inherit;
  text-decoration: none;
}
.col-event .event-title:hover { color: var(--accent); }
.col-event .event-date {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
