:root {
  color-scheme: dark;
  --bg: #080a12;
  --surface: rgba(20, 23, 38, 0.92);
  --surface-strong: #171a2a;
  --surface-soft: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f4f8;
  --muted: #9ca1b3;
  --violet: #9c72ff;
  --violet-strong: #7650df;
  --gold: #e8bd69;
  --teal: #62d6bf;
  --danger: #ff8798;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 45% -10%, rgba(117, 74, 215, 0.13), transparent 38%),
    linear-gradient(180deg, #0b0d17 0%, var(--bg) 68%);
  color: var(--text);
  font-family: "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

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

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(156, 114, 255, 0.45);
  outline-offset: 3px;
}

.ambient {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(100px);
  pointer-events: none;
}

.ambient-one {
  width: 360px;
  height: 360px;
  top: 18%;
  left: -180px;
  background: rgba(109, 74, 215, 0.11);
}

.ambient-two {
  width: 330px;
  height: 330px;
  right: -170px;
  bottom: 5%;
  background: rgba(45, 142, 167, 0.08);
}

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

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

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

.brand-block strong {
  display: block;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.eyebrow,
.result-label {
  display: block;
  margin: 0 0 4px;
  color: var(--violet);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.sigil {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(156, 114, 255, 0.52);
  border-radius: 17px;
  background: linear-gradient(145deg, rgba(156, 114, 255, 0.21), rgba(156, 114, 255, 0.04));
  color: #c4a9ff;
  font-size: 1.4rem;
  font-weight: 800;
  box-shadow: inset 0 0 22px rgba(156, 114, 255, 0.1);
}

.sigil.small {
  width: 39px;
  height: 39px;
  border-radius: 12px;
  font-size: 1rem;
}

main {
  padding-top: 42px;
}

.search-section {
  position: relative;
  padding: 30px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(156, 114, 255, 0.075), transparent 46%),
    var(--surface);
  box-shadow: var(--shadow);
}

.search-section::after {
  content: "";
  position: absolute;
  top: 0;
  left: 9%;
  width: 42%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(198, 173, 255, 0.82), transparent);
}

.section-heading,
.collection-heading,
.subsection-heading,
.expedition-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
}

.section-heading h1,
.collection-heading h2,
.subsection-heading h3,
.expedition-header h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

.section-heading h1 {
  font-size: clamp(1.55rem, 3vw, 2.2rem);
}

.section-heading > p {
  max-width: 480px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}

.search-bar {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 26px;
  padding: 8px 9px 8px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 15px;
  background: rgba(7, 9, 17, 0.78);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-bar:focus-within {
  border-color: rgba(156, 114, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(156, 114, 255, 0.09);
}

.search-bar svg {
  width: 21px;
  fill: none;
  stroke: #747a90;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.search-bar input {
  width: 100%;
  min-width: 0;
  padding: 11px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1rem;
}

.search-bar input::placeholder {
  color: #656b7e;
}

.primary-button,
.ghost-button,
.delete-button {
  min-height: 44px;
  border-radius: 11px;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.primary-button {
  padding: 11px 22px;
  border: 0;
  background: linear-gradient(135deg, var(--violet), var(--violet-strong));
  color: white;
  font-weight: 800;
  box-shadow: 0 9px 24px rgba(128, 85, 239, 0.25);
}

.primary-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.primary-button.full {
  width: 100%;
}

.ghost-button,
.delete-button {
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: #b4b8c7;
}

.ghost-button:hover {
  border-color: var(--line-strong);
  color: white;
}

.delete-button {
  min-width: 66px;
  color: #9da2b3;
}

.delete-button:hover {
  border-color: rgba(255, 135, 152, 0.35);
  background: rgba(255, 135, 152, 0.08);
  color: var(--danger);
}

.search-feedback {
  min-height: 29px;
  padding: 9px 3px 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.search-feedback.error,
.form-error {
  color: #ff9baa;
}

.search-result {
  margin-top: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(7, 9, 17, 0.56);
}

.searched-character {
  display: grid;
  grid-template-columns: 98px minmax(180px, 1fr) minmax(420px, 1.25fr) auto;
  align-items: center;
  gap: 20px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.character-portrait {
  width: 98px;
  height: 98px;
  object-fit: cover;
  object-position: top;
  border-radius: 17px;
  background: #202438;
}

.portrait-placeholder {
  display: grid;
  place-items: center;
  color: var(--violet);
  font-weight: 800;
}

.searched-info h2 {
  margin: 1px 0 8px;
  font-size: 1.42rem;
  letter-spacing: -0.035em;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.result-meta span {
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  color: #b1b5c4;
  font-size: 0.75rem;
}

.searched-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--line);
}

.searched-metrics > div {
  min-width: 0;
  padding: 12px 13px;
  background: #111421;
}

.searched-metrics span,
.character-stats dt {
  display: block;
  color: #858b9f;
  font-size: 0.72rem;
}

.searched-metrics strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: white;
  font-size: 0.91rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-expedition-button {
  min-width: 112px;
}

.top-characters-panel {
  padding: 21px 22px 23px;
}

.subsection-heading {
  align-items: center;
  margin-bottom: 15px;
}

.subsection-heading h3 {
  font-size: 1rem;
}

.subsection-heading > span,
.updated-at {
  color: #777d91;
  font-size: 0.75rem;
}

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

.character-card {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.character-card:hover {
  transform: translateY(-2px);
  border-color: rgba(156, 114, 255, 0.28);
  background: rgba(156, 114, 255, 0.055);
}

.card-portrait {
  width: 68px;
  height: 100%;
  min-height: 106px;
  object-fit: cover;
  object-position: top;
  background: #202438;
}

.rank-badge {
  position: absolute;
  z-index: 1;
  top: 7px;
  left: 7px;
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 7px;
  background: rgba(8, 10, 18, 0.85);
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

.character-card-body {
  min-width: 0;
  padding: 11px;
}

.character-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.character-card-title strong {
  overflow: hidden;
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.support-badge {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(98, 214, 191, 0.09);
  color: var(--teal);
  font-size: 0.62rem;
  font-weight: 800;
}

.class-name {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  color: #8d92a4;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-stats {
  display: grid;
  gap: 5px;
  margin: 8px 0 0;
}

.character-stats div {
  min-width: 0;
}

.character-stats dd {
  margin: 0;
  overflow: hidden;
  color: #dadce5;
  font-size: 0.76rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-stats div:first-child dd {
  color: var(--gold);
}

.expeditions-section {
  padding-top: 42px;
}

.collection-heading {
  align-items: center;
  margin-bottom: 16px;
  padding: 0 3px;
}

.collection-heading h2 {
  font-size: clamp(1.35rem, 2.6vw, 1.8rem);
}

.count-badge {
  min-width: 48px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #b9bdca;
  font-size: 0.78rem;
  text-align: center;
}

.expedition-list {
  display: grid;
  gap: 18px;
}

.expedition-block {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 15px 44px rgba(0, 0, 0, 0.22);
}

.expedition-header {
  align-items: center;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(156, 114, 255, 0.055), transparent 42%);
}

.expedition-header h3 {
  font-size: 1.1rem;
}

.saved-grid {
  padding: 18px;
}

.empty-state {
  min-height: 250px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 7px;
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: #cfd1da;
  font-size: 0.96rem;
}

.empty-state span {
  font-size: 0.82rem;
}

.empty-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 5px;
  border: 1px solid rgba(156, 114, 255, 0.35);
  border-radius: 14px;
  background: rgba(156, 114, 255, 0.06);
  color: var(--violet);
  font-size: 1.45rem;
}

.login-overlay {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 5, 10, 0.88);
  backdrop-filter: blur(14px);
}

.login-card {
  width: min(390px, 100%);
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: #111425;
  box-shadow: var(--shadow);
}

.login-card .sigil {
  margin-bottom: 22px;
}

.login-card h1 {
  margin: 5px 0;
  font-size: 1.55rem;
}

.login-card > p:not(.eyebrow):not(.form-error) {
  margin: 0 0 24px;
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #b5b9c7;
  font-size: 0.875rem;
}

.login-card input {
  width: 100%;
  margin-bottom: 13px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: #0d1020;
  color: var(--text);
}

.form-error {
  min-height: 21px;
  margin: 10px 0 0;
  font-size: 0.8rem;
}

.toast {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: 26px;
  max-width: calc(100% - 32px);
  padding: 11px 16px;
  transform: translate(-50%, 20px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #20243a;
  box-shadow: var(--shadow);
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.hidden {
  display: none !important;
}

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

@media (max-width: 1020px) {
  .searched-character {
    grid-template-columns: 86px minmax(0, 1fr) minmax(360px, 1.2fr);
  }

  .character-portrait {
    width: 86px;
    height: 86px;
  }

  .add-expedition-button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 780px) {
  .app-shell {
    width: min(100% - 28px, 680px);
    padding-bottom: 48px;
  }

  .topbar {
    min-height: 72px;
  }

  main {
    padding-top: 24px;
  }

  .search-section {
    padding: 22px 18px;
    border-radius: 19px;
  }

  .section-heading {
    display: block;
  }

  .section-heading > p {
    margin-top: 8px;
    text-align: left;
  }

  .searched-character {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 14px;
    padding: 18px;
  }

  .character-portrait {
    width: 76px;
    height: 76px;
    border-radius: 14px;
  }

  .searched-metrics {
    grid-column: 1 / -1;
  }

  .character-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-characters-panel,
  .saved-grid {
    padding: 17px;
  }

  .expeditions-section {
    padding-top: 30px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: calc(100% - 24px);
  }

  .brand-block .eyebrow {
    display: none;
  }

  .ghost-button {
    min-height: 40px;
    padding: 7px 11px;
    font-size: 0.82rem;
  }

  .search-bar {
    grid-template-columns: 22px minmax(0, 1fr);
    padding: 8px 10px 10px;
  }

  .search-bar .primary-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .searched-metrics {
    grid-template-columns: 1fr 1fr;
  }

  .searched-metrics > div:last-child {
    grid-column: 1 / -1;
  }

  .subsection-heading {
    align-items: flex-start;
  }

  .subsection-heading > span {
    white-space: nowrap;
  }

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

  .character-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .card-portrait {
    width: 76px;
  }

  .character-stats {
    grid-template-columns: 1fr 1fr;
  }

  .expedition-header {
    align-items: flex-start;
    padding: 17px;
  }

  .delete-button {
    min-width: 58px;
  }

  .login-card {
    padding: 28px 22px;
  }
}
