:root {
  --paper: #f1eee7;
  --ink: #151515;
  --muted: #6f6c65;
  --line: rgba(21, 21, 21, 0.18);
  --soft-line: rgba(21, 21, 21, 0.09);
  --card: #f7f4ee;
  --signal: #d73b24;
  --rail: 76px;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --sans: "Avenir Next Condensed", "DIN Condensed", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  letter-spacing: 0.01em;
}
body.is-dark {
  --paper: #171715;
  --ink: #eeebe3;
  --muted: #aaa69d;
  --line: rgba(238, 235, 227, 0.22);
  --soft-line: rgba(238, 235, 227, 0.09);
  --card: #201f1c;
  --signal: #ff6047;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.paper-noise {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  opacity: .12;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
.is-dark .paper-noise { mix-blend-mode: screen; opacity: .06; }

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail);
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  z-index: 10;
}
.rail-mark {
  height: var(--rail);
  display: grid;
  place-content: center;
  text-align: center;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  line-height: .8;
}
.rail-mark span { font-size: 10px; letter-spacing: .18em; }
.rail-mark b { font-family: var(--serif); font-size: 25px; }
.rail nav { display: flex; flex-direction: column; }
.rail nav a {
  min-height: 94px;
  padding: 15px 0;
  display: grid;
  place-items: center;
  text-align: center;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  font-size: 10px;
  line-height: 1.5;
  writing-mode: vertical-rl;
  transition: background .2s, color .2s;
}
.rail nav a:hover, .rail nav a.is-active { background: var(--ink); color: var(--paper); }
.theme-toggle {
  margin-top: auto;
  height: var(--rail);
  border: 0;
  border-top: 1px solid var(--line);
  color: inherit;
  background: none;
  cursor: pointer;
  font-size: 22px;
}

main { margin-left: var(--rail); overflow: clip; }
.hero { padding: 28px clamp(24px, 5vw, 78px) 34px; min-height: 670px; border-bottom: 1px solid var(--line); position: relative; }
.hero::before {
  content: "";
  position: absolute;
  width: min(46vw, 680px);
  aspect-ratio: 1;
  border: 1px solid var(--soft-line);
  border-radius: 50%;
  right: -12vw;
  top: -18vw;
  box-shadow: 0 0 0 55px var(--soft-line), 0 0 0 110px transparent, 0 0 0 111px var(--soft-line);
}
.hero-kicker, .section-label, .card-meta, footer { display: flex; justify-content: space-between; align-items: center; font-size: 10px; letter-spacing: .18em; text-transform: uppercase; }
.hero-grid { display: grid; grid-template-columns: minmax(340px, 1.1fr) minmax(300px, .9fr); gap: 7vw; align-items: end; min-height: 530px; position: relative; z-index: 1; }
.eyebrow { color: var(--signal); font-size: 11px; font-weight: 700; letter-spacing: .16em; }
.hero h1 { margin: 14px 0 25px; font-family: var(--serif); font-weight: 500; font-size: clamp(92px, 11vw, 176px); line-height: .76; letter-spacing: -.08em; }
.hero h1 em { color: transparent; -webkit-text-stroke: 1.5px var(--ink); font-style: normal; margin-left: .28em; }
.hero-deck { max-width: 540px; color: var(--muted); font-family: var(--serif); font-size: clamp(15px, 1.45vw, 21px); line-height: 1.8; }
.hero-count { padding: 26px; border: 1px solid var(--ink); background: color-mix(in srgb, var(--paper) 76%, transparent); position: relative; transform: rotate(1deg); }
.hero-count::after { content: "ACTIVE ROSTER"; position: absolute; right: 18px; top: 14px; color: var(--signal); font-size: 9px; letter-spacing: .2em; }
.count-total { display: block; font-family: var(--serif); font-size: clamp(116px, 15vw, 240px); line-height: .78; letter-spacing: -.1em; }
.count-meta { display: flex; justify-content: space-between; margin: 28px 0 12px; font-size: 12px; }
.count-meta b { color: var(--signal); }
.progress-track { height: 8px; background: var(--soft-line); overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0; background: var(--signal); transition: width .8s cubic-bezier(.16,1,.3,1); }
.march-line { position: relative; z-index: 1; display: flex; align-items: center; gap: 16px; font-size: 9px; letter-spacing: .12em; }
.march-line i { height: 1px; flex: 1; background: repeating-linear-gradient(90deg, var(--ink), var(--ink) 4px, transparent 4px, transparent 11px); opacity: .45; }

.controls { padding: 42px clamp(20px, 4vw, 62px) 24px; position: sticky; top: 0; z-index: 8; background: color-mix(in srgb, var(--paper) 93%, transparent); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.section-label { margin-bottom: 18px; }
.section-label strong { font-size: 12px; color: var(--signal); }
.control-row { display: grid; grid-template-columns: minmax(260px, 1fr) auto auto; gap: 10px; }
.search-box { position: relative; }
.search-box input, .select-wrap select {
  width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 0; background: var(--card); color: var(--ink); padding: 0 45px 0 14px; outline: none;
}
.search-box input:focus, .select-wrap select:focus { border-color: var(--ink); box-shadow: inset 0 -2px var(--signal); }
.search-box kbd { position: absolute; right: 12px; top: 10px; width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--muted); }
.segmented { display: flex; }
.segmented button, .category-strip button {
  border: 1px solid var(--line); margin-left: -1px; background: var(--card); color: var(--ink); padding: 0 14px; cursor: pointer; white-space: nowrap;
}
.segmented button:first-child { margin-left: 0; }
.segmented button.is-active, .category-strip button.is-active { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.segmented span { color: var(--signal); }
.category-strip { display: flex; gap: 6px; margin-top: 12px; overflow: auto; scrollbar-width: none; }
.category-strip::-webkit-scrollbar { display: none; }
.category-strip button { margin: 0; padding: 8px 12px; font-size: 11px; }

.roster-grid { padding: 30px clamp(20px, 4vw, 62px) 80px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.soldier-card { min-width: 0; }
.card-open { width: 100%; padding: 0; border: 1px solid var(--line); color: inherit; background: var(--card); text-align: left; cursor: pointer; transition: transform .25s ease, box-shadow .25s ease; }
.card-open:hover { transform: translateY(-6px) rotate(-.35deg); box-shadow: 9px 11px 0 var(--ink); }
.card-visual { aspect-ratio: 9 / 14; position: relative; overflow: hidden; border-bottom: 1px solid var(--line); background: #dfdcd4; }
.card-visual img { width: 100%; height: 100%; display: none; object-fit: contain; object-position: center; filter: saturate(.9) contrast(1.02); transition: transform .45s cubic-bezier(.16,1,.3,1), filter .35s; }
.is-ready .card-visual img { display: block; }
.is-ready .placeholder { display: none; }
.card-open:hover img { transform: scale(1.025); filter: saturate(1.06) contrast(1.02); }
.placeholder { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: repeating-linear-gradient(135deg, transparent 0 16px, var(--soft-line) 16px 17px); }
.placeholder::before, .placeholder::after { content: ""; position: absolute; background: var(--line); }
.placeholder::before { width: 1px; top: 8%; bottom: 8%; left: 50%; }
.placeholder::after { height: 1px; left: 8%; right: 8%; top: 50%; }
.placeholder strong { font-family: var(--serif); font-size: clamp(62px, 7vw, 104px); line-height: .9; color: var(--card); -webkit-text-stroke: 1px var(--ink); z-index: 1; }
.placeholder small { margin-top: 14px; font-size: 8px; letter-spacing: .24em; line-height: 1.5; background: var(--card); padding: 5px; z-index: 1; }
.status-stamp { position: absolute; z-index: 2; right: 9px; top: 9px; border: 1px solid currentColor; padding: 5px 7px; color: var(--muted); background: var(--card); font-size: 8px; letter-spacing: .14em; }
.is-ready .status-stamp { color: var(--signal); transform: rotate(3deg); }
.card-body { padding: 16px 16px 14px; }
.card-meta { color: var(--muted); }
.card-id { color: var(--signal); font-weight: 700; }
.card-title { min-height: 2.5em; margin: 15px 0 8px; font-family: var(--serif); font-size: clamp(20px, 1.7vw, 27px); font-weight: 600; line-height: 1.25; }
.card-description { min-height: 4.5em; margin: 0; color: var(--muted); font-family: var(--serif); font-size: 13px; line-height: 1.55; }
.card-footer { margin-top: 16px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; gap: 10px; align-items: center; }
.card-traits { flex: 1; color: var(--muted); font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-footer i { font-style: normal; }
.empty-state { margin: 50px; text-align: center; font-family: var(--serif); font-size: 24px; }

.about { border-top: 1px solid var(--line); padding: 90px clamp(24px, 7vw, 110px); display: grid; grid-template-columns: .7fr 1.3fr; gap: 8vw; align-items: center; }
.about-number { font-family: var(--serif); font-size: clamp(170px, 24vw, 380px); line-height: .6; color: var(--signal); letter-spacing: -.13em; transform: translateX(-.08em); }
.about h2 { margin: 12px 0 26px; font-family: var(--serif); font-size: clamp(34px, 4.4vw, 68px); font-weight: 500; line-height: 1.1; }
.about p:not(.eyebrow) { max-width: 700px; color: var(--muted); font-family: var(--serif); line-height: 1.8; }
.about-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 26px; }
.about-tags span { border: 1px solid var(--line); padding: 8px 10px; font-size: 9px; letter-spacing: .12em; }
footer { padding: 25px clamp(24px, 4vw, 62px); border-top: 1px solid var(--line); }
footer a { text-underline-offset: 4px; }

.panel-dialog { width: min(1000px, calc(100vw - 40px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); overflow: auto; }
.panel-dialog::backdrop { background: rgba(10,10,8,.72); backdrop-filter: blur(5px); }
.dialog-close { position: sticky; float: right; right: 12px; top: 12px; width: 42px; height: 42px; z-index: 3; border: 1px solid var(--ink); border-radius: 50%; background: var(--paper); color: var(--ink); cursor: pointer; font-size: 28px; line-height: 1; }
.dialog-layout { display: grid; grid-template-columns: 46% 54%; min-height: 620px; }
.dialog-visual { min-height: 620px; background: var(--card); border-right: 1px solid var(--line); display: grid; place-items: center; overflow: hidden; position: relative; }
.dialog-visual img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.dialog-placeholder { font-family: var(--serif); font-size: 150px; color: transparent; -webkit-text-stroke: 1px var(--ink); }
.dialog-info { padding: 70px 42px 40px; }
.dialog-overline { color: var(--signal); font-size: 11px; letter-spacing: .18em; }
.dialog-info h2 { margin: 17px 0; font-family: var(--serif); font-size: clamp(38px, 5vw, 66px); line-height: 1; font-weight: 500; }
.dialog-info > p { font-family: var(--serif); color: var(--muted); line-height: 1.7; }
.trait-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 28px 0; }
.trait-list span { border: 1px solid var(--line); padding: 7px 9px; font-size: 10px; }
.dialog-actions { display: grid; gap: 8px; margin-top: 32px; }
.dialog-actions a { display: flex; justify-content: space-between; padding: 13px 14px; border: 1px solid var(--line); text-decoration: none; font-size: 12px; transition: background .2s, color .2s; }
.dialog-actions a:hover { background: var(--ink); color: var(--paper); }
.dialog-actions .disabled { display: flex; justify-content: space-between; padding: 13px 14px; border: 1px dashed var(--line); color: var(--muted); font-size: 12px; }
.dialog-status { margin-top: 32px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .14em; }
.dialog-status b { color: var(--signal); }

.reveal { opacity: 0; transform: translateY(18px); animation: reveal .8s cubic-bezier(.16,1,.3,1) forwards; }
.delay-1 { animation-delay: .08s; }
.delay-2 { animation-delay: .18s; }
.reveal-card { animation: card-in .5s both; animation-delay: min(calc(var(--i) * 28ms), 400ms); }
@keyframes reveal { to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: translateY(16px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }

@media (max-width: 1180px) {
  .roster-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .control-row { grid-template-columns: 1fr auto; }
  .select-wrap { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  :root { --rail: 0px; }
  .rail { inset: auto 0 0 0; width: auto; height: 62px; flex-direction: row; border: 0; border-top: 1px solid var(--line); }
  .rail-mark { width: 62px; height: 62px; border: 0; border-right: 1px solid var(--line); }
  .rail nav { flex: 1; flex-direction: row-reverse; }
  .rail nav a { min-height: 62px; flex: 1; padding: 8px; border: 0; border-left: 1px solid var(--line); writing-mode: initial; }
  .theme-toggle { width: 62px; height: 62px; margin: 0; border: 0; border-left: 1px solid var(--line); }
  main { margin: 0 0 62px; }
  .hero { min-height: auto; padding-top: 22px; }
  .hero-grid { min-height: auto; grid-template-columns: 1fr; gap: 42px; padding: 54px 0 46px; }
  .hero h1 { font-size: clamp(78px, 25vw, 150px); }
  .hero-count { width: min(100%, 460px); justify-self: end; }
  .controls { position: relative; }
  .control-row { grid-template-columns: 1fr; }
  .segmented { overflow-x: auto; }
  .segmented button { min-height: 43px; flex: 1; }
  .select-wrap { grid-column: auto; }
  .roster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about { grid-template-columns: 1fr; }
  .about-number { font-size: 45vw; }
  .dialog-layout { grid-template-columns: 1fr; }
  .dialog-visual { min-height: 420px; border: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .hero { padding-inline: 16px; }
  .hero-kicker { font-size: 8px; }
  .hero h1 { letter-spacing: -.07em; }
  .hero h1 em { margin-left: .12em; }
  .controls { padding: 30px 12px 18px; }
  .roster-grid { grid-template-columns: 1fr; gap: 16px; padding: 18px 12px 60px; }
  .card-visual { aspect-ratio: 9 / 14; }
  .card-title, .card-description { min-height: 0; }
  .about { padding: 70px 18px; }
  footer { gap: 14px; align-items: flex-start; flex-direction: column; }
  .panel-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .dialog-info { padding: 52px 22px 30px; }
}
