:root {
  color-scheme: dark;
  --ink: #f3f2ec;
  --muted: #aaa9b4;
  --bg: #08090f;
  --panel: #0d0f18;
  --panel-deep: #090a10;
  --line: #272b3c;
  --line-bright: #3a4058;
  --green: #c5f589;
  --green-strong: #8ed84c;
  --coral: #ff8e83;
  --gold: #e6c361;
  --blue: #9abbff;
  --shadow: 0 18px 42px rgb(0 0 0 / 32%);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 10% -5%, rgb(70 80 126 / 20%), transparent 30rem),
    radial-gradient(circle at 90% 10%, rgb(46 92 93 / 12%), transparent 28rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, "Avenir Next", "Segoe UI", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto 72px; }

.text-button, .chip, .compare-button {
  border: 1px solid var(--line-bright);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); align-items: center; gap: 20px; padding: 66px 0 42px; }
.intro-copy { min-width: 0; }
.intro-image { display: block; width: 100%; height: auto; justify-self: start; border-radius: 16px; border: 1px solid var(--line); }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: 0.7rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.intro h1 { max-width: 650px; margin: 0; font-size: clamp(2.25rem, 5vw, 4.9rem); line-height: 0.98; letter-spacing: -0.055em; }
.intro-copy > p { max-width: 620px; margin: 18px 0 0; color: var(--muted); font-size: 1.04rem; line-height: 1.6; }

.control-deck {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(150deg, rgb(17 20 32 / 95%), rgb(8 9 15 / 95%));
  box-shadow: var(--shadow);
}

.filter-group { min-width: 0; padding: 25px; }
.filter-group + .filter-group { border-top: 1px solid var(--line); }
.ship-type-group { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 32px; }
.filter-heading h2 { margin: 0; font-size: 1.1rem; letter-spacing: -0.02em; }

.type-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.type-filters .chip { width: auto; min-width: 130px; gap: 18px; }
.chip { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 9px 11px; color: var(--muted); font-size: 0.82rem; text-align: left; }
.chip::after { content: ""; width: 8px; height: 8px; border: 1px solid var(--line-bright); border-radius: 50%; }
.chip.is-active { border-color: var(--green-strong); background: rgb(197 245 137 / 8%); color: var(--ink); }
.chip.is-active::after { border-color: var(--green); background: var(--green); box-shadow: 0 0 0 3px rgb(197 245 137 / 15%); }

.metric-filters { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 18px; }
.metric-filters .filter-heading { grid-column: 1 / -1; }
.filter-help { grid-column: 1 / -1; margin: -9px 0 2px; color: var(--muted); font-size: 0.79rem; line-height: 1.45; }
.stat-filter-grid {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: start;
  gap: 24px 16px;
}
.stat-filter-column { min-width: 0; margin: 0; padding: 0; border: 0; }
.stat-filter-column legend { padding: 0; margin-bottom: 12px; color: var(--gold); font-size: 0.875rem; font-weight: 700; }
.stat-filter-column-fields { display: grid; gap: 12px; }
.stat-filter-grid .field-label { min-width: 0; gap: 5px; font-size: 0.875rem; line-height: 1.3; letter-spacing: 0; text-transform: none; }
.stat-filter-grid .field-label > span:first-child { min-height: 2.6em; color: var(--muted); }
.stat-filter-grid .field-label input { min-width: 0; padding: 10px 38px 10px 8px; font-size: 0.875rem; }
.stat-filter-grid .input-wrap b { top: 11px; right: 9px; font-size: 0.8rem; }
.field-label, .check-label { display: grid; gap: 8px; color: var(--muted); font-size: 0.73rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.field-label input { width: 100%; border: 1px solid var(--line-bright); border-radius: 7px; outline: none; background: #11131d; color: var(--ink); padding: 10px; }
.field-label input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgb(197 245 137 / 10%); }
.input-wrap { position: relative; display: block; }
.input-wrap input { padding-right: 30px; }
.input-wrap b { position: absolute; top: 9px; right: 11px; color: var(--gold); font-size: 0.9rem; }
.check-label { grid-auto-flow: column; align-items: center; justify-content: start; padding-bottom: 10px; text-transform: none; letter-spacing: 0; }
.check-label input { width: 16px; height: 16px; accent-color: var(--green); }

.text-button, .compare-button { padding: 9px 12px; font-size: 0.76rem; font-weight: 800; }
.text-button:hover, .compare-button:hover { border-color: var(--green); color: var(--green); }
.text-button:focus-visible, .compare-button:focus-visible, .chip:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.results-bar { display: flex; justify-content: space-between; gap: 20px; padding: 20px 2px 18px; color: var(--muted); font-size: 0.8rem; }
.results-bar p { margin: 0; }
.results-bar p:first-child { color: var(--ink); font-weight: 700; }

.ship-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

.ship-card {
  position: relative;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgb(13 15 24 / 97%), rgb(6 7 12 / 97%));
  box-shadow: var(--shadow);
}
.ship-card::before { content: ""; position: absolute; top: 0; right: 0; left: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0.85; }
.ship-card.is-compared { border-color: var(--accent); }
.card-heading { display: flex; justify-content: space-between; gap: 12px; padding: 25px 22px 17px; border-bottom: 1px solid var(--line); }
.ship-type { margin: 0 0 5px; color: var(--blue); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.card-heading h2 { margin: 0; font-size: 1.45rem; letter-spacing: -0.04em; }
.compare-button.is-selected { border-color: var(--green); background: rgb(197 245 137 / 10%); color: var(--green); }

.metric-section { padding: 17px 22px 0; }
.metric-section:last-child { padding-bottom: 22px; }
.metric-section h3 { margin: 0 0 7px; color: var(--gold); font-size: 0.65rem; letter-spacing: 0.12em; text-transform: uppercase; }
.metric-list { margin: 0; }
.metric-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 4px 0; }
.metric-row dt { color: var(--muted); font-size: 0.79rem; }
.metric-row dd { margin: 0; font-size: 0.84rem; font-variant-numeric: tabular-nums; font-weight: 800; }
.positive { color: var(--green); }
.negative { color: var(--coral); }
.neutral { color: var(--ink); }

.no-results { grid-column: 1 / -1; padding: 48px 24px; border: 1px dashed var(--line-bright); border-radius: 14px; color: var(--muted); text-align: center; }

.comparison { margin-top: 32px; padding: 23px; border: 1px solid var(--line-bright); border-radius: 16px; background: rgb(13 15 24 / 90%); }
.comparison.is-hidden { display: none; }
.comparison-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.comparison-heading h2 { margin: 0; font-size: 1.3rem; }
.comparison-table { width: 100%; margin-top: 17px; border-collapse: collapse; font-size: 0.84rem; }
.comparison-table th, .comparison-table td { padding: 9px 0; border-bottom: 1px solid rgb(39 43 60 / 72%); text-align: right; font-variant-numeric: tabular-nums; }
.comparison-table th:first-child, .comparison-table td:first-child { width: 43%; color: var(--muted); text-align: left; }
.comparison-table th { color: var(--ink); font-weight: 800; }

@media (max-width: 1100px) {
  .stat-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 830px) {
  .intro { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .intro-image { justify-self: start; }
  .results-bar { align-items: flex-start; flex-direction: column; }
  .control-deck { grid-template-columns: 1fr; }
  .filter-group + .filter-group { border-top: 1px solid var(--line); border-left: 0; }
  .metric-filters .filter-heading { grid-column: 1 / -1; }
  .stat-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 24px, 1440px); }
  .intro { padding: 46px 0 32px; }
  .filter-group { padding: 20px; }
  .metric-filters { grid-template-columns: 1fr; }
  .comparison { padding: 17px; overflow-x: auto; }
  .comparison-table { min-width: 460px; }
}

@media (max-width: 420px) {
  .stat-filter-grid { grid-template-columns: minmax(0, 1fr); }
}
