:root {
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f7f8fa;
  --ink: #111827;
  --ink-soft: #5f6b7a;
  --line: #e5e9ef;
  --accent: #155eef;
  --accent-deep: #0b4bd4;
  --accent-soft: #edf4ff;
  --danger: #c4320a;
  --danger-soft: #fff2ed;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 50% -20%, rgba(21, 94, 239, 0.10), transparent 38rem),
    var(--canvas);
}

button,
input {
  font: inherit;
}

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

.shell {
  width: min(100% - 40px, 1040px);
  margin: 0 auto;
  padding: 72px 0 max(80px, env(safe-area-inset-bottom));
}

.hero {
  margin-bottom: 32px;
  text-align: center;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 1.05;
}

.hero-copy {
  margin-bottom: 0;
  color: var(--ink-soft);
  font-size: 16px;
  letter-spacing: -0.02em;
}

.search-panel,
.result-card {
  border: 1px solid rgba(229, 233, 239, 0.9);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.search-panel {
  padding: 28px;
  border-radius: var(--radius-lg);
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
}

.search-form input {
  width: 100%;
  height: 56px;
  min-width: 0;
  padding: 0 18px;
  border: 1px solid #d8dee8;
  border-radius: 14px;
  outline: none;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.025em;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.search-form input::placeholder {
  color: #929baa;
  font-weight: 500;
}

.search-form input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(21, 94, 239, 0.12);
}

.search-form button {
  height: 56px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease, opacity 150ms ease;
}

.search-form button:hover {
  background: var(--accent-deep);
}

.search-form button:active {
  transform: translateY(1px);
}

.search-form button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.field-message {
  min-height: 20px;
  margin: 10px 2px 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

.field-message:empty {
  display: none;
}

.field-message.is-error {
  color: var(--danger);
}

.popular {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.popular-heading,
.results-heading,
.result-title-row,
.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.popular-heading {
  margin-bottom: 13px;
}

.popular-heading h2,
.results-heading h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.popular-heading span,
.results-heading > span {
  color: var(--ink-soft);
  font-size: 12px;
}

.popular-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 34px;
}

.popular-chip {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #dce5f5;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #174ea6;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.popular-chip:hover,
.popular-chip:focus-visible {
  border-color: #94b8ff;
  background: #e3eeff;
  outline: none;
}

.popular-chip b {
  margin-right: 6px;
  color: var(--accent);
  font-size: 11px;
}

.popular-placeholder {
  align-self: center;
  color: #8a94a3;
  font-size: 13px;
}

.results {
  margin-top: 38px;
}

.results-heading {
  margin: 0 4px 14px;
}

#result-list {
  display: grid;
  gap: 16px;
}

.empty-state {
  padding: 52px 24px;
  border: 1px dashed #cfd6e1;
  border-radius: var(--radius-lg);
  color: var(--ink-soft);
  text-align: center;
}

.empty-state p {
  margin-bottom: 6px;
  color: #3d4858;
  font-weight: 700;
}

.empty-state span {
  font-size: 13px;
}

.result-card {
  overflow: hidden;
  border-radius: var(--radius-lg);
  animation: result-in 220ms ease-out both;
}

.result-head {
  padding: 22px 24px 18px;
}

.result-title-row h3 {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.045em;
}

.result-status {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #067647;
  font-size: 11px;
  font-weight: 800;
}

.result-status.is-muted {
  background: #f0f2f5;
  color: #667085;
}

.result-status.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.result-meta {
  justify-content: flex-start;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 12px;
}

.formation-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-top: 1px solid var(--line);
  table-layout: fixed;
}

.formation-table th,
.formation-table td {
  vertical-align: middle;
}

.formation-group + .formation-group th,
.formation-group + .formation-group td {
  border-top: 1px solid var(--line);
}

.deck-cell {
  width: 22%;
  padding: 18px 14px;
  background: #fbfcfd;
  color: #263244;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
}

.deck-name {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.general-cell {
  width: 26%;
  padding: 15px 8px;
  overflow-wrap: anywhere;
  color: #172033;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.general-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  line-height: 1.35;
}

.promotion {
  color: var(--accent);
  white-space: nowrap;
}

.promotion.is-max {
  color: #c2410c;
  font-weight: 900;
}

.troop-type {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: #475467;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.35;
}

.counter-cell {
  padding: 8px 14px 10px;
  background: #fbfcfd;
  color: #667085;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

.counter-label {
  margin-right: 7px;
  color: #98a2b3;
  font-size: 10px;
  font-weight: 800;
}

.counter-list {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}

.counter-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border: 1px solid #e4e7ec;
  border-radius: 999px;
  background: #fff;
  font-weight: 700;
}

.matchup-result {
  font-size: 9px;
  font-weight: 900;
}

.matchup-result.is-great,
.matchup-result.is-good {
  color: #067647;
}

.matchup-result.is-even {
  color: #667085;
}

.matchup-result.is-bad {
  color: #b54708;
}

.matchup-result.is-worst {
  color: #b42318;
}

.result-message {
  padding: 34px 24px 38px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.6;
}

.result-message strong {
  display: block;
  margin-bottom: 3px;
  color: #344054;
}

.result-card.is-loading .result-head {
  opacity: 0.68;
}

.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;
}

@keyframes result-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 24px, 1040px);
    padding-top: 38px;
  }

  .hero {
    margin-bottom: 24px;
  }

  h1 {
    margin-bottom: 10px;
    font-size: 38px;
  }

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

  .search-panel {
    padding: 18px;
    border-radius: 20px;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: 8px;
  }

  .search-form input,
  .search-form button {
    height: 52px;
    border-radius: 12px;
  }

  .search-form input {
    padding: 0 14px;
    font-size: 16px;
  }

  .popular {
    margin-top: 18px;
    padding-top: 18px;
  }

  .results {
    margin-top: 30px;
  }

  .result-card {
    border-radius: 20px;
  }

  .result-head {
    padding: 19px 18px 16px;
  }

  .result-title-row h3 {
    font-size: 21px;
  }

  .formation-table .deck-cell {
    padding: 14px 14px 9px;
  }

  .general-cell {
    padding: 11px 5px 3px;
    font-size: 14px;
  }

  .troop-cell {
    padding: 3px 5px 15px;
    font-size: 12px;
  }
}

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