:root {
  color-scheme: light;
  --bg: #f4f2ed;
  --ink: #1b1b1f;
  --muted: #64666d;
  --line: #d7d2c8;
  --panel: #ffffff;
  --accent: #b7372f;
  --accent-strong: #8c211c;
  --teal: #0f766e;
  --blue: #365f91;
  --shadow: 0 16px 40px rgba(22, 25, 33, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 28px clamp(16px, 4vw, 48px) 22px;
  border-bottom: 1px solid var(--line);
  background: #fbfaf7;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 980px;
  font-size: clamp(1.8rem, 3.4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.15;
  letter-spacing: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  gap: 8px;
  min-width: min(420px, 100%);
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
}

.stats strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.1;
}

.stats span {
  color: var(--muted);
  font-size: 0.82rem;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.compare-band,
.leaderboard-band,
.notes {
  padding: 28px 0;
}

.prompt-row,
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin-bottom: 16px;
}

.secondary-button {
  min-height: 42px;
  border: 1px solid #b9b2a6;
  border-radius: 8px;
  background: #fffdfa;
  color: var(--ink);
  padding: 9px 14px;
  cursor: pointer;
}

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

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.leaderboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  min-height: 42px;
  border: 1px solid #b9b2a6;
  border-radius: 8px;
  background: #fffdfa;
}

.segment {
  min-width: 104px;
  border: 0;
  border-right: 1px solid #d3cabd;
  background: transparent;
  color: var(--ink);
  padding: 9px 12px;
  cursor: pointer;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: var(--ink);
  color: #ffffff;
}

.status,
.result {
  min-height: 28px;
  margin-bottom: 12px;
  color: var(--muted);
}

.result {
  color: var(--ink);
  font-weight: 700;
}

.pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-height: 360px;
}

.crime-card {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  width: 100%;
  min-height: 360px;
  border: 2px solid #cabfb0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: clamp(16px, 2.2vw, 24px);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 120ms ease, transform 120ms ease;
}

.crime-card:hover,
.crime-card:focus-within {
  border-color: var(--accent);
  outline: none;
  transform: translateY(-2px);
}

.crime-card[aria-busy="true"] {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 4px 10px;
  background: #ece7dd;
  color: #342f28;
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.outcome {
  background: #f8d7d0;
  color: var(--accent-strong);
}

.badge.level {
  background: #dce9e7;
  color: #07534d;
}

.case-number {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.charge {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  font-weight: 850;
  line-height: 1.08;
  letter-spacing: 0;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.detail {
  min-width: 0;
}

.detail span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail strong {
  display: block;
  margin-top: 2px;
  font-size: 0.95rem;
  line-height: 1.25;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.docket-link,
.docket-missing {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 800;
}

.docket-link {
  border: 1px solid #b9b2a6;
  background: #fffdfa;
  color: var(--blue);
  padding: 8px 12px;
  text-decoration: none;
}

.docket-link:hover,
.docket-link:focus-visible {
  border-color: var(--blue);
  outline: none;
  text-decoration: underline;
}

.docket-missing {
  color: var(--muted);
}

.pick-button {
  min-height: 42px;
  border: 1px solid var(--accent-strong);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 850;
}

.pick-button:hover,
.pick-button:focus-visible {
  background: var(--accent-strong);
  outline: none;
}

.pick-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfa;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.rating-cell {
  min-width: 170px;
}

.rating-bar {
  width: 100%;
  height: 8px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5dfd4;
}

.rating-bar span {
  display: block;
  height: 100%;
  width: var(--bar-width, 0%);
  background: linear-gradient(90deg, var(--teal), var(--accent));
}

.notes {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.notes p {
  max-width: 980px;
  margin: 0 0 8px;
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    min-width: 0;
  }

  .pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  main {
    width: min(100% - 20px, 1180px);
  }

  .topbar {
    padding-inline: 10px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .prompt-row,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .leaderboard-actions {
    justify-content: stretch;
  }

  .segmented,
  .leaderboard-actions .secondary-button {
    width: 100%;
  }

  .segment {
    flex: 1;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
