:root {
  --bg: #f3f4ef;
  --surface: #ffffff;
  --surface-2: #eaeee7;
  --ink: #111418;
  --muted: #626b66;
  --line: #d0d7ce;
  --gold: #d6a019;
  --brand-dark: #121816;
  --brand-green: #18362b;
  --brand-mint: #9fddb8;
  --brand-gold: #f0c363;
  --brand-cream: #ffe0a1;
  --hold: #2f6b4f;
  --purge: #8a2b2b;
  --disruption: #1f4f8a;
  --recon: #1f7a82;
  --priority: #a17b14;
  --shadow: 0 18px 45px rgba(18, 22, 28, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18px 18px, rgba(240, 195, 99, 0.12), transparent 190px),
    linear-gradient(180deg, rgba(24, 54, 43, 0.055), rgba(17, 20, 24, 0)),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

.site-header,
.site-footer,
main {
  width: min(100% - 32px, 1500px);
  margin-inline: auto;
}

.site-header {
  padding: 22px 0 14px;
  border-top: 3px solid color-mix(in srgb, var(--brand-gold) 72%, transparent);
}

.header-inner,
.controls,
.stage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

h1,
h2 {
  margin: 0;
  font-family:
    "Arial Narrow", "Roboto Condensed", "Segoe UI Condensed", Arial, sans-serif;
  font-weight: 800;
  line-height: 0.96;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.2rem);
}

h2 {
  font-size: clamp(1.35rem, 2vw, 2.2rem);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.selected-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: right;
}

.controls {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 0 16px;
  padding: 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 78%, var(--brand-gold));
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(18, 24, 22, 0.09);
  backdrop-filter: blur(14px);
}

.disposition-picker {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(5, 180px);
  gap: 10px;
  width: auto;
}

.disposition-button {
  width: 180px;
  height: 58px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 850;
  line-height: 1.12;
  text-align: left;
  text-transform: uppercase;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.disposition-button span:not(.swatch) {
  min-width: 0;
  overflow-wrap: break-word;
}

.disposition-button:hover,
.disposition-button[aria-pressed="true"] {
  background: var(--surface);
  border-color: var(--dispo-color);
  box-shadow: inset 0 0 0 1px var(--dispo-color);
}

.disposition-button[aria-pressed="true"] {
  transform: translateY(-1px);
}

.swatch {
  width: 15px;
  height: 38px;
  border-radius: 3px;
  background: var(--dispo-color);
  flex: 0 0 auto;
}

.secondary-toggle {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

.secondary-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  width: 50px;
  height: 28px;
  padding: 3px;
  border-radius: 999px;
  background: #c7d0ca;
  border: 1px solid #aeb9b2;
  transition: background 160ms ease;
}

.toggle-thumb {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 3px 9px rgba(18, 22, 28, 0.25);
  transition: transform 160ms ease;
}

.secondary-toggle input:checked + .toggle-track {
  background: var(--gold);
  border-color: var(--gold);
}

.secondary-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(22px);
}

.mission-stage,
.secondary-section {
  padding: 18px 0 22px;
}

.stage-heading {
  margin-bottom: 12px;
}

.board-scroll {
  overflow-x: auto;
  padding: 0 0 10px;
  scrollbar-color: var(--gold) transparent;
}

.matchup-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 10px;
  min-width: 920px;
}

.opponent-chip {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 6px;
  color: #fff;
  background: var(--dispo-color);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.05;
  text-align: center;
  text-transform: uppercase;
}

.mission-card {
  min-width: 0;
  display: block;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: zoom-in;
  text-align: left;
}

.mission-card:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 4px;
}

.card-caption {
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.card-role {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card-name {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.05;
}

.image-frame {
  display: block;
  position: relative;
  overflow: hidden;
  aspect-ratio: 7 / 12;
  background: #191c20;
  border: 1px solid color-mix(in srgb, var(--accent) 72%, #111);
  border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow);
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.face-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 5px 7px;
  color: #fff;
  background: rgba(17, 20, 24, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 5px;
  font-size: 0.64rem;
  font-weight: 900;
  text-transform: uppercase;
}

.secondary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}

.card-dialog {
  width: min(96vw, 780px);
  max-height: 96vh;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.card-dialog-wide,
.card-dialog-compare {
  width: min(98vw, 1180px);
}

.card-dialog-many {
  width: min(99vw, 1680px);
}

.card-dialog::backdrop {
  background: rgba(6, 8, 10, 0.86);
  backdrop-filter: blur(8px);
}

.dialog-shell {
  position: relative;
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.dialog-topbar {
  min-height: 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(36px, 1fr);
  align-items: center;
  gap: 8px;
}

.dialog-title-block {
  min-width: 0;
}

.dialog-topbar h2 {
  font-size: clamp(0.9rem, 1.35vw, 1.28rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.dialog-center {
  display: flex;
  justify-content: center;
}

.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  min-width: 36px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

#closeDialog {
  width: 34px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.compare-button {
  min-width: 150px;
  min-height: 38px;
  padding: 0 22px;
  color: #17130a;
  background: var(--gold);
  border: 2px solid color-mix(in srgb, var(--gold) 70%, #000);
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(217, 160, 23, 0.38);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease;
}

.compare-button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.compare-button[aria-pressed="true"]::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  color: #fff;
  background: #17130a;
  border-radius: 50%;
  font-size: 0.72rem;
  letter-spacing: 0;
}

.compare-button[aria-pressed="false"] {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--gold);
  box-shadow: 0 6px 18px rgba(217, 160, 23, 0.18);
}

.side-nav {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 48px;
  height: 92px;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 8px;
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-size: 3rem;
  line-height: 1;
  transform: translateY(-50%);
  transition:
    background 140ms ease,
    transform 140ms ease;
}

.side-nav:hover {
  background: var(--gold);
  transform: translateY(-50%) scale(1.03);
}

.side-nav-prev {
  left: 16px;
}

.side-nav-next {
  right: 16px;
}

.side-nav[hidden] {
  display: none;
}

.dialog-images {
  --face-count: 1;
  display: grid;
  grid-template-columns: repeat(var(--face-count), minmax(0, 1fr));
  align-items: start;
  gap: 10px;
  max-height: calc(96vh - 70px);
  overflow: auto;
}

.dialog-figure {
  min-width: 0;
  height: calc(96vh - 70px);
  display: grid;
  place-items: center;
  margin: 0;
}

.dialog-image {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 7px;
  background: #121417;
}

.site-footer {
  display: block;
  padding: 30px 0 34px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.site-footer a {
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.source-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 20px;
  color: #f0dfbf;
  background:
    linear-gradient(135deg, rgba(18, 24, 22, 0.96), rgba(24, 54, 43, 0.95)),
    var(--brand-dark);
  border: 1px solid color-mix(in srgb, var(--brand-gold) 44%, transparent);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(18, 24, 22, 0.18);
}

.source-note .source-kicker {
  margin: 0 0 8px;
  color: var(--brand-mint);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.source-note h2 {
  margin: 0;
  color: var(--brand-cream);
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.source-note p {
  max-width: 780px;
  margin: 10px 0 0;
  color: #eadfc8;
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.45;
}

.source-link {
  min-width: 150px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  color: #17130a;
  background: var(--brand-gold);
  border: 1px solid color-mix(in srgb, var(--brand-gold) 68%, #000);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  transition:
    filter 140ms ease,
    transform 140ms ease;
}

.source-link:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.footer-credit {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-align: right;
  text-transform: uppercase;
}

@media (min-width: 1180px) {
  .matchup-grid {
    min-width: 0;
  }
}

@media (max-width: 1250px) {
  .controls {
    align-items: flex-start;
    flex-direction: column;
  }

  .disposition-picker {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
  }

  .disposition-button {
    width: 100%;
  }
}

@media (max-width: 900px) {
  .header-inner,
  .controls,
  .stage-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .selected-summary {
    text-align: left;
  }

  .disposition-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .disposition-button:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .card-dialog,
  .card-dialog-wide,
  .card-dialog-compare,
  .card-dialog-many {
    width: min(100vw - 12px, 720px);
  }

  .dialog-shell {
    padding: 8px;
  }

  .dialog-images {
    grid-template-columns: minmax(0, 1fr);
    max-height: calc(96vh - 104px);
  }

  .dialog-figure {
    height: auto;
  }

  .dialog-image {
    width: 100%;
    height: auto;
    max-height: none;
  }

  .source-note {
    grid-template-columns: minmax(0, 1fr);
  }

  .source-link {
    width: 100%;
  }

  .footer-credit {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .site-header,
  .site-footer,
  main {
    width: min(100% - 20px, 1500px);
  }

  .controls {
    border-radius: 0 0 8px 8px;
    margin-inline: -10px;
  }

  .disposition-button {
    min-height: 44px;
    font-size: 0.72rem;
  }

  .matchup-grid {
    min-width: 860px;
    grid-template-columns: repeat(5, minmax(160px, 1fr));
  }

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

  .card-caption {
    min-height: 50px;
    padding: 8px;
  }

  .card-name {
    font-size: 0.72rem;
  }

  .dialog-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .dialog-center {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .dialog-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .compare-button {
    width: 100%;
  }

  .side-nav {
    top: auto;
    bottom: 14px;
    width: 54px;
    height: 48px;
    font-size: 2.4rem;
    transform: none;
  }

  .side-nav:hover {
    transform: scale(1.03);
  }

  .side-nav-prev {
    left: 16px;
  }

  .side-nav-next {
    right: 16px;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1d2227;
    --surface-2: #262d34;
    --ink: #eef2ee;
    --muted: #a7b0aa;
    --line: #3c4540;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  }

  html {
    color-scheme: dark;
  }
}
