:root {
  color-scheme: dark;
  --bg: #080d11;
  --panel: rgba(16, 25, 31, 0.86);
  --panel-strong: #121d24;
  --line: rgba(221, 194, 132, 0.17);
  --line-strong: rgba(221, 194, 132, 0.38);
  --gold: #dcc58f;
  --gold-bright: #f2dfa9;
  --jade: #6bd3b0;
  --text: #eef2ef;
  --muted: #91a0a4;
  --danger: #df9079;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(44, 91, 83, 0.24), transparent 42%),
    linear-gradient(150deg, #0b1115 0%, #080d11 52%, #0d1216 100%);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(220, 197, 143, 0.06);
  border-radius: 50%;
  pointer-events: none;
}

.ambient::before,
.ambient::after {
  position: absolute;
  inset: 13%;
  border: inherit;
  border-radius: inherit;
  content: "";
}

.ambient::after {
  inset: 29%;
}

.ambient-one {
  top: 160px;
  right: -280px;
}

.ambient-two {
  bottom: -340px;
  left: -240px;
}

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

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 13px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--gold-bright);
  background: linear-gradient(145deg, rgba(220, 197, 143, 0.13), transparent);
  font-family: Georgia, serif;
  font-size: 21px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 17px;
  letter-spacing: 0.04em;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.sync-state {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 16px rgba(107, 211, 176, 0.65);
}

.sync-state.error .sync-dot {
  background: var(--danger);
}

.hero {
  max-width: 880px;
  padding: 94px 0 68px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: clamp(38px, 6vw, 67px);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.hero-copy {
  max-width: 690px;
  margin: 24px 0 0;
  color: #aeb9ba;
  font-size: 16px;
  line-height: 1.75;
}

.search {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  max-width: 760px;
  margin-top: 38px;
  padding: 7px;
  border: 1px solid var(--line-strong);
  background: rgba(10, 17, 21, 0.88);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.26);
}

.search:focus-within {
  border-color: rgba(242, 223, 169, 0.7);
  box-shadow: 0 0 0 3px rgba(220, 197, 143, 0.08);
}

.search-icon {
  padding: 0 10px 0 12px;
  color: var(--gold);
  font-size: 26px;
  line-height: 1;
}

.search input {
  min-width: 0;
  height: 52px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 16px;
}

.search input::placeholder {
  color: #65757a;
}

.search button,
.quick-users button {
  cursor: pointer;
}

.search button {
  height: 48px;
  padding: 0 23px;
  border: 1px solid #c9af73;
  color: #15130e;
  background: linear-gradient(135deg, #f0dfa9, #bca064);
  font-size: 14px;
  font-weight: 800;
}

.search button:hover {
  filter: brightness(1.08);
}

.quick-users {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
  margin-top: 16px;
}

.quick-users::before {
  align-self: center;
  margin-right: 3px;
  color: #647278;
  content: "최근";
  font-size: 11px;
}

.quick-users button {
  padding: 7px 11px;
  border: 1px solid rgba(145, 160, 164, 0.18);
  border-radius: 999px;
  color: #aeb8ba;
  background: rgba(255, 255, 255, 0.025);
  font-size: 12px;
}

.quick-users button:hover,
.quick-users button:focus-visible {
  border-color: var(--line-strong);
  color: var(--gold-bright);
}

.content {
  min-height: 340px;
  padding: 40px 0 70px;
  border-top: 1px solid var(--line);
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  text-align: center;
}

.empty-mark {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 18px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--gold);
  font-family: Georgia, serif;
}

.empty-state h2 {
  margin: 0;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 22px;
  font-weight: 500;
}

.empty-state p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.result-head {
  display: flex;
  gap: 28px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 26px;
}

.result-head h2 {
  margin: 7px 0 0;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 500;
}

.result-kicker,
.formation-index {
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.result-meta {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.formations {
  display: grid;
  gap: 18px;
}

.formation {
  position: relative;
  overflow: hidden;
  padding: 25px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(220, 197, 143, 0.035), transparent 38%),
    var(--panel);
  box-shadow: var(--shadow);
}

.formation::after {
  position: absolute;
  top: 0;
  right: 0;
  width: 110px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
  content: "";
}

.formation-top {
  display: flex;
  gap: 18px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 19px;
}

.formation-top h3 {
  margin: 5px 0 0;
  font-size: 18px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: end;
}

.badge {
  padding: 6px 9px;
  border: 1px solid rgba(107, 211, 176, 0.22);
  border-radius: 999px;
  color: var(--jade);
  background: rgba(107, 211, 176, 0.055);
  font-size: 10px;
}

.badge.inferred {
  border-color: var(--line-strong);
  color: var(--gold-bright);
  background: rgba(220, 197, 143, 0.07);
}

.badge.partial {
  border-color: rgba(223, 144, 121, 0.26);
  color: #efaa96;
  background: rgba(223, 144, 121, 0.065);
}

.badge.tier {
  border-color: rgba(137, 165, 222, 0.28);
  color: #aebfe2;
  background: rgba(87, 116, 172, 0.09);
}

.formation-body.has-image {
  display: grid;
  grid-template-columns: minmax(300px, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
  align-items: stretch;
}

.formation-scan {
  display: grid;
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(220, 197, 143, 0.18);
  background: #05080a;
}

.formation-scan a {
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.formation-scan img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 230px;
}

.formation-scan figcaption {
  padding: 7px 10px;
  border-top: 1px solid rgba(220, 197, 143, 0.11);
  color: #728085;
  font-size: 10px;
}

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

.general {
  min-height: 126px;
  padding: 16px;
  border: 1px solid rgba(145, 160, 164, 0.12);
  background: rgba(4, 9, 12, 0.42);
}

.general.is-inferred {
  border-style: dashed;
  border-color: rgba(220, 197, 143, 0.29);
}

.general-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.general-name {
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 20px;
  font-weight: 600;
}

.promotion {
  color: var(--gold-bright);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.troop {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 23px;
  color: #b6c0c0;
  font-size: 13px;
}

.troop-icon {
  display: grid;
  width: 29px;
  height: 29px;
  place-items: center;
  border: 1px solid rgba(220, 197, 143, 0.22);
  border-radius: 50%;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 12px;
}

.inferred-note {
  margin-top: 9px;
  color: #a99568;
  font-size: 10px;
}

.counter-panel {
  margin-top: 16px;
  border: 1px solid rgba(220, 197, 143, 0.16);
  background: rgba(4, 9, 12, 0.36);
}

.counter-panel summary {
  padding: 13px 15px;
  cursor: pointer;
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 700;
  list-style: none;
}

.counter-panel summary::-webkit-details-marker {
  display: none;
}

.counter-panel summary::after {
  float: right;
  color: var(--gold);
  content: "+";
}

.counter-panel[open] summary::after {
  content: "−";
}

.counter-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  padding: 0 10px 10px;
}

.counter-card {
  position: relative;
  padding: 13px 14px;
  border: 1px solid rgba(145, 160, 164, 0.11);
  background: rgba(8, 14, 17, 0.64);
}

.counter-head {
  display: flex;
  gap: 10px;
  align-items: start;
  justify-content: space-between;
}

.counter-head strong {
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 15px;
}

.counter-labels {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: end;
}

.counter-labels .badge {
  padding: 4px 7px;
  font-size: 9px;
}

.counter-generals {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 11px;
}

.counter-generals span {
  padding: 4px 7px;
  border: 1px solid rgba(145, 160, 164, 0.12);
  color: #c9d0cf;
  background: rgba(145, 160, 164, 0.04);
  font-size: 10px;
}

.counter-reason {
  min-height: 32px;
  margin: 10px 0 7px;
  color: #98a4a5;
  font-size: 11px;
  line-height: 1.5;
}

.counter-source {
  color: var(--gold);
  font-size: 10px;
  text-decoration: none;
}

.counter-source:hover {
  color: var(--gold-bright);
  text-decoration: underline;
}

.formation-foot {
  display: flex;
  gap: 12px 24px;
  flex-wrap: wrap;
  margin-top: 16px;
  color: #728085;
  font-size: 11px;
}

.history {
  margin-top: 22px;
  border: 1px solid var(--line);
  background: rgba(7, 12, 15, 0.54);
}

.history summary {
  padding: 17px 19px;
  cursor: pointer;
  color: #adb8b9;
  font-size: 12px;
  list-style: none;
}

.history summary::-webkit-details-marker {
  display: none;
}

.history summary::after {
  float: right;
  color: var(--gold);
  content: "+";
}

.history[open] summary::after {
  content: "−";
}

.history-list {
  display: grid;
  gap: 1px;
  padding: 0 12px 12px;
}

.history-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  padding: 12px 8px;
  border-top: 1px solid rgba(145, 160, 164, 0.09);
  color: var(--muted);
  font-size: 11px;
}

.history-names {
  color: #cbd2d1;
}

footer {
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 24px 0 38px;
  border-top: 1px solid var(--line);
  color: #5f6d71;
  font-size: 10px;
}

footer p {
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 1180px);
  }

  .masthead {
    min-height: 76px;
  }

  .sync-state {
    max-width: 120px;
    justify-content: end;
    text-align: right;
  }

  .hero {
    padding: 65px 0 50px;
  }

  .hero-copy {
    font-size: 14px;
  }

  .search {
    grid-template-columns: auto 1fr;
  }

  .search button {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 4px;
  }

  .result-head,
  .formation-top,
  footer {
    align-items: start;
    flex-direction: column;
  }

  .result-meta {
    text-align: left;
  }

  .badges {
    justify-content: start;
  }

  .formation {
    padding: 18px;
  }

  .formation-body.has-image {
    grid-template-columns: 1fr;
  }

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

  .general {
    min-height: 108px;
  }

  .troop {
    margin-top: 17px;
  }

  .history-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}
