/*
 * Bates Cottages CC — club colours: yellow (#F5F20A) and black.
 * Yellow is only ever a background behind dark text, or text on dark:
 * yellow text on white is unreadable.
 */
:root {
  /* Brand */
  --yellow: #F5F20A;
  --yellow-soft: #fdfcd2;   /* highlighted rows */
  --yellow-glow: rgba(245, 242, 10, .16);

  /* Neutrals (warm) */
  --ink: #0b0b0c;           /* near-black: header, hero, text */
  --ink-2: #18181b;
  --ink-3: #27272a;
  --text: #18181b;
  --muted: #5d5d66;         /* passes contrast on white */
  --faint: #8e8e98;
  --line: #e9e8e4;
  --line-2: #dcdbd6;
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 16, 20, .04), 0 2px 8px rgba(16, 16, 20, .04);
  --shadow-lift: 0 2px 4px rgba(16, 16, 20, .05), 0 12px 28px rgba(16, 16, 20, .08);
  --display: "Space Grotesk", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--ink); text-decoration-color: var(--line-2); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { text-decoration-color: var(--ink); }
h1, h2, h3 { font-family: var(--display); line-height: 1.1; color: var(--ink); margin: 0 0 .5em; letter-spacing: -.02em; font-weight: 700; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); }
h2 { font-size: 1.35rem; letter-spacing: -.015em; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--yellow); color: var(--ink); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(11, 11, 12, .92);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  color: #fff;
}
.site-header::after { content: ""; display: block; height: 3px; background: var(--yellow); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; padding-top: 6px; padding-bottom: 6px; flex-wrap: wrap; }
/* aye684 logo (back to the aye684.com home page), then a thin divider, then the club crest */
.brand-group { display: flex; align-items: center; gap: 14px; min-width: 0; }
.aye684-logo { flex: none; display: block; line-height: 0; padding-right: 14px; border-right: 1px solid rgba(255, 255, 255, .18); }
.aye684-logo img { height: 44px; width: auto; display: block; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand-logo { height: 48px; width: auto; display: block; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--yellow); color: var(--ink); font: 700 1rem var(--display);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font: 700 1.15rem var(--display); letter-spacing: -.01em; }
.brand-sub { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--yellow); font-weight: 600; margin-top: 3px; }
.site-nav { display: flex; gap: 2px; flex-wrap: wrap; }
.site-nav a {
  color: rgba(255, 255, 255, .78); text-decoration: none; padding: 8px 14px; border-radius: 999px;
  font-weight: 500; font-size: .92rem; transition: background .15s, color .15s;
}
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.site-nav a.active { background: var(--yellow); color: var(--ink); font-weight: 600; }
.site-header :focus-visible { outline-color: var(--yellow); }
.nav-toggle {
  display: none; background: rgba(255, 255, 255, .08); color: #fff; border: 0; border-radius: 999px;
  padding: 8px 16px; font: 600 .9rem Inter, sans-serif; cursor: pointer;
}

/* Seven menu items need about 1040px in one row; below that, use the Menu button. */
@media (max-width: 1040px) {
  .nav-toggle { display: block; }
  .site-nav { display: none; width: 100%; flex-direction: column; padding-bottom: 12px; }
  .site-nav a { border-radius: var(--radius-sm); padding: 10px 14px; }
  .nav-open .site-nav { display: flex; }
}
/* Tablets: menu items in two columns rather than one long list */
@media (min-width: 641px) and (max-width: 1040px) {
  .nav-open .site-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
}

.main { padding-top: 32px; padding-bottom: 64px; min-height: 60vh; }

/* ---------- Home hero ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; grid-template-columns: 1fr auto; gap: 32px; align-items: center;
  background: var(--ink); color: #fff; border-radius: 24px;
  padding: clamp(28px, 5vw, 56px); margin-bottom: 40px;
}
.hero::before {   /* soft yellow glow behind the crest */
  content: ""; position: absolute; z-index: -1; right: -10%; top: -30%; width: 60%; aspect-ratio: 1;
  background: radial-gradient(closest-side, var(--yellow-glow), transparent);
}
.hero::after {    /* thin yellow edge */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--yellow);
}
.hero h1 { color: #fff; margin-bottom: 14px; }
.hero .lead { color: rgba(255, 255, 255, .72); }
.hero-crest { width: clamp(150px, 22vw, 240px); height: auto; filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .5)); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 16px;
  font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--yellow);
}
.eyebrow::before { content: ""; width: 18px; height: 2px; background: currentColor; border-radius: 2px; }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 48ch; margin: 0; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  background: var(--yellow); color: var(--ink); padding: 11px 20px; border-radius: 999px;
  font-weight: 600; font-size: .95rem; transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(245, 242, 10, .25); }
.btn.ghost { background: transparent; color: #fff; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .3); }
.btn.ghost:hover { background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .6); }
.hero-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 120px)); gap: 10px; margin-top: 32px; }
.hero .stat {
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px; padding: 12px 14px;
}
.stat-num { display: block; font: 700 1.9rem/1.1 var(--display); color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hero .stat-num { color: var(--yellow); }
.stat-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.hero .stat-label { color: rgba(255, 255, 255, .6); }
.stat-caption { margin: 10px 0 0; font-size: .8rem; color: rgba(255, 255, 255, .5); }
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .hero-crest { order: -1; width: 110px; }
  .hero-stats { grid-template-columns: repeat(4, 1fr); }
  .hero .stat { padding: 10px; text-align: center; }
  .hero .stat-num { font-size: 1.5rem; }
}

/* ---------- Sections & headings ---------- */
.section { margin-bottom: 44px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.section-head h2 { margin: 0; }
.section-head a {
  font-weight: 600; font-size: .9rem; white-space: nowrap; text-decoration: none;
  padding: 6px 12px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
}
.section-head a:hover { background: var(--ink); color: #fff; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { margin: 0; }
.page-head h1::after, .section > h2::after, .section-head h2::after {
  content: ""; display: block; width: 40px; height: 4px; margin-top: 10px; border-radius: 4px; background: var(--yellow);
}
.month { font: 600 .78rem Inter, sans-serif; text-transform: uppercase; letter-spacing: .14em; color: var(--faint); margin: 32px 0 12px; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; }
.filters label { display: flex; flex-direction: column; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); gap: 6px; }
.filters select {
  font: 500 .95rem Inter, sans-serif; text-transform: none; letter-spacing: 0; color: var(--ink);
  padding: 10px 38px 10px 14px; min-width: 150px; border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%230b0b0c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  -webkit-appearance: none; appearance: none; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.filters select:hover { border-color: var(--faint); }
.filters select:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--yellow-glow); }
.filters select[name="player"] { min-width: 220px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 20px;
}
.list { display: grid; gap: 10px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
@media (max-width: 400px) { .grid { grid-template-columns: 1fr; } }

.fixture { display: flex; align-items: center; gap: 18px; padding: 16px 20px; transition: box-shadow .15s, transform .15s; }
.fixture:hover { box-shadow: var(--shadow-lift); }
.date-chip { flex: none; width: 58px; text-align: center; background: var(--ink); color: #fff; border-radius: 12px; padding: 8px 0 7px; }
.dc-day { display: block; font: 700 1.5rem/1 var(--display); color: var(--yellow); }
.dc-mon { display: block; font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .14em; margin-top: 4px; color: rgba(255, 255, 255, .75); }
.fx-body { flex: 1; min-width: 0; }
.fx-teams { font-weight: 600; font-size: 1.02rem; }
.fx-teams .vs { color: var(--faint); font-weight: 500; margin: 0 6px; }
.ours { color: var(--ink); font-weight: 700; }
.fx-meta, .fx-comp { font-size: .875rem; color: var(--muted); }
.fx-comp { color: var(--faint); }
.tag { flex: none; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; padding: 5px 10px; border-radius: 999px; }
.tag.home { background: var(--yellow); color: var(--ink); }
.tag.away { background: var(--bg); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2); }
@media (max-width: 520px) { .fixture { align-items: flex-start; padding: 14px; gap: 14px; } .tag { display: none; } }

.result { display: flex; flex-direction: column; gap: 10px; transition: box-shadow .15s, transform .15s; }
.result:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.res-top { display: flex; justify-content: space-between; align-items: center; }
.res-date { font-size: .82rem; color: var(--faint); font-weight: 500; }
.res-teams { font-weight: 600; font-size: 1.02rem; }
.res-scores { list-style: none; margin: 0; padding: 4px 12px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--line); }
.res-scores li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; font-size: .92rem; }
.res-scores li + li { border-top: 1px solid var(--line); }
.res-scores strong { font-family: var(--display); font-variant-numeric: tabular-nums; }
.res-desc { font-size: .875rem; color: var(--muted); }
.res-link { margin-top: auto; font-size: .875rem; font-weight: 600; color: var(--ink); text-decoration: none; display: inline-flex; gap: 4px; }
.res-link:hover { text-decoration: underline; }

/* Result badges: won = yellow, lost = black, drawn = grey, other = light grey */
.badge { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; padding: 5px 10px; border-radius: 999px; }
.badge.win  { background: var(--yellow); color: var(--ink); }
.badge.loss { background: var(--ink); color: #fff; }
.badge.draw { background: var(--muted); color: #fff; }
.badge.na   { background: var(--bg); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-2); }

.empty { background: var(--surface); border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 36px; text-align: center; color: var(--muted); }
.notice { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--yellow); border-radius: var(--radius-sm); padding: 12px 16px; font-size: .9rem; margin: 0 0 20px; }
.notice.error { border-left-color: var(--ink); background: var(--surface-2); }

/* ---------- Scorecard ---------- */
.match-head { margin-bottom: 32px; padding: 28px; position: relative; overflow: hidden; }
.match-head::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--yellow); }
.match-head .eyebrow { color: var(--muted); }
.match-title { font-size: clamp(1.5rem, 3.5vw, 2.2rem); }
.match-title .vs { color: var(--faint); font-weight: 500; }
.match-result { display: inline-block; font-weight: 600; font-size: 1rem; background: var(--ink); color: var(--yellow); padding: 8px 14px; border-radius: 999px; margin: 8px 0; }
.innings-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.innings-head h2::after { display: none; }
.innings-total { font: 700 1.15rem var(--display); background: var(--yellow); color: var(--ink); padding: 4px 14px; border-radius: 999px; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); margin: 12px 0; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line-2);
}
th:first-child, td:first-child, th.how, td.how, th.team, td.team, td.name { text-align: left; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.how { color: var(--muted); white-space: normal; }
td.name { white-space: normal; font-weight: 500; }
td strong { font-weight: 700; color: var(--ink); }
.how-mobile { display: none; }
tfoot td { background: var(--surface-2); border-top: 1px solid var(--line-2); border-bottom: 0; }
tfoot .total td { font-weight: 700; color: var(--ink); }
@media (max-width: 600px) {
  .score th.how, .score td.how { display: none; }
  .how-mobile { display: block; font-size: .8rem; color: var(--muted); font-weight: 400; }
}
td.dismissal { text-align: left; color: var(--muted); white-space: normal; min-width: 120px; }
th.dismissal { text-align: left; }
td .sub { display: block; font-size: .78rem; color: var(--faint); }
td.name a, td.team a { color: var(--ink); font-weight: 600; text-decoration: none; }
td.name a:hover, td.team a:hover { text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 3px; }
tfoot .total td:first-child { white-space: normal; font-weight: 600; font-size: .85rem; }

/* Sortable tables: headings are buttons; ▼/▲ shows the current order */
.sortable th { padding: 0; }
.sort-btn {
  display: block; width: 100%; padding: 11px 12px; border: 0; background: none; cursor: pointer;
  font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; text-align: inherit; white-space: nowrap;
  transition: color .1s, background .1s;
}
.sortable th:first-child .sort-btn { padding-left: 18px; }
.sortable th:last-child .sort-btn { padding-right: 18px; }
.sort-btn::after { content: "↕"; margin-left: 4px; opacity: .35; font-size: .95em; }
.sort-btn:hover { color: var(--ink); background: var(--bg); }
.sort-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
th[aria-sort] .sort-btn { color: var(--ink); box-shadow: inset 0 -3px 0 var(--yellow); }
th[aria-sort="descending"] .sort-btn::after { content: "▼"; opacity: 1; font-size: .75em; }
th[aria-sort="ascending"] .sort-btn::after { content: "▲"; opacity: 1; font-size: .75em; }

/* ---------- Player stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin: 12px 0 36px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; position: relative; overflow: hidden;
}
.stat-tile::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--yellow); }
.stat-tile .stat-num { font-size: 1.7rem; }
@media (max-width: 760px) { .stat-row { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Season records ---------- */
.records { display: grid; gap: 16px; }
.record { padding: 0; overflow: hidden; scroll-margin-top: 96px; }  /* clear the sticky header when jumped to */
.record:target { box-shadow: 0 0 0 3px var(--yellow), var(--shadow-lift); }
.record-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.record-head h3 { font-size: 1.1rem; margin: 0; letter-spacing: -.01em; }
.record-top { flex: none; font-size: .8rem; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 10px; border-radius: 999px; }
.record-top:hover { background: var(--bg); color: var(--ink); }

/* Jump buttons at the top of the records page */
.records-nav { display: grid; gap: 14px; margin-bottom: 36px; padding: 18px 20px; scroll-margin-top: 96px; }
.records-nav-group { display: grid; grid-template-columns: 90px 1fr; gap: 12px; align-items: baseline; }
.records-nav-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.records-nav-links { display: flex; flex-wrap: wrap; gap: 8px; }
.records-nav-links a {
  font-size: .85rem; font-weight: 600; text-decoration: none; color: var(--ink);
  padding: 7px 14px; border-radius: 999px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line-2);
  transition: background .15s, color .15s, box-shadow .15s;
}
.records-nav-links a:hover { background: var(--yellow); box-shadow: inset 0 0 0 1px var(--ink); }
@media (max-width: 600px) { .records-nav-group { grid-template-columns: 1fr; gap: 6px; } }
.record-note { margin: 2px 0 0; font-size: .78rem; color: var(--faint); }
.record-empty { padding: 16px 18px; margin: 0; }
.record-table { font-size: .88rem; }
.record-table th { background: transparent; border-bottom: 1px solid var(--line); padding: 8px 10px; }
.record-table td { padding: 9px 10px; vertical-align: top; }
.record-table th.left, .record-table td.left { text-align: left; white-space: normal; }
.record-table td.left a { color: var(--ink); font-weight: 600; text-decoration: none; }
.record-table td.left a:hover { text-decoration: underline; text-decoration-color: var(--yellow); text-decoration-thickness: 3px; }
.record-table td:not(.left) a { color: var(--ink); text-decoration: none; }
.record-table .rank { width: 34px; text-align: center; padding-left: 14px; padding-right: 0; color: var(--faint); font-weight: 600; }
.record-table tbody tr:first-child .rank { color: var(--ink); }
.record-table tbody tr:first-child .rank::before {   /* yellow dot for the record holder */
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--yellow);
  box-shadow: 0 0 0 2px var(--ink); margin-right: 6px; vertical-align: 1px;
}
.record-table td .sub { white-space: nowrap; }
.sub-inline { color: var(--faint); font-size: .8rem; font-weight: 400; }

/* League tables: our team's row highlighted in yellow */
.league tr.mine td { background: var(--yellow-soft); font-weight: 700; color: var(--ink); }
.league tr.mine td:first-child { box-shadow: inset 4px 0 0 var(--yellow); }
.league td.team { white-space: normal; min-width: 160px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--ink); color: rgba(255, 255, 255, .62); padding: 36px 0; font-size: .9rem; }
.site-footer strong { color: #fff; font-family: var(--display); font-size: 1.05rem; }
.site-footer a { color: var(--yellow); }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.footer-meta { max-width: 380px; }

/* ---------- Loading overlay (includes/loader.php) ---------- */
/* The yellow bar at the top shows at once; the dimmed page and the ball card fade in after a
   short pause (longer on first load), so pages that arrive quickly never flash it. */
.loader {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  --loader-delay: .3s;
}
.loader.boot { --loader-delay: .6s; animation: loader-gone 0s linear 90s forwards; }  /* safety net if a page never finishes */
@keyframes loader-gone { to { visibility: hidden; } }
.loader[hidden] { display: none; }
.loader::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: rgba(11, 11, 12, .55);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: loader-in .25s ease-out var(--loader-delay) both;
}
.loader-card {
  width: min(360px, 100%); text-align: center; padding: 28px 24px 24px;
  background: var(--ink); color: #fff; border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45); border-bottom: 4px solid var(--yellow);
  animation: loader-in .25s ease-out var(--loader-delay) both;
}
/* After a tap or picklist change, show it at full strength at once: no fade or timer to rely on,
   because some phones stop animating once the next page starts loading. */
.loader.show::before, .loader.show .loader-card { animation: none; opacity: 1; }
/* Thin loading bar across the very top of the screen */
.loader-bar { position: fixed; top: 0; left: 0; right: 0; height: 4px; overflow: hidden; background: rgba(245, 242, 10, .25); z-index: 1; }
.loader-bar::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -40%; width: 40%;
  background: var(--yellow); box-shadow: 0 0 10px var(--yellow);
  animation: loader-bar 1.1s ease-in-out infinite;
}
@keyframes loader-bar { to { left: 100%; } }
.loader-ball { width: 84px; height: 84px; display: block; margin: 0 auto 16px; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, .45)); }
/* Only the leather and seam spin; the lighting stays still, like a real ball under floodlights */
.loader-ball .ball-turn { transform-box: view-box; transform-origin: 50% 50%; animation: ball-spin 1.2s linear infinite; }
.loader-title { margin: 0 0 6px; font: 700 1.15rem var(--display); color: var(--yellow); letter-spacing: -.01em; }
.loader-text { margin: 0; min-height: 3em; font-size: .95rem; line-height: 1.5; color: rgba(255, 255, 255, .8); }
body.is-loading { cursor: progress; }
@keyframes ball-spin { to { transform: rotate(360deg); } }
@keyframes loader-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Tables wider than the screen (any device) ---------- */
/* footer.php adds .scrolls when a table is wider than its box, .scrolled once swiped, and
   .at-end at the far right; plus a "Swipe the table" hint above it. */
.swipe-hint { text-align: right; font-size: .76rem; color: var(--faint); margin: 6px 0 -4px; }

/* The first column stays put while the rest scroll sideways */
.table-wrap.scrolls th:first-child, .table-wrap.scrolls td:first-child {
  position: sticky; left: 0; z-index: 2; background: var(--surface);
}
.table-wrap.scrolls th:first-child, .table-wrap.scrolls tfoot td:first-child { background: var(--surface-2); }
.table-wrap.scrolled th:first-child, .table-wrap.scrolled td:first-child { box-shadow: 6px 0 8px -6px rgba(16, 16, 20, .25); }
.table-wrap.scrolls:not(.at-end) { box-shadow: inset -18px 0 14px -14px rgba(16, 16, 20, .22); }

/* League tables: # and Team stay put together */
.table-wrap.scrolls .league th:first-child, .table-wrap.scrolls .league td:first-child { width: 38px; min-width: 38px; max-width: 38px; padding-right: 0; }
.table-wrap.scrolls .league th.team, .table-wrap.scrolls .league td.team {
  position: sticky; left: 38px; z-index: 2; background: var(--surface);
}
.table-wrap.scrolls .league th.team { background: var(--surface-2); }
.table-wrap.scrolled .league td.team, .table-wrap.scrolled .league th.team { box-shadow: 6px 0 8px -6px rgba(16, 16, 20, .25); }
.table-wrap.scrolled .league td:first-child, .table-wrap.scrolled .league th:first-child { box-shadow: none; }
.table-wrap.scrolls .league tr.mine td.team, .table-wrap.scrolls .league tr.mine td:first-child { background: var(--yellow-soft); }

/* League tables on phones and tablets: key columns only, with "Show all columns" */
.cols-toggle {
  display: none; margin-top: 4px; font: 600 .85rem Inter, sans-serif; color: var(--ink); cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px; padding: 9px 16px; min-height: 40px;
}
@media (max-width: 900px) {
  .table-block:not(.show-all) .league .opt { display: none; }
  .cols-toggle { display: inline-flex; }
}

/* ---------- Phones ---------- */

@media (max-width: 640px) {
  .main { padding-top: 20px; padding-bottom: 44px; }
  h1 { font-size: clamp(1.7rem, 8vw, 2.1rem); }
  h2 { font-size: 1.2rem; }
  .section { margin-bottom: 32px; }

  /* Header */
  .header-inner { min-height: 60px; }
  .brand-logo { height: 40px; }
  .brand-name { font-size: 1.02rem; }
  .brand-group { gap: 10px; }
  .aye684-logo { padding-right: 10px; }
  .aye684-logo img { height: 34px; }
  .nav-toggle { min-height: 40px; }
  .site-nav a { font-size: 1rem; padding: 12px 14px; }   /* bigger tap targets in the menu */

  /* Page headings and filters: picklists in a tidy full-width grid */
  .page-head { flex-direction: column; align-items: stretch; gap: 16px; margin-bottom: 20px; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .filters label { min-width: 0; }
  .filters label:only-of-type, .filters label:has(select[name="player"]) { grid-column: 1 / -1; }
  .filters select, .filters select[name="player"] {
    min-width: 0; width: 100%; min-height: 46px;
    font-size: 16px;   /* 16px stops iPhones zooming in when a picklist is tapped */
  }

  .card { padding: 16px; }
  .section-head a { font-size: .82rem; padding: 6px 10px; }

  /* Tables: edge to edge, tighter cells */
  .table-wrap {
    margin-left: -16px; margin-right: -16px; border-radius: 0; border-left: 0; border-right: 0;
    -webkit-overflow-scrolling: touch;
  }
  th, td { padding: 10px 8px; font-size: .86rem; }
  th { font-size: .64rem; letter-spacing: .06em; }
  th:first-child, td:first-child, .sortable th:first-child .sort-btn { padding-left: 14px; }
  th:last-child, td:last-child, .sortable th:last-child .sort-btn { padding-right: 14px; }
  .sort-btn { padding: 10px 8px; }
  td.name { min-width: 112px; }
  .league td.team, .league th.team { min-width: 130px; }

  /* Scorecard */
  .match-head { padding: 20px 18px; }
  .match-result { border-radius: 12px; font-size: .92rem; }
  .innings-total { font-size: 1rem; }

  /* Fixtures and results */
  .fx-teams, .res-teams { font-size: .98rem; }

  /* Player stats tiles */
  .stat-row { gap: 8px; margin-bottom: 28px; }
  .stat-tile { padding: 12px 10px; }
  .stat-tile .stat-num { font-size: 1.35rem; }
  .stat-tile .stat-label { font-size: .64rem; }

  /* Records: wrap text so tables fit; scroll sideways only if they still can't */
  .records-nav { padding: 14px; gap: 12px; }
  .records-nav-links { gap: 6px; }
  .records-nav-links a { font-size: .8rem; padding: 8px 12px; }
  .record-head { padding: 14px; }
  .record-top { padding: 6px 8px; }
  .record-table th, .record-table td { white-space: normal; padding: 9px 6px; }
  .record-table .rank { width: 30px; padding-left: 10px; }
  .record-table td .sub { white-space: normal; }
  .record-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .footer-inner { flex-direction: column; gap: 14px; }
}

/* Anyone who has asked their device for less motion gets none */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  /* Keep the loader's short pause (no movement), so quick pages still don't flash it */
  .loader::before, .loader-card { animation: loader-in .01s linear var(--loader-delay) both !important; }
  .loader.show::before, .loader.show .loader-card { animation: none !important; }
  .loader-bar::before { left: 0; width: 100%; }   /* a still bar instead of a moving one */
}
