:root {
  color-scheme: dark;
  --bg: #08090c;
  --panel: #11141a;
  --panel-2: #171b23;
  --ink: #f4efe6;
  --muted: #a7aeba;
  --soft: #727b89;
  --line: #2c3340;
  --line-strong: #404a5a;
  --red: #d84d4d;
  --gold: #d2ad62;
  --green: #5ac08d;
  --blue: #63a6d9;
  --purple: #a988db;
  --shadow: 0 24px 80px rgb(0 0 0 / 38%);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 20% 0%, rgb(216 77 77 / 12%), transparent 26rem),
    linear-gradient(135deg, #08090c 0%, #10131a 52%, #0a0d11 100%);
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(18px);
  background: rgb(8 9 12 / 86%);
}

.topbar {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1240px;
  min-height: 76px;
  padding: 0 1.25rem;
}

.brand {
  align-items: center;
  display: inline-flex;
  gap: 0.85rem;
  text-decoration: none;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--red), var(--gold));
  border-radius: 8px;
  color: #111;
  display: inline-flex;
  font-weight: 900;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.nav-toggle {
  display: none;
}

.nav-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  justify-content: flex-end;
}

.nav-links a {
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  padding: 0.55rem 0.7rem;
  text-decoration: none;
}

.nav-links a.active,
.nav-links a:hover {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--ink);
}

main {
  margin: 0 auto;
  max-width: 1240px;
  padding: 2rem 1.25rem 5rem;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.hero {
  align-items: stretch;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  min-height: calc(100vh - 140px);
}

.hero-copy {
  align-content: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  padding: 5rem 0 4rem;
}

.eyebrow {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 0 0 1rem;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(2.8rem, 9vw, 7.8rem);
  letter-spacing: 0;
  line-height: 0.88;
  margin-bottom: 1.5rem;
  max-width: 920px;
}

.page-heading h1 {
  font-size: clamp(2.2rem, 5vw, 4.8rem);
  max-width: 980px;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.hero-copy p:not(.eyebrow) {
  font-size: 1.15rem;
  max-width: 680px;
}

.hero-actions,
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.button {
  align-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 44px;
  padding: 0.68rem 0.9rem;
  text-decoration: none;
}

.button.primary {
  background: linear-gradient(135deg, #d84d4d, #d2ad62);
  border-color: transparent;
  color: #111;
}

.button:hover {
  border-color: var(--gold);
}

.command-panel,
.tool-panel,
.metric-card,
.scorecard,
.table-wrap,
.settings-grid article,
.feature-grid article,
.empty-state {
  background: rgb(17 20 26 / 92%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.command-panel {
  align-self: center;
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.panel-header,
.battle-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.panel-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.85rem;
}

.panel-header span,
.battle-row span {
  color: var(--muted);
}

.panel-header strong {
  color: var(--gold);
  font-size: 2rem;
}

.battle-meter,
.mini-meter {
  background: #222832;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.battle-meter span,
.mini-meter span {
  background: linear-gradient(90deg, var(--red), var(--gold), var(--green));
  display: block;
  height: 100%;
}

.feature-grid,
.settings-grid,
.metric-grid,
.leader-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1.25rem;
}

.feature-grid article,
.settings-grid article {
  padding: 1.2rem;
}

.feature-grid span {
  color: var(--red);
  font-weight: 900;
}

.page-heading {
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
  padding: 2.5rem 0 1.25rem;
}

.tool-panel {
  align-items: end;
  display: grid;
  gap: 0.85rem;
  grid-template-columns: minmax(260px, 1fr) 220px 180px 180px max-content;
  margin-bottom: 1rem;
  padding: 1rem;
}

.tool-panel.compact {
  display: flex;
}

.versus-form {
  grid-template-columns: repeat(2, minmax(220px, 1fr)) 180px max-content max-content;
}

.settings-form {
  grid-template-columns: minmax(260px, 1fr) max-content max-content;
}

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

input,
select {
  background: #090b0f;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  width: 100%;
}

.status-line {
  color: var(--soft);
  font-size: 0.9rem;
  margin: 0.4rem 0 1rem;
}

.source-notice {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
}

.source-notice strong {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.source-notice span {
  color: var(--muted);
}

.source-notice.live {
  background: rgb(90 192 141 / 10%);
  border-color: rgb(90 192 141 / 46%);
}

.source-notice.live strong {
  color: var(--green);
}

.meta-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 1rem;
}

.meta-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
}

.meta-grid span {
  color: var(--soft);
  display: block;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.meta-grid strong {
  display: block;
  font-size: 0.96rem;
  margin-top: 0.35rem;
  overflow-wrap: anywhere;
}

.error-state {
  border-color: rgb(216 77 77 / 62%);
}

.error-state strong {
  color: var(--red);
}

.notice,
.debug-line {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  margin-top: 0.85rem;
  padding: 0.8rem;
}

.debug-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.debug-line span {
  font-size: 0.82rem;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  padding: 1rem;
}

.metric-card span {
  color: var(--soft);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  font-size: 1.65rem;
  margin-top: 0.35rem;
}

.scorecard {
  margin-top: 1rem;
  padding: 1rem;
}

.scorecard-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding-bottom: 1rem;
}

.versus-score {
  color: var(--gold);
  font-size: clamp(2rem, 6vw, 4.5rem);
  font-weight: 900;
}

.category-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.category {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
}

.category span {
  color: var(--soft);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.category strong {
  display: block;
  margin: 0.3rem 0;
}

.table-wrap {
  margin-top: 1rem;
  overflow: auto;
}

.table-section {
  margin-top: 1.25rem;
}

.table-section h2,
.scorecard h2 {
  margin-bottom: 0.7rem;
}

table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.85rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  color: var(--muted);
}

td strong {
  color: var(--ink);
}

.badge {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 900;
  padding: 0.28rem 0.55rem;
}

.badge.gold {
  border-color: rgb(210 173 98 / 55%);
  color: var(--gold);
}

.badge.green {
  border-color: rgb(90 192 141 / 55%);
  color: var(--green);
}

.badge.red {
  border-color: rgb(216 77 77 / 55%);
  color: var(--red);
}

.empty-state {
  color: var(--muted);
  padding: 1.2rem;
}

.guest-editor {
  display: flex;
  gap: 0.5rem;
}

.guest-editor input {
  min-width: 180px;
}

.modal-backdrop {
  align-items: center;
  background: rgb(0 0 0 / 72%);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 50;
}

.modal-backdrop[hidden] {
  display: none;
}

.comment-modal {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.85rem;
  max-height: min(600px, calc(100vh - 2rem));
  max-width: 980px;
  padding: 1rem;
  width: min(980px, 100%);
}

.modal-header {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding-bottom: 0.8rem;
}

.modal-header h2 {
  margin: 0;
}

.modal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-comments {
  display: grid;
  gap: 0.75rem;
  max-height: 450px;
  overflow: auto;
  padding-right: 0.25rem;
}

.comment-evidence {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
}

.comment-evidence p {
  color: var(--ink);
  margin-bottom: 0.7rem;
}

.comment-evidence dl {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 0.55rem;
}

.comment-evidence dt {
  color: var(--soft);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.comment-evidence dd {
  color: var(--muted);
  margin: 0;
}

.comment-evidence small {
  color: var(--soft);
}

code {
  color: var(--gold);
}

@media (max-width: 980px) {
  .hero,
  .feature-grid,
  .settings-grid,
  .metric-grid,
  .leader-grid,
  .category-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .tool-panel,
  .versus-form,
  .settings-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding-bottom: 1rem;
    padding-top: 1rem;
  }

  .nav-toggle {
    align-self: flex-start;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    display: inline-flex;
    padding: 0.55rem 0.8rem;
  }

  .nav-links {
    display: none;
    justify-content: flex-start;
  }

  .nav-links.open {
    display: flex;
  }

  .hero {
    min-height: 0;
  }

  .hero-copy {
    padding-top: 2rem;
  }
}
