:root {
  --bg: #0e1116;
  --panel: #161b23;
  --panel-2: #1d242e;
  --border: #2a3340;
  --text: #e6ebf2;
  --muted: #8b97a8;
  --accent: #4da3ff;
  --pos: #3ecf8e;
  --neg: #ff6b6b;
  --pill: #223047;
}

body.light-theme {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-2: #eef2f7;
  --border: #cfd8e3;
  --text: #111827;
  --muted: #4b5563;
  --accent: #0284c7;
  --pos: #059669;
  --neg: #dc2626;
  --pill: #e0f2fe;
}

.theme-toggle-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; gap: 16px; }
.header-left { display: flex; align-items: center; gap: 24px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.brand { color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: 0.5px; white-space: nowrap; }
.brand span { color: var(--accent); }
.brand-logo { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.brand-logo .logo-dark { display: inline-block; }
.brand-logo .logo-light { display: none; }
body.light-theme .brand-logo .logo-dark { display: none; }
body.light-theme .brand-logo .logo-light { display: inline-block; }

main { padding: 24px 20px 48px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 16px;
  overflow-x: auto;
}

h2 { margin: 0 0 10px; font-size: 19px; }
h3 { margin: 16px 0 8px; font-size: 15px; color: var(--accent); }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.05em; }
.strong { font-weight: 700; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.big-number {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 42px; font-weight: 700; letter-spacing: 6px; color: var(--accent);
}
a.number-link { color: var(--accent); text-decoration: none; }
a.number-link:hover { text-decoration: underline; }

table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 10px 0; }
table:not(.narrow) { min-width: 720px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }
th[title*="Click to sort"] { cursor: pointer; transition: color 0.15s, background 0.15s; }
th[title*="Click to sort"]:hover { color: var(--accent); background: rgba(56, 139, 253, 0.08); border-radius: 4px; }
tr:hover td { background: var(--panel-2); }
.selected-row td { background: var(--pill); }
table.narrow { max-width: 560px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.active-sort { font-weight: 700; color: var(--accent) !important; text-decoration: underline; }

.pill {
  display: inline-block; background: var(--pill); border-radius: 999px;
  padding: 1px 9px; font-size: 12px; color: var(--accent);
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; display: inline-flex; flex-direction: column; align-items: center; min-width: 64px;
}
.chip small { color: var(--muted); font-size: 11px; }
.muted-chip { color: var(--muted); }

.button {
  display: inline-block; margin-top: 8px; background: var(--accent); color: #0b1220;
  font-weight: 600; padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.button:hover { text-decoration: none; filter: brightness(1.1); }

.callout {
  background: var(--panel-2); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 0 8px 8px 0; margin: 12px 0; font-size: 14px;
}

.notes { padding-left: 18px; }
.notes li { margin-bottom: 6px; }

.lookup-form { display: flex; gap: 10px; margin: 10px 0; }
.lookup-form input {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 12px; width: 120px; font-size: 18px;
  font-family: ui-monospace, Menlo, monospace; letter-spacing: 4px;
}
.lookup-form button {
  background: var(--accent); color: #0b1220; border: none; border-radius: 8px;
  padding: 9px 18px; font-weight: 700; cursor: pointer;
}

.stat { display: flex; flex-direction: column; background: var(--panel-2); border-radius: 8px; padding: 12px; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 20px; font-weight: 700; margin-top: 4px; }

.barchart { margin: 8px 0; }
.bar-row { display: grid; grid-template-columns: 56px 1fr 72px; gap: 8px; align-items: center; margin: 2px 0; }
.bar-label { color: var(--muted); font-size: 11.5px; font-family: ui-monospace, Menlo, monospace; }
.bar-track { background: var(--panel-2); border-radius: 4px; height: 14px; overflow: hidden; }
.bar { display: block; height: 100%; }
.bar-pos { background: var(--pos); }
.bar-neg { background: var(--neg); }
.bar-value { font-size: 12px; text-align: right; font-family: ui-monospace, Menlo, monospace; }

details { margin: 8px 0; }
details summary { cursor: pointer; color: var(--accent); }

.pill-active { background: var(--accent); color: #0b1220; font-weight: 700; }
a.pill:hover { text-decoration: none; filter: brightness(1.15); }
.periods { display: flex; flex-wrap: wrap; gap: 6px; }

.site-footer {
  border-top: 1px solid var(--border); background: var(--panel);
  padding: 18px 20px 28px; color: var(--muted); font-size: 13px;
}
.site-footer .muted { font-size: 12px; }

/* ---- mobile / responsive ---- */
@media (max-width: 760px) {
  main { padding: 14px 10px 36px; }
  .header-inner { padding: 10px; flex-direction: row; justify-content: space-between; align-items: center; }
  .header-left { gap: 10px; }
  .header-right { gap: 8px; }
  .game-switch select { width: auto; max-width: 140px; }
  nav {
    display: flex;
    overflow-x: auto;
    width: 100%;
    padding: 4px 0 6px;
    gap: 8px;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  nav a {
    margin-left: 0;
    font-size: 13px;
    padding: 5px 11px;
    border-radius: 6px;
    background: var(--panel-2);
    display: inline-block;
    flex-shrink: 0;
  }
  nav a.active {
    background: var(--pill);
    color: var(--accent);
    font-weight: 600;
  }
  .big-number { font-size: 30px; letter-spacing: 3px; }
  .card { padding: 14px 12px; overflow-x: auto; }
  table { white-space: nowrap; -webkit-overflow-scrolling: touch; }
  table.narrow { max-width: none; }
  th, td { padding: 6px 8px; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .lookup-form input { width: 96px; font-size: 16px; }
  .bar-row { grid-template-columns: 44px 1fr 60px; }
  .periods { gap: 4px; }
  .pill { padding: 3px 10px; font-size: 12px; }
  form p label { display: block; }
  input, select { max-width: 100%; }
}
@media (max-width: 420px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.state-game-picker {
  display: flex;
  align-items: center;
  gap: 6px;
}
.state-game-picker select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.state-game-picker select:focus {
  border-color: var(--accent);
}
@media (max-width: 768px) {
  .state-game-picker {
    gap: 4px;
  }
  .state-game-picker select {
    font-size: 12px;
    padding: 4px 6px;
    max-width: 115px;
  }
}
@media (max-width: 420px) {
  .state-game-picker select {
    max-width: 88px;
    font-size: 11px;
    padding: 3px 4px;
  }
}

.bar-row-wide { grid-template-columns: 64px 1fr 170px; }

/* ---- Desktop Navigation & Dropdowns ---- */
nav.desktop-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-group {
  position: relative;
  display: inline-block;
}
.nav-link, .nav-group-btn {
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}
.nav-link:hover, .nav-group-btn:hover,
.nav-link.active, .nav-group-btn.active {
  color: var(--accent);
  background: var(--panel-2);
}
.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
}
.nav-group:hover .nav-dropdown,
.nav-group:focus-within .nav-dropdown {
  display: block;
}
.nav-dropdown a {
  display: block;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
}
.nav-dropdown a:hover {
  background: var(--panel-2);
  color: var(--accent);
}
.nav-dropdown a.active {
  background: var(--pill);
  color: var(--accent);
  font-weight: 600;
}

/* ---- Sister Sub-Nav Tabs ---- */
.subnav-bar {
  margin: 12px 0 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.subnav-bar::-webkit-scrollbar { display: none; }
.subnav-tabs {
  display: inline-flex;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 10px;
  white-space: nowrap;
}
.subnav-tab {
  padding: 6px 14px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
}
.subnav-tab:hover {
  color: var(--text);
  background: var(--panel-2);
}
.subnav-tab.active {
  color: #fff;
  background: var(--accent);
}
body.light-theme .subnav-tab.active {
  color: #fff;
}

/* ---- Nationwide Segmented Tab Grid (Responsive & Bounded) ---- */
.nationwide-nav-wrap {
  margin: 16px 0 22px 0;
  width: 100%;
}
.nationwide-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
}
.nationwide-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
  cursor: pointer;
  box-sizing: border-box;
  white-space: normal;
  line-height: 1.3;
}
.nationwide-tab:hover {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(31, 111, 235, 0.1);
}
.nationwide-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(31, 111, 235, 0.35);
}
body.light-theme .nationwide-tab.active {
  color: #fff;
  background: var(--accent);
}

@media (max-width: 900px) {
  .nationwide-tabs {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 6px;
  }
  .nationwide-tab {
    font-size: 12px;
    padding: 8px 10px;
  }
}

@media (max-width: 540px) {
  .nationwide-tabs {
    grid-template-columns: 1fr;
  }
  .nationwide-tab {
    padding: 10px 12px;
    font-size: 13px;
  }
}

/* ---- Slide-out Mobile Drawer & Backdrop ---- */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 10000;
}
.drawer-backdrop.open {
  display: block;
}
.mobile-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: 85%;
  max-width: 340px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.5);
  z-index: 10001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 20px;
}
.mobile-drawer.open {
  transform: translateX(0);
}
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.drawer-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}
.drawer-category {
  margin-bottom: 16px;
}
.drawer-category-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 700;
  margin: 0 0 6px 0;
}
.drawer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 4px;
}
.drawer-link:hover, .drawer-link.active {
  background: var(--panel-2);
  color: var(--accent);
}
.drawer-link.active {
  font-weight: 600;
}
.menu-toggle-btn {
  display: none;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 15px;
  cursor: pointer;
}

/* ---- Mobile Bottom App Dock ---- */
.mobile-bottom-dock {
  display: none;
}

@media (max-width: 768px) {
  body {
    padding-bottom: 68px;
  }
  nav.desktop-nav {
    display: none;
  }
  .menu-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mobile-bottom-dock {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 58px;
    background: rgba(22, 27, 35, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    justify-content: space-around;
    align-items: center;
    z-index: 999;
    padding: 0 4px;
  }
  body.light-theme .mobile-bottom-dock {
    background: rgba(255, 255, 255, 0.94);
  }
  .dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    flex: 1;
    height: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 0;
    gap: 2px;
  }
  .dock-item:hover, .dock-item.active {
    color: var(--accent);
  }
  .dock-icon {
    font-size: 18px;
    line-height: 1;
  }
}
