:root {
  color-scheme: dark;
  --page: #080b10;
  --panel: #0d1219;
  --panel-raised: #111822;
  --ink: #eef3fb;
  --muted: #8e9bad;
  --quiet: #697689;
  --line: #28313f;
  --line-bright: #3a4657;
  --cyan: #62d9ff;
  --green: #8df2b0;
  --amber: #ffc56d;
  --rose: #ff7896;
  --font-display: "Avenir Next", "DIN Alternate", "PingFang SC", sans-serif;
  --font-body: "Avenir Next", "Noto Sans SC", "PingFang SC", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(rgba(98, 217, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 217, 255, 0.014) 1px, transparent 1px),
    var(--page);
  background-size: 72px 72px;
  color: var(--ink);
  font-family: var(--font-body);
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

::selection {
  background: var(--cyan);
  color: #061018;
}

.calibration-rail {
  position: fixed;
  z-index: 10;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 0;
  border-right: 1px solid rgba(98, 217, 255, 0.16);
  background: rgba(8, 11, 16, 0.92);
  color: #526072;
  font: 9px var(--font-mono);
  text-align: center;
  pointer-events: none;
}

.calibration-rail::after {
  content: "";
  position: absolute;
  top: 0;
  right: -4px;
  width: 7px;
  height: 100%;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 19px,
    rgba(98, 217, 255, 0.18) 20px,
    transparent 21px
  );
}

.atlas-shell {
  width: min(1480px, calc(100% - 82px));
  margin: 0 auto;
  padding: 0 0 54px;
}

.atlas-header {
  position: relative;
  padding: 54px 0 34px;
  border-bottom: 1px solid var(--line);
}

.header-index {
  position: absolute;
  top: 58px;
  right: 0;
  color: #425063;
  font: 10px var(--font-mono);
  letter-spacing: 0.16em;
}

.atlas-kicker,
.section-label,
.section-code {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.atlas-kicker {
  color: var(--cyan);
  font-size: 11px;
}

.atlas-header h1 {
  max-width: 960px;
  margin: 14px 0 18px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(46px, 6vw, 86px);
  font-weight: 700;
  letter-spacing: -0.065em;
  line-height: 0.92;
}

.atlas-header h1 em {
  color: #8b98aa;
  font-style: normal;
  font-weight: 400;
}

.atlas-header > p {
  max-width: 850px;
  margin: 0;
  color: #a0acbc;
  font-size: 15px;
  line-height: 1.75;
}

.dataset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 24px;
}

.dataset-strip span {
  padding: 8px 11px;
  border: 1px solid #2d3745;
  color: #a8b4c4;
  background: rgba(13, 18, 25, 0.72);
  font: 600 10px var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.dataset-strip b {
  color: var(--ink);
}

.atlas-section {
  padding-top: 46px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.section-label {
  display: block;
  margin-bottom: 8px;
  color: #7f8c9f;
  font-size: 10px;
}

.section-heading h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(23px, 2.4vw, 32px);
  letter-spacing: -0.035em;
}

.section-heading p {
  margin: 7px 0 0;
  color: #8492a5;
  font-size: 13px;
  line-height: 1.5;
}

.section-code {
  flex: 0 0 auto;
  color: #4e5c6f;
  font-size: 9px;
}

.control-deck {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(360px, 3fr);
  gap: 14px;
  margin-bottom: 16px;
  padding: 13px;
  border: 1px solid var(--line-bright);
  background: rgba(13, 18, 25, 0.9);
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field > span {
  color: #8d99aa;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.field > small {
  color: #69778a;
  font-size: 10px;
}

.field input,
.field select {
  width: 100%;
  height: 42px;
  margin-top: 3px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 0;
  outline: 0;
  background: #111923;
  color: var(--ink);
  font-size: 13px;
  transition: border-color 140ms ease, background 140ms ease;
}

.field input:hover,
.field select:hover {
  background: #141d28;
}

.field input:focus,
.field select:focus {
  border-color: var(--cyan);
  background: #101a24;
}

.field input[aria-invalid="true"] {
  border-color: var(--rose);
}

.density-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.density-card {
  min-width: 0;
  padding: 17px 14px 10px;
  border: 1px solid var(--line);
  background: rgba(13, 18, 26, 0.94);
  transition: border-color 160ms ease, transform 160ms ease;
}

.density-card:hover,
.density-card:focus-within {
  border-color: #465368;
  transform: translateY(-2px);
}

.density-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
}

.density-heading div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.density-heading strong {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.density-heading > span {
  color: #778599;
  font: 600 10px var(--font-mono);
  text-transform: uppercase;
}

.metric-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
}

.density-card > p {
  min-height: 36px;
  margin: 8px 0 0;
  color: #8996a8;
  font-size: 11px;
  line-height: 1.5;
}

.density-card svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-grid line {
  stroke: #26303d;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.density-fill {
  opacity: 0.12;
}

.density-line {
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}

.quartiles line {
  stroke: #718095;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.axis-ticks line {
  stroke: #536174;
}

.axis-ticks text,
.axis-label {
  fill: #758397;
  font: 10px var(--font-mono);
}

.hover-marker line {
  stroke: #69788c;
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.hover-marker text {
  fill: #a8b4c5;
  font: 11px var(--font-mono);
}

.selected-marker line {
  stroke: #f4f7fb;
  stroke-width: 1.5;
}

.selected-marker text {
  fill: #f4f7fb;
  font: 700 11px var(--font-mono);
}

.density-hitbox {
  fill: transparent;
  cursor: crosshair;
  outline: none;
}

.density-hitbox:focus {
  stroke: #f4f7fb;
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}

.slice-summary {
  min-height: 42px;
  margin: 0 0 18px;
  padding: 10px 13px;
  border-left: 2px solid var(--cyan);
  color: #b8c3d1;
  font-size: 13px;
}

.slice-summary code {
  padding: 2px 5px;
  background: #bdcad9;
  color: #071018;
  font-family: var(--font-mono);
}

.slice-summary b {
  color: var(--ink);
}

.table-frame {
  max-height: 450px;
  overflow: auto;
  border: 1px solid var(--line-bright);
  scrollbar-color: #4e5b6d #0a0e14;
}

.games-table {
  width: 100%;
  border-collapse: collapse;
  color: #d9e2ed;
  font: 11px var(--font-mono);
}

.games-table th,
.games-table td {
  padding: 11px 10px;
  border-right: 1px solid #2b3543;
  border-bottom: 1px solid #1a222d;
  text-align: left;
  white-space: nowrap;
}

.games-table th:last-child,
.games-table td:last-child {
  border-right: 0;
}

.games-table th {
  position: sticky;
  z-index: 2;
  top: 0;
  background: #0a0e14;
  color: #c9d2de;
  font-weight: 700;
}

.games-table tbody tr {
  outline: none;
  background: #0d131b;
  cursor: pointer;
  transition: background 120ms ease, box-shadow 120ms ease;
}

.games-table tbody tr:nth-child(even) {
  background: #111923;
}

.games-table tbody tr:hover,
.games-table tbody tr:focus,
.games-table tbody tr.is-selected {
  background: #132331;
  box-shadow: inset 2px 0 var(--cyan);
}

.game-row-button {
  width: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}

.game-row-button:focus-visible {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.coverage-cell {
  font-weight: 700;
  letter-spacing: 0.05em;
}

.coverage-cell.high {
  color: var(--cyan);
}

.coverage-cell.medium {
  color: var(--amber);
}

.coverage-cell.low {
  color: var(--rose);
}

.game-report {
  margin: 0 0 16px;
  padding: 22px;
  border: 1px solid #2a3442;
  background: rgba(13, 18, 25, 0.96);
}

.game-report-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  color: #7e8a9b;
  font: 700 9px var(--font-mono);
  letter-spacing: 0.16em;
}

.game-report h3 {
  margin: 5px 0 18px;
  color: #f0f4fa;
  font-family: var(--font-display);
  font-size: clamp(25px, 3vw, 36px);
  letter-spacing: -0.04em;
}

.coverage-badge {
  padding: 7px 9px;
  border: 1px solid;
  font: 700 9px var(--font-mono);
  white-space: nowrap;
}

.coverage-badge.high {
  color: var(--cyan);
  border-color: #28627a;
}

.coverage-badge.medium {
  color: var(--amber);
  border-color: #72592d;
}

.coverage-badge.low {
  color: var(--rose);
  border-color: #75384a;
}

.metric-readout-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.metric-readout-grid > div {
  padding: 16px;
  border-right: 1px solid var(--line);
}

.metric-readout-grid > div:first-child {
  padding-left: 0;
}

.metric-readout-grid > div:last-child {
  border-right: 0;
}

.metric-readout-grid span,
.metric-readout-grid small {
  display: block;
  color: #7f8c9e;
  font: 600 9px var(--font-mono);
  text-transform: uppercase;
}

.metric-readout-grid strong {
  display: block;
  margin: 5px 0;
  color: var(--ink);
  font: 500 34px var(--font-mono);
}

.game-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  padding-top: 16px;
  color: #8996a8;
  font-size: 12px;
}

.game-facts b {
  color: #e9eef6;
  font-family: var(--font-mono);
}

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

.frame-card {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: 0;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  transition: border-color 150ms ease, transform 150ms ease;
}

.frame-card:hover,
.frame-card:focus-visible {
  z-index: 1;
  border-color: var(--cyan);
  transform: translateY(-3px);
}

.frame-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  background: #05070a;
}

.frame-caption {
  display: grid;
  gap: 5px;
  min-height: 70px;
  padding: 10px 11px 12px;
}

.frame-caption strong {
  color: #dbe4ef;
  font: 600 10px var(--font-mono);
}

.frame-caption span {
  overflow: hidden;
  color: #7f8c9e;
  font-size: 10px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frame-card::after {
  content: "OPEN +";
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 6px;
  background: rgba(6, 10, 15, 0.82);
  color: #a9b6c6;
  font: 8px var(--font-mono);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.frame-card:hover::after,
.frame-card:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.method-note {
  margin-top: 42px;
  padding: 24px 0 0;
  border-top: 1px solid var(--line);
  color: #7f8b9d;
  font-size: 11px;
  line-height: 1.8;
}

.method-note strong {
  color: #bbc5d2;
}

.frame-dialog {
  width: min(1240px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100vh - 48px);
  padding: 0;
  overflow: hidden;
  border: 1px solid #4a586d;
  border-radius: 0;
  background: #090d13;
  color: var(--ink);
}

.frame-dialog::backdrop {
  background: rgba(1, 3, 6, 0.88);
  backdrop-filter: blur(5px);
}

.dialog-close {
  position: absolute;
  z-index: 3;
  top: 12px;
  right: 12px;
  padding: 7px 9px;
  border: 1px solid #475467;
  background: rgba(8, 12, 18, 0.88);
  color: #c3cdda;
  font: 9px var(--font-mono);
}

.dialog-close:hover,
.dialog-close:focus-visible {
  border-color: var(--cyan);
  color: white;
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.35fr) minmax(260px, 0.65fr);
  min-height: 620px;
}

.dialog-image-stage {
  display: grid;
  place-items: center;
  min-width: 0;
  background: #030507;
}

.dialog-image-stage img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 50px);
  object-fit: contain;
  image-rendering: auto;
}

.dialog-layout aside {
  padding: 58px 24px 28px;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: #0d1219;
}

.dialog-layout h2 {
  margin: 5px 0 22px;
  font-family: var(--font-display);
  font-size: 24px;
}

.dialog-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-bottom: 22px;
  background: var(--line);
}

.dialog-meta div {
  padding: 11px;
  background: #111923;
}

.dialog-meta span,
.dialog-meta b {
  display: block;
}

.dialog-meta span {
  margin-bottom: 4px;
  color: #718095;
  font: 8px var(--font-mono);
  text-transform: uppercase;
}

.dialog-meta b {
  color: #dce5f0;
  font-size: 12px;
}

.element-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.element-list span {
  padding: 6px 7px;
  border: 1px solid #2f3a49;
  color: #aeb9c8;
  font: 9px var(--font-mono);
}

.element-list .empty {
  color: var(--rose);
  border-color: #6b3343;
}

.loading-screen {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--page);
  color: #c7d1de;
  transition: opacity 260ms ease, visibility 260ms ease;
}

.loading-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loading-screen b,
.loading-screen span {
  display: block;
  font-family: var(--font-mono);
}

.loading-screen b {
  font-size: 11px;
  letter-spacing: 0.14em;
}

.loading-screen span {
  margin-top: 5px;
  color: #657386;
  font-size: 9px;
}

.loading-mark {
  width: 28px;
  height: 28px;
  border: 1px solid #243140;
  border-top-color: var(--cyan);
  animation: spin 760ms linear infinite;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 10px 12px;
  border: 1px solid #673747;
  background: #1b1016;
  color: #ffc1cf;
  font-size: 11px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.fatal-error {
  padding: 22px;
  border: 1px solid #76384b;
  background: #1b1016;
  color: #ffc1cf;
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: reveal 480ms ease forwards;
}

.reveal-1 { animation-delay: 40ms; }
.reveal-2 { animation-delay: 110ms; }
.reveal-3 { animation-delay: 180ms; }
.reveal-4 { animation-delay: 250ms; }

@keyframes reveal {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .density-grid {
    grid-template-columns: 1fr;
  }

  .density-card > p {
    min-height: 0;
  }

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

  .dialog-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .frame-dialog {
    overflow-y: auto;
  }

  .dialog-image-stage img {
    max-height: 58vh;
  }

  .dialog-layout aside {
    overflow: visible;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .calibration-rail,
  .header-index,
  .section-code {
    display: none;
  }

  .atlas-shell {
    width: calc(100% - 28px);
  }

  .atlas-header {
    padding-top: 34px;
  }

  .control-deck {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: start;
  }

  .table-frame {
    margin-right: -14px;
    margin-left: -14px;
    border-right: 0;
    border-left: 0;
  }

  .metric-readout-grid {
    grid-template-columns: 1fr;
  }

  .metric-readout-grid > div {
    padding-left: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-readout-grid > div:last-child {
    border-bottom: 0;
  }

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

  .game-report-title {
    display: block;
  }

  .coverage-badge {
    display: inline-block;
    margin-bottom: 14px;
  }

  .frame-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 16px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
