:root {
  --bg: #10121a;
  --surface: #191c27;
  --surface-2: #20242f;
  --border: #2b3040;
  --text: #eef0f6;
  --text-muted: #8a90a6;
  --text-faint: #5c6178;

  --great: #2b8cff;
  --ultra: #f2b705;
  --premier: #ff6fa5;
  --master: #8b5cf6;

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --radius: 14px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(43,140,255,0.10), transparent 60%),
    radial-gradient(ellipse 900px 500px at 90% 0%, rgba(139,92,246,0.10), transparent 60%);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

a { color: inherit; }

/* ---------- Header ---------- */

.site-header {
  padding: 28px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ultra);
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(22px, 5vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.header-note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 52ch;
}

button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--ultra);
  outline-offset: 2px;
}

.last-updated {
  max-width: 980px;
  margin: 14px auto 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-faint);
}

/* ---------- Layout ---------- */

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 20px 60px;
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.view-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  width: 100%;
}

.view-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.view-tab[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border) inset;
}

.tier-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tier-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px 7px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  user-select: none;
}

.tier-chip[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--chip-color, var(--border));
  box-shadow: 0 0 0 1px var(--chip-color, transparent) inset;
}

.tier-chip .count {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 11.5px;
}

/* ---------- Tier status strip (errors / loading) ---------- */

.tier-status-strip {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.tier-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid var(--border);
}

.tier-status.loading { color: var(--text-muted); background: var(--surface); }
.tier-status.error {
  color: #ffb4b4;
  background: rgba(224,57,62,0.08);
  border-color: rgba(224,57,62,0.35);
}
.tier-status.warn {
  color: #ffd98a;
  background: rgba(242,183,5,0.07);
  border-color: rgba(242,183,5,0.3);
}

.tier-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--dot-color, currentColor);
  flex-shrink: 0;
}

.retry-link {
  margin-left: auto;
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  padding: 0;
}

/* ---------- Date accordion ---------- */

.date-section {
  margin-bottom: 10px;
}

.date-section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.date-section-toggle:hover { border-color: #3a4155; }
.date-section-toggle.expanded {
  background: var(--surface-2);
  border-radius: 12px 12px 0 0;
  border-bottom-color: var(--border);
}

.date-section-toggle .chevron {
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform 0.15s;
}
.date-section-toggle.expanded .chevron {
  transform: rotate(180deg);
  color: var(--ultra);
}

.date-section-title { flex: 1; min-width: 0; }

.date-section-count {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

.date-section-content {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 12px 12px;
  padding: 10px;
  background: rgba(0,0,0,0.12);
}
.date-section-content:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Event cards ---------- */

.event-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-left: 3px solid var(--card-color, var(--border));
}

.event-date-line {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.event-main { min-width: 0; flex: 1; }

.event-tier-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.event-tier-row .tier-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--card-color, var(--text-muted));
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.event-shop {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15.5px;
  margin: 0 0 3px;
  overflow-wrap: anywhere;
}

.event-name {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text);
  margin: 0 0 2px;
  overflow-wrap: anywhere;
}

.event-format {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-muted);
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.event-meta .time {
  font-family: var(--font-mono);
  color: var(--text);
  flex-shrink: 0;
}

.event-meta .location {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.register-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  background: var(--card-color, var(--ultra));
  color: #10121a;
  font-weight: 700;
  font-size: 12.5px;
  padding: 7px 16px;
  border-radius: 999px;
  text-decoration: none;
}
.register-btn:hover { filter: brightness(1.08); }

.event-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  min-width: 140px;
}

.website-btn,
.calendar-btn,
.listing-btn,
.add-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  text-decoration: none;
}

.website-btn {
  background: var(--card-color, var(--surface-2));
  border-color: transparent;
  color: #10121a;
}

.calendar-btn {
  border-color: var(--card-color, var(--border));
  color: var(--card-color, var(--text));
}
.calendar-btn:hover { background: color-mix(in srgb, var(--card-color, var(--text)) 12%, transparent); }

.listing-btn:hover { color: var(--text); border-color: #3a4155; }

.add-toggle { cursor: pointer; }
.add-toggle svg { flex-shrink: 0; }
.add-toggle.added {
  color: #14161f;
  background: var(--card-color, var(--ultra));
  border-color: transparent;
}

.no-website {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-align: center;
  padding: 6px 0;
}

@media (max-width: 480px) {
  .event-actions { min-width: 108px; }
  .website-btn, .calendar-btn, .listing-btn, .add-toggle { font-size: 11px; padding: 6px 8px; }
}

/* ---------- Empty / notice states ---------- */

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.csv-notice {
  margin-top: 24px;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.6;
}
.csv-notice code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* ---------- Footer ---------- */

.site-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 90px;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.6;
}

.disclaimer {
  margin-top: 8px;
  color: var(--text-faint);
  font-style: italic;
}

/* ---------- My List: floating button ---------- */

.mylist-fab {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--ultra);
  color: #14161f;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  padding: 12px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  transition: transform 0.15s;
}
.mylist-fab:active { transform: scale(0.96); }

.mylist-count {
  background: rgba(20,22,31,0.85);
  color: var(--ultra);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

/* ---------- My List: modal ---------- */

.mylist-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: flex-end;
  justify-content: center;
}
.mylist-modal:not([hidden]) {
  display: flex;
}

.mylist-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8,9,14,0.65);
}

.mylist-modal-inner {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 82vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 620px) {
  .mylist-modal { align-items: center; }
  .mylist-modal-inner { border-radius: 18px; border-bottom: 1px solid var(--border); max-height: 76vh; }
}

.mylist-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mylist-modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.icon-btn:hover { color: var(--text); }

.mylist-items {
  overflow-y: auto;
  padding: 8px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mylist-item {
  display: grid;
  grid-template-columns: 3px 1fr auto auto;
  gap: 12px;
  align-items: center;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.mylist-item .swatch { align-self: stretch; border-radius: 3px; background: var(--item-color, var(--border)); }
.mylist-item .info { min-width: 0; }
.mylist-item .info .shop { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mylist-item .info .evname { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mylist-item .info .meta { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
.mylist-item .remove-btn {
  background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 15px; padding: 4px 6px;
}
.mylist-item .remove-btn:hover { color: #ffb4b4; }

.mylist-cal-link {
  display: inline-flex;
  align-items: center;
  color: var(--text-faint);
  padding: 4px 6px;
  border-radius: 6px;
  text-decoration: none;
}
.mylist-cal-link:hover { color: var(--ultra); background: rgba(242,183,5,0.1); }

.mylist-empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.mylist-modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.text-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.text-btn:hover { color: var(--text); border-color: #3a4155; }

.export-btn {
  flex: 1;
  background: var(--ultra);
  color: #14161f;
  border: none;
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.export-btn:hover { filter: brightness(1.05); }
.export-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Add-to-list toggle on event cards ---------- */



/* -------------------- LEADERBOARD -------------------- */
.leaderboard:not([hidden]) { display: block; }
.lb-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.lb-divisions { display: inline-flex; background: var(--surface); border-radius: 10px; padding: 3px; }
.lb-search {
  flex: 1 1 180px; min-width: 0; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--surface-2);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
}
.lb-status { margin: 0 0 4px; font-size: 12.5px; color: var(--text-muted); }
.lb-rule { margin: 0 0 14px; font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.lb-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row { background: var(--surface); border-radius: 12px; overflow: hidden; }
.lb-player {
  all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; cursor: pointer; color: var(--text);
}
.lb-player:hover { background: var(--surface-2); }
.lb-rank { width: 34px; font-family: "IBM Plex Mono", monospace; font-weight: 500; color: var(--text-muted); text-align: right; }
.lb-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lb-name .n { font-weight: 600; overflow-wrap: anywhere; }
.lb-name .id { font-size: 11.5px; color: var(--text-faint); }
.lb-total { font-family: "IBM Plex Mono", monospace; font-weight: 500; }
.lb-detail { border-top: 1px solid var(--surface-2); padding: 6px 14px 10px; }
.lb-entry { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 13px; }
.lb-entry + .lb-entry { border-top: 1px solid var(--surface-2); }
.lb-entry .t a { color: var(--text); text-decoration: none; font-weight: 500; }
.lb-entry .t a:hover { text-decoration: underline; }
.lb-entry .m { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.lb-entry .p { white-space: nowrap; font-family: "IBM Plex Mono", monospace; }
.lb-entry.not-counted { opacity: .45; }
.lb-entry.not-counted .p { text-decoration: line-through; }
#tierFilters[hidden], #tierStatusStrip[hidden], #eventContainer[hidden] { display: none !important; }

.site-nav { display: flex; gap: 6px; margin-bottom: 14px; }
.site-nav a {
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 500; text-decoration: none;
  color: var(--text-muted); background: var(--surface);
}
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.lb-sources { margin-bottom: 12px; }
.lb-more, .lb-share {
  all: unset; box-sizing: border-box; cursor: pointer; text-align: center; font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 10px; background: var(--surface-2); color: var(--text);
}
.lb-more { margin-top: 8px; }
.lb-share { margin-top: 10px; display: block; width: 100%; background: var(--text); color: var(--bg); }
.lb-more:hover, .lb-share:hover { filter: brightness(1.1); }
.lb-share:disabled { opacity: .6; cursor: default; }
.lb-note { margin: 8px 0 4px; font-size: 12px; color: var(--text-muted); line-height: 1.5; }
.header-inner { flex-wrap: wrap; }
.header-inner > .site-nav { flex: 0 0 100%; }
.lb-tier {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: 5px;
  padding: 2px 10px 2px 8px; border-radius: 999px; border: 1.5px solid var(--c);
  background: var(--surface-2); color: var(--text); font-size: 11.5px; font-weight: 500;
}
.lb-entry { border-left: 3px solid var(--c, transparent); padding-left: 10px; }
.lb-entry .t a { font-size: 15px; font-weight: 600; }
.lb-entry .side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.lb-rankpill {
  background: #fff; color: #10121a; font-size: 12px; font-weight: 700; letter-spacing: .02em;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.lb-entry .p { font-size: 19px; font-weight: 700; color: var(--text); }
.lb-entry.not-counted .p { font-size: 14px; font-weight: 500; }
.lb-rankpill { font-size: 10.5px; padding: 2px 8px; }
.lb-entry .side { gap: 4px; }
