:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e4e6eb;
  --text: #14171c;
  --muted: #6a7180;
  --faint: #9aa1ad;
  --accent: #5b5bd6;
  --accent-soft: #ececfc;
  --up: #12a36a;
  --up-soft: #e3f6ed;
  --down: #e5484d;
  --down-soft: #fdecec;
  --free: #12a594;
  --paid: #3e63dd;
  --grossing: #e3860b;
  --new: #e5484d;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-hover: 0 6px 20px rgba(16, 24, 40, .10);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014;
    --surface: #161920;
    --surface-2: #1d2129;
    --border: #262b35;
    --text: #e7e9ee;
    --muted: #9aa1ad;
    --faint: #6b7280;
    --accent: #8b8cf5;
    --accent-soft: #23244a;
    --up: #3dd68c;
    --up-soft: #12301f;
    --down: #ff6b6f;
    --down-soft: #3a1618;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0;
  flex: 0 0 248px; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; }
.brand-mark {
  display: grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #8e4ec6);
}
.brand-mark svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 3; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 550;
  transition: background .15s, color .15s;
}
.nav a svg { width: 19px; height: 19px; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 0 12px; color: var(--faint); font-size: 12px; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 32px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.015em; }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.content { padding: 26px 32px 60px; max-width: 1480px; }
.content.enter { animation: enter .25s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Controls ---------- */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
}
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; padding: 6px 14px; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.btn, .select {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; box-shadow: var(--shadow);
}
.btn:hover, .select:hover { border-color: var(--faint); }
.btn svg { width: 16px; height: 16px; color: var(--muted); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%236a7180' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.control-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Cards & text ---------- */
.stack { display: flex; flex-direction: column; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 15px; font-weight: 700; }
.pill-icon svg { width: 16px; height: 16px; }
.pill-icon {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-size: 15px;
}
.day-title { margin: 4px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.md { font-size: 14.5px; line-height: 1.65; }
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md ul { margin: 0 0 12px; padding-left: 20px; }
.md li { margin: 5px 0; }
.md li ul { margin: 4px 0 6px; }
.md h4 { margin: 18px 0 6px; font-size: 14.5px; }
.md h4:first-child { margin-top: 0; }
.md blockquote {
  margin: 14px 0 0; padding: 12px 16px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent);
}
.md strong { font-weight: 650; }
.md code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: 12px;
  background: var(--surface-2); color: var(--muted); border: 1px dashed var(--border);
}
.notice strong { color: var(--text); }
.empty { padding: 28px 10px; text-align: center; color: var(--faint); }
.source-tag { font-size: 11.5px; color: var(--faint); font-weight: 600; }

/* ---------- Games ---------- */
.icon {
  flex: none; width: 56px; height: 56px; border-radius: 14px; object-fit: cover;
  background: var(--surface-2); border: 1px solid var(--border);
}
.icon.sm { width: 36px; height: 36px; border-radius: 9px; }
.icon.ph {
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px; border: 0;
}
.icon.sm.ph { font-size: 13px; }
.icon-wrap { position: relative; flex: none; }
.badge-new {
  position: absolute; top: -7px; right: -9px;
  background: var(--new); color: #fff; font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
  padding: 2px 6px; border-radius: 6px; box-shadow: 0 2px 6px rgba(229, 72, 77, .35);
}
.game {
  display: flex; gap: 14px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.game:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); border-color: transparent; }
.game-body { min-width: 0; flex: 1; }
.game-name { font-weight: 700; font-size: 14.5px; color: var(--text); line-height: 1.3; display: block; }
.game-name:hover { color: var(--accent); text-decoration: none; }
.game-meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.game-pitch { margin-top: 8px; font-size: 13.5px; line-height: 1.5; }
.game-pitch.blurb { color: var(--muted); font-style: italic; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.store {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 650; color: var(--muted);
  padding: 3px 8px; border-radius: 7px; background: var(--surface-2);
}
.store:hover { color: var(--accent); text-decoration: none; }
.store svg { width: 12px; height: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 650; padding: 3px 8px; border-radius: 7px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.chip.up { background: var(--up-soft); color: var(--up); }
.chip.down { background: var(--down-soft); color: var(--down); }
.chip.rank { background: var(--accent-soft); color: var(--accent); }

/* New entrants columns */
.columns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
.column { display: flex; flex-direction: column; gap: 12px; }
.column-head { display: flex; align-items: center; gap: 9px; padding: 2px 4px 4px; font-weight: 700; font-size: 15px; }
.column-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.column-head .count { margin-left: auto; color: var(--faint); font-weight: 650; font-size: 13px; }
.column .empty { border: 1px dashed var(--border); border-radius: 13px; }

/* Movers */
.movers { display: flex; flex-direction: column; }
.mover { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--border); }
.mover:first-child { border-top: 0; }
.mover .game-body { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mover .who { min-width: 180px; flex: 1; }
.mover .chips { margin: 0; }
.more { margin-top: 12px; }
.mover.extra { display: none; }
.expanded .mover.extra { display: flex; }
.more .when-open, .expanded .more .when-closed { display: none; }
.expanded .more .when-open { display: inline; }
.card-sub { margin: -6px 0 8px; color: var(--muted); font-size: 13px; }
.card-title .count { color: var(--faint); font-weight: 650; font-size: 13px; }
.chip.move { background: var(--surface-2); color: var(--muted); white-space: normal; max-width: 100%; }
.chip.move { display: inline-block; line-height: 1.45; }
.chip.move b { font-weight: 800; margin-right: 4px; white-space: nowrap; }
.chip.move b.up { color: var(--up); }
.chip.move b.down { color: var(--down); }
.chip .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 2px; }
.strip { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.strip-icons { display: flex; }
.strip-icons > span { margin-right: -8px; border-radius: 10px; box-shadow: 0 0 0 2px var(--surface); }
.strip-icons > span:last-child { margin-right: 0; }
.strip-icons .icon.sm { display: block; }
.strip-text { flex: 1; min-width: 220px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.summary { margin: 0; color: var(--muted); }
.summary strong { color: var(--text); }
.badge-inline { background: var(--new); color: #fff; font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; }

/* Tracker */
.tracker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }

/* Week view */
.day-list { display: flex; flex-direction: column; gap: 14px; }
.day-row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 18px; }
.day-row .when { font-weight: 700; color: var(--muted); font-size: 13px; padding-top: 2px; }
.day-row .when a { color: inherit; }
.day-row .md + .md { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.label { display: inline-block; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 3px; }

/* ---------- Calendar popover ---------- */
.popover {
  position: absolute; z-index: 50; width: 300px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(16, 24, 40, .18);
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head strong { font-size: 14px; }
.cal-nav { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.cal-nav:hover { background: var(--surface-2); color: var(--text); }
.cal-nav svg { width: 16px; height: 16px; }
.cal-mode { display: flex; margin-bottom: 10px; }
.cal-mode .segmented { width: 100%; }
.cal-mode .segmented button { flex: 1; justify-content: center; }
.cal-dows, .cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-weeks { display: flex; flex-direction: column; gap: 2px; }
.cal-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--faint); padding: 4px 0; }
.cal-day {
  position: relative; height: 36px; border: 0; border-radius: 9px; background: transparent;
  font: inherit; font-weight: 600; color: var(--faint); cursor: default;
}
.cal-day.avail { color: var(--text); }
.cal-day.avail::after {
  content: ""; position: absolute; left: 50%; bottom: 5px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--accent);
}
.day-mode .cal-day.avail { cursor: pointer; }
.day-mode .cal-day.avail:hover { background: var(--surface-2); }
.day-mode .cal-day.sel { background: var(--accent); color: #fff; }
.cal-day.sel::after, .cal-week.sel .cal-day::after { background: #fff; }
.cal-day.out { visibility: hidden; }
.week-mode .cal-week { border-radius: 9px; }
.week-mode .cal-week.avail, .week-mode .cal-week.avail .cal-day { cursor: pointer; }
.week-mode .cal-week.avail:hover { background: var(--surface-2); }
.week-mode .cal-week.sel { background: var(--accent); }
.week-mode .cal-week.sel .cal-day { color: #fff; }
.cal-nav:disabled { opacity: .3; cursor: default; background: transparent; }

/* ---------- Loading ---------- */
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Small screens ---------- */
@media (max-width: 1100px) {
  .columns { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  body { flex-direction: column; }
  .sidebar { position: static; height: auto; flex: none; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0 8px 0 0; }
  .brand-name, .sidebar-foot { display: none; }
  .nav { flex-direction: row; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .topbar { position: static; padding-top: 14px; padding-bottom: 14px; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .content { padding-top: 18px; }
  .day-row { grid-template-columns: 1fr; gap: 4px; }
}
