:root {
  color-scheme: dark;
  --bg: #080a0d;
  --surface: #0e1116;
  --line: #2d333d;
  --line-soft: #20252d;
  --ink: #f1eee5;
  --muted: #c0c2c2;
  --faint: #a4a7a8;
  --amber: #e7b65a;
  --cyan: #5dc6d8;
  --accent: var(--amber);
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-size-adjust: 100%;
}

:root[data-civ="scots"] { --accent: var(--cyan); }
:root[data-civ="vikings"] { --accent: var(--amber); }

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }
body { min-width: 280px; min-height: 100vh; min-height: 100svh; margin: 0; background: var(--bg); color: var(--ink); }
a { color: inherit; }

.skip-link {
  position: fixed;
  z-index: 1;
  top: 8px;
  left: 8px;
  padding: 10px 12px;
  transform: translateY(-160%);
  border: 1px solid var(--cyan);
  background: var(--surface);
  color: var(--ink);
}
.skip-link:focus { transform: translateY(0); }

.site-shell { width: min(760px, 100%); min-height: 100vh; min-height: 100svh; margin-inline: auto; padding: 0 18px 12px; }
.site-header { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line-soft); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-decoration: none; }
.brand__mark { display: inline-grid; width: 24px; height: 24px; place-items: center; border: 1px solid var(--amber); color: var(--amber); font-size: 10px; letter-spacing: 0; }
.brand__sub { margin-left: 6px; color: var(--faint); font-size: 9px; letter-spacing: .09em; }
.header-note { color: var(--faint); font-size: 9px; letter-spacing: .08em; }

.home-main { padding: 14px 0 8px; }
.home-intro { margin: 0 0 12px; }
h1, h2, p { margin-top: 0; }
.home-intro h1 { margin-bottom: 3px; font-size: 27px; font-weight: 760; letter-spacing: -.025em; line-height: 1.08; }
.home-intro p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.35; }
.build-groups { display: grid; grid-template-columns: 1fr; gap: 13px; }
.build-group { min-width: 0; }
.build-group[data-civ="scots"] { --accent: var(--cyan); }
.group-heading { display: flex; align-items: center; gap: 8px; margin: 0 0 5px; color: var(--accent); font-size: 13px; font-weight: 750; line-height: 1.2; }
.group-heading::after { height: 1px; flex: 1; background: var(--line); content: ""; }
.build-list { margin: 0; padding: 0; list-style: none; }
.build-list li + li { border-top: 1px solid var(--line-soft); }
.build-link { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 5px 9px; border: 1px solid transparent; color: var(--ink); text-decoration: none; }
.build-link:hover { background: var(--surface); }
.build-link:focus-visible, .back-link:focus-visible, .source-link:focus-visible, .page-nav a:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
.build-link__copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.build-link strong { overflow: hidden; font-size: 18px; font-weight: 680; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.build-link small { color: var(--muted); font-size: 14px; line-height: 1.15; }
.build-link__arrow { color: var(--accent); font-size: 18px; line-height: 1; }
.home-footnote { margin: 11px 0 0; color: var(--muted); font-size: 11px; line-height: 1.35; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line-soft); color: var(--faint); font-size: 10px; }
.site-footer i { padding-inline: 4px; color: var(--line); font-style: normal; }

.detail-main { padding: 5px 0 10px; }
.back-link { min-height: 36px; display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; text-decoration: none; }
.back-link:hover, .source-link:hover { color: var(--ink); }
.back-link span { color: var(--accent); font-size: 16px; }
.build-heading { margin: 4px 0 10px; }
.build-heading__civ { margin: 0 0 2px; color: var(--accent); font-size: 10px; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
.build-heading h1 { margin: 0; font-size: 28px; font-weight: 760; letter-spacing: -.025em; line-height: 1.1; }
.build-heading__landmark { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.25; }
.build-page-label { margin: 6px 0; color: var(--accent); font-size: 15px; font-weight: 720; line-height: 1.2; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
.steps-list { margin: 0; padding: 0; list-style: none; }
.step { display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 10px; align-items: start; padding: 6px 0; border-top: 1px solid var(--line-soft); }
.step:last-child { border-bottom: 1px solid var(--line-soft); }
.step__number { padding-top: 2px; color: var(--accent); font-size: 17px; font-weight: 760; font-variant-numeric: tabular-nums; text-align: right; }
.step__content { min-width: 0; }
.step__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; margin-bottom: 3px; }
.step__allocation { color: var(--ink); font-size: 16px; font-weight: 650; line-height: 1.25; }
.step__status { display: inline-flex; align-items: center; padding: 1px 5px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 650; line-height: 1.25; }
.step__copy { color: var(--ink); font-size: 20px; line-height: 1.25; }
.step__note { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; line-height: 1.3; }
.page-note, .status-legend { margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.3; }
.page-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: center; gap: 8px; margin-top: 7px; }
.page-nav a { min-height: 36px; display: inline-flex; align-items: center; color: var(--accent); font-size: 14px; font-weight: 680; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.page-nav a:hover { color: var(--ink); }
.page-nav__previous { justify-self: start; }
.page-nav__next { justify-self: end; }
.build-reminder { margin-top: 9px; color: var(--muted); font-size: 14px; line-height: 1.3; }
.build-reminder::before { content: "Reminder: "; color: var(--ink); font-weight: 680; }
.source-link { display: inline-flex; min-height: 34px; align-items: center; margin-top: 3px; color: var(--accent); font-size: 14px; font-weight: 650; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.missing-build { max-width: 36ch; padding-top: 25px; }
.missing-build h1 { margin: 0 0 6px; font-size: 25px; }
.missing-build p { margin: 0; color: var(--muted); line-height: 1.5; }

@media (min-width: 620px) {
  .site-shell { padding-inline: 24px; }
  .site-header { min-height: 54px; }
  .home-main { padding-top: 24px; }
  .home-intro { margin-bottom: 18px; }
  .home-intro h1 { font-size: 31px; }
  .build-groups { grid-template-columns: 1fr 1fr; gap: 22px; }
  .home-footnote { margin-top: 16px; }
  .detail-main { padding-top: 14px; }
  .build-heading { margin-top: 6px; margin-bottom: 14px; }
  .build-heading h1 { font-size: 28px; }
}

@media (max-width: 380px) {
  .site-shell { padding-inline: 14px; }
  .site-header { min-height: 44px; }
  .home-main { padding-top: 11px; }
  .home-intro { margin-bottom: 9px; }
  .home-intro h1 { font-size: 25px; }
  .build-groups { gap: 9px; }
  .group-heading { margin-bottom: 3px; }
  .build-link { min-height: 44px; padding-block: 4px; }
  .home-footnote { margin-top: 8px; font-size: 10px; }
  .site-footer { padding-top: 6px; }
  .detail-main { padding-top: 6px; }
  .build-heading { margin-top: 2px; margin-bottom: 7px; }
  .step__copy { font-size: 18px; }
  .step__note { font-size: 14px; }
  .step__meta { gap: 3px 7px; }
  .build-reminder { margin-top: 7px; }
}

@media (max-height: 590px) and (max-width: 619px) {
  .site-shell { padding-bottom: 8px; }
  .site-header { min-height: 40px; }
  .home-main { padding-top: 8px; }
  .home-intro { margin-bottom: 7px; }
  .build-groups { gap: 6px; }
  .home-footnote { margin-top: 6px; }
  .site-footer { padding-top: 5px; }
  .detail-main { padding-top: 3px; }
  .build-heading { margin-bottom: 5px; }
  .build-reminder { margin-top: 5px; }
  .source-link { min-height: 24px; }
}

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

@media (min-width: 700px) and (max-height: 560px) {
  .detail-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 14px; padding-top: 6px; }
  .detail-main > .back-link { grid-column: 2; grid-row: 1; align-self: center; }
  .build-heading { grid-column: 1; grid-row: 1; margin: 0 0 8px; }
  .build-page-label, .steps-list, .page-note, .status-legend, .page-nav { grid-column: 1 / -1; }
  .steps-list { display: grid; grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; column-gap: 16px; }
  .step:nth-child(4), .step:last-child { border-bottom: 1px solid var(--line-soft); }
  .build-reminder { grid-column: 1; align-self: center; }
  .source-link { grid-column: 2; align-self: center; margin-top: 9px; }
}

@media (min-width: 620px) and (max-height: 560px) {
  .home-main { padding-top: 16px; }
  .home-intro { margin-bottom: 14px; }
  .build-groups { gap: 16px; }
  .home-footnote { margin-top: 10px; }
}
