:root {
  color-scheme: dark;
  --bg: #07101f;
  --ink: #f6f8fc;
  --muted: #aeb9c1;
  --line: rgba(174, 185, 193, 0.2);
  --panel: #0c1830;
  --panel-strong: #111f3d;
  --accent: #e51b23;
  --accent-dark: #ff4d55;
  --amber: #f3b236;
  --red: #e51b23;
  --blue: #203669;
  --green: #12b886;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(229, 27, 35, 0.18), transparent 34rem),
    radial-gradient(circle at top right, rgba(32, 54, 105, 0.76), transparent 36rem),
    linear-gradient(180deg, #07101f 0%, #0a1326 48%, #050913 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
  min-width: 0;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 16, 31, 0.92);
  backdrop-filter: blur(12px);
}

.auth-panel {
  width: min(480px, 100%);
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(17, 31, 61, 0.98), rgba(12, 24, 48, 0.98));
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-panel h1 {
  font-size: clamp(2rem, 7vw, 3.4rem);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.auth-tab,
.secondary-button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  padding: 0 10px;
}

.auth-tab.active {
  border-color: var(--accent);
  background: rgba(229, 27, 35, 0.18);
  color: #fff;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-message,
.auth-notice {
  color: var(--muted);
  line-height: 1.45;
}

.auth-message[data-tone="error"],
.auth-notice {
  color: var(--red);
}

.auth-message[data-tone="success"] {
  color: var(--accent-dark);
}

.auth-notice {
  border: 1px solid #f1c6cc;
  border-radius: 8px;
  background: rgba(229, 27, 35, 0.08);
  padding: 12px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 24px;
  border-bottom: 1px solid rgba(174, 185, 193, 0.18);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  font-size: 1.08rem;
}

.source-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  min-width: 0;
}

.source-note span,
.source-note a {
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.source-note button {
  font-size: 0.9rem;
}

.controls-band,
.question-band,
.summary-grid,
.analysis-layout,
.view-nav,
.compare-layout,
.compare-results,
#newsView {
  margin-top: 16px;
}

.view-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.view-tab {
  width: auto;
  flex: 1 1 160px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.view-tab.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(229, 27, 35, 0.28), rgba(229, 27, 35, 0.16));
  color: #fff;
}

.controls-band,
.question-band {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(17, 31, 61, 0.92), rgba(12, 24, 48, 0.9));
  box-shadow: var(--shadow);
}

.controls-band {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(4, 9, 19, 0.72);
  color: var(--ink);
  padding: 0 12px;
}

select:focus,
input:focus {
  outline: 2px solid rgba(229, 27, 35, 0.38);
  border-color: rgba(229, 27, 35, 0.72);
}

.ask-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: linear-gradient(180deg, #ff343d, #d9161e);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(229, 27, 35, 0.24);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
  color: var(--ink);
}

option {
  background: #0c1830;
  color: var(--ink);
}

.answer-text {
  color: var(--ink);
  line-height: 1.45;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-panel,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(17, 31, 61, 0.96), rgba(12, 24, 48, 0.96)),
    var(--panel);
  box-shadow: var(--shadow);
}

.metric-panel {
  min-height: 116px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  border-top: 3px solid rgba(229, 27, 35, 0.82);
}

.metric-panel.good {
  border-top-color: var(--green);
}

.metric-panel.danger {
  border-top-color: var(--red);
}

.metric-panel.good strong {
  color: var(--green);
}

.metric-panel.danger strong {
  color: #ff5b63;
}

#improversPanel,
#watchlistPanel {
  cursor: pointer;
}

#improversPanel:hover,
#watchlistPanel:hover {
  border-color: rgba(255, 255, 255, 0.34);
  transform: translateY(-1px);
}

.metric-panel span,
.metric-panel small,
.panel-head p {
  color: var(--muted);
}

.metric-panel strong {
  font-size: clamp(1.55rem, 3vw, 2.4rem);
  line-height: 1;
  color: #fff;
}

.analysis-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
}

.compare-layout {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.filter-panel {
  display: grid;
  gap: 14px;
}

.check-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--ink);
}

.check-filter input,
.player-check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.player-check-header,
.player-check-list {
  display: grid;
}

.player-check-header,
.player-check-row {
  grid-template-columns: minmax(220px, 1.2fr) minmax(160px, 0.8fr) minmax(140px, 0.7fr);
}

.player-check-header {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 10px 0;
  text-transform: uppercase;
}

.player-check-list {
  max-height: 640px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.player-check-row {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.player-check-row:hover {
  background: rgba(229, 27, 35, 0.08);
}

.player-check-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
}

.compare-control-row {
  width: min(360px, 100%);
  margin-bottom: 12px;
}

.selected-player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.selected-player-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: rgba(229, 27, 35, 0.12);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 800;
}

.compare-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 8px 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.legend-swatch {
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

.compare-chart {
  min-height: 440px;
}

.news-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.news-updated {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.84rem;
  font-weight: 800;
}

.news-controls {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr);
  gap: 14px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(17, 31, 61, 0.92), rgba(12, 24, 48, 0.9));
  box-shadow: var(--shadow);
}

.news-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.news-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(17, 31, 61, 0.96), rgba(12, 24, 48, 0.96)),
    var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
  text-decoration: none;
  transition:
    border-color 0.16s ease,
    transform 0.16s ease;
}

.news-card:hover,
.news-card:focus-visible {
  border-color: rgba(255, 255, 255, 0.34);
  transform: translateY(-2px);
  outline: none;
}

.news-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  object-fit: cover;
  background: #101d37;
}

.news-image-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.news-card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.news-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.news-source {
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(229, 27, 35, 0.18);
  color: #fff;
}

.news-card h3 {
  margin: 0;
  font-size: 1.04rem;
  line-height: 1.25;
}

.news-summary {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.news-link {
  width: fit-content;
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}

.news-card:hover .news-link {
  color: var(--accent-dark);
}

.empty-state {
  padding: 18px 0;
  color: var(--muted);
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel.wide {
  grid-column: span 1;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head select {
  width: min(340px, 44vw);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.chart {
  min-height: 260px;
}

.chart-caption {
  margin: 8px 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chart.compact {
  min-height: 360px;
}

svg {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: block;
}

.axis {
  fill: var(--muted);
  font-size: 11px;
}

.grid-line {
  stroke: rgba(174, 185, 193, 0.14);
  stroke-width: 1;
}

.line-path {
  fill: none;
  stroke: #22c7b7;
  stroke-width: 3;
}

.movers-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.mover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.03);
}

.mover strong {
  display: block;
  overflow-wrap: anywhere;
}

.mover span {
  color: var(--muted);
  font-size: 0.84rem;
}

.pill {
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.up {
  background: var(--green);
}

.pill.down {
  background: var(--red);
}

.pill.flat {
  background: #667383;
}

.table-panel,
.pav-panel {
  align-self: start;
}

.table-wrap {
  overflow: auto;
  max-height: 480px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #101d37;
  z-index: 1;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
.mover:hover {
  background: rgba(229, 27, 35, 0.08);
}

.bar-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.bar-value {
  fill: var(--muted);
  font-size: 11px;
}

.line-label {
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 980px) {
  .topbar {
    display: grid;
    align-items: start;
  }

  .controls-band,
  .summary-grid,
  .analysis-layout,
  .compare-layout,
  .news-controls,
  .news-grid {
    grid-template-columns: 1fr;
  }

  .news-header {
    display: grid;
    align-items: start;
  }

  .ask-row {
    grid-template-columns: 1fr;
  }

  .panel-head {
    display: grid;
  }

  .panel-head select {
    width: 100%;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: 100%;
    padding: 18px 14px 32px;
  }

  .topbar {
    gap: 16px;
    padding-bottom: 18px;
  }

  h1 {
    font-size: clamp(2.35rem, 14vw, 3.3rem);
    line-height: 0.98;
    overflow-wrap: anywhere;
  }

  .eyebrow {
    font-size: 0.72rem;
  }

  .source-note {
    justify-content: flex-start;
    gap: 8px;
    font-size: 0.82rem;
  }

  .source-note span,
  .source-note a,
  .source-note button {
    min-height: 34px;
    padding: 7px 9px;
  }

  #userBadge {
    max-width: min(100%, 19rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #seasonBadge {
    border-radius: 8px;
    white-space: normal;
  }

  .view-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(174, 185, 193, 0.22);
    background: rgba(7, 16, 31, 0.94);
    backdrop-filter: blur(14px);
    box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.34);
  }

  .view-tab {
    flex: none;
    min-height: 50px;
    padding: 0 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: clamp(0.7rem, 3.2vw, 0.84rem);
    line-height: 1.12;
    white-space: normal;
    box-shadow: none;
  }

  .view-tab.active {
    background: rgba(229, 27, 35, 0.22);
    box-shadow: inset 0 3px 0 var(--accent);
  }

  .app-shell {
    padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }

  .controls-band,
  .question-band,
  .news-controls,
  .panel {
    padding: 14px;
  }

  .ask-row {
    gap: 12px;
  }

  select,
  input,
  button {
    min-height: 44px;
    font-size: 1rem;
  }

  .summary-grid {
    gap: 10px;
  }

  .metric-panel {
    min-height: 96px;
    padding: 14px;
  }

  .player-check-header,
  .player-check-row {
    grid-template-columns: minmax(150px, 1fr) minmax(96px, 0.7fr) minmax(98px, 0.7fr);
  }

  .player-check-list,
  .table-wrap {
    overflow-x: auto;
  }

  .panel-head {
    gap: 10px;
  }

  .chart,
  .compare-chart {
    min-height: 240px;
  }

  .chart.compact {
    min-height: 300px;
  }

  .news-card-body {
    padding: 12px;
  }
}

@media (max-width: 380px) {
  #userBadge {
    max-width: 100%;
  }
}
