:root {
  color-scheme: dark;
  --bg: #080a12;
  --bg-2: #101527;
  --panel: rgba(18, 22, 37, 0.84);
  --panel-solid: #121625;
  --panel-2: #171d31;
  --text: #f6f8ff;
  --muted: #a8b0ca;
  --faint: #68708c;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #72f3ff;
  --accent-2: #a875ff;
  --gold: #ffd166;
  --good: #65f0a3;
  --bad: #ff6b8a;
  --warn: #ffca66;
  --radius-lg: 26px;
  --radius: 18px;
  --radius-sm: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(114, 243, 255, 0.18), transparent 32rem),
    radial-gradient(circle at 85% 8%, rgba(168, 117, 255, 0.22), transparent 28rem),
    linear-gradient(135deg, #080a12 0%, #101425 52%, #090b15 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid rgba(114, 243, 255, 0.55);
  outline-offset: 2px;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.hero {
  min-height: 220px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 22px;
  align-items: end;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(24, 30, 52, 0.9), rgba(11, 13, 25, 0.78));
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -80px -160px auto;
  width: 360px;
  height: 360px;
  background: conic-gradient(from 60deg, var(--accent), var(--accent-2), var(--gold), var(--accent));
  filter: blur(52px);
  opacity: 0.2;
  border-radius: 50%;
}

.hero-copy,
.hero-card {
  position: relative;
  z-index: 1;
}

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

h1 {
  font-size: clamp(38px, 7vw, 82px);
  line-height: 0.88;
  margin: 0;
  letter-spacing: -0.07em;
}

.lede {
  max-width: 620px;
  color: var(--muted);
  font-size: clamp(16px, 2.6vw, 20px);
  margin: 18px 0 0;
}

.hero-card,
.control-panel,
.tabs,
.section-head,
.sprite-card,
.friend-block,
.summary-card,
.table-wrap,
.empty-card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.18);
}

.hero-card {
  padding: 20px;
  border-radius: 22px;
}

.hero-card-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.hero-card strong {
  display: block;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.hero-card span {
  display: block;
}

.hero-card #activeUserProgress {
  color: var(--good);
  margin-top: 8px;
  font-weight: 700;
}

.save-status {
  min-height: 1.3em;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.save-status[data-state="saving"] {
  color: var(--accent);
}

.save-status[data-state="saved"] {
  color: var(--good);
}

.save-status[data-state="error"] {
  color: var(--bad);
}

.save-status[data-state="warning"] {
  color: var(--warn);
}

.control-panel {
  margin-top: 16px;
  border-radius: 22px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 12px;
}

.field-row,
.create-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.field-row label {
  color: var(--muted);
  font-weight: 700;
  min-width: 64px;
}

select,
input[type="text"],
input[type="search"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

select option {
  color: #111;
}

input::placeholder {
  color: rgba(168, 176, 202, 0.7);
}

input:focus,
select:focus {
  border-color: rgba(114, 243, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(114, 243, 255, 0.12);
}

.create-form {
  flex-wrap: wrap;
}

.create-form input {
  min-width: 0;
  flex: 1 1 240px;
}

.create-form button,
.tab {
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  color: #061018;
  background: linear-gradient(135deg, var(--accent), #8af7c9);
  font-weight: 900;
  padding: 0 18px;
}

.hint,
.field-error {
  width: 100%;
  margin: 0;
  font-size: 13px;
}

.hint {
  color: var(--muted);
}

.field-error {
  color: var(--bad);
  min-height: 1.25em;
}

.tabs {
  position: sticky;
  top: 8px;
  z-index: 5;
  margin: 16px 0;
  border-radius: 22px;
  padding: 8px;
  display: flex;
  gap: 8px;
}

.tab {
  flex: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
}

.tab.active {
  color: #061018;
  background: linear-gradient(135deg, var(--accent), #8af7c9);
}

.tab:not(.active):hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.section-head {
  border-radius: 22px;
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 40px);
  letter-spacing: -0.04em;
}

.section-head p {
  color: var(--muted);
  margin: 8px 0 0;
}

.filters {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search {
  min-width: min(260px, 100%);
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pill-toggle {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  color: var(--muted);
  white-space: nowrap;
}

.pill-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.empty-state {
  margin-bottom: 16px;
}

.empty-card {
  border-radius: var(--radius);
  padding: 22px;
}

.empty-card h3 {
  margin: 0 0 6px;
  font-size: 22px;
}

.empty-card p {
  margin: 0;
  color: var(--muted);
}

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

.sprite-card {
  border-radius: var(--radius);
  padding: 16px;
  overflow: hidden;
}

.sprite-card-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
  margin-bottom: 14px;
}

.family-title {
  font-size: 20px;
  font-weight: 950;
  letter-spacing: -0.03em;
}

.family-progress {
  color: var(--good);
  font-weight: 850;
  font-size: 13px;
  padding: 5px 9px;
  background: rgba(101, 240, 163, 0.12);
  border-radius: 999px;
}

.family-progress.is-incomplete {
  color: var(--accent);
  background: rgba(114, 243, 255, 0.12);
}

.sprite-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.045);
  transition: 0.15s ease;
}

.sprite-option:hover {
  transform: translateY(-1px);
  border-color: rgba(114, 243, 255, 0.45);
}

.sprite-option input {
  width: 28px;
  height: 28px;
  accent-color: var(--accent);
  justify-self: center;
}

.sprite-option-content {
  min-width: 0;
}

.sprite-name {
  display: block;
  font-weight: 850;
}

.sprite-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.07);
}

.badge.starter {
  color: var(--gold);
}

.rarity-Mythic {
  color: #ffadf6;
}

.rarity-Legendary {
  color: #ffd166;
}

.rarity-Epic {
  color: #b794ff;
}

.rarity-Rare {
  color: #72f3ff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-card {
  border-radius: var(--radius);
  padding: 16px;
}

.summary-card strong {
  display: block;
  font-size: 22px;
}

.summary-card span {
  color: var(--muted);
}

.progress-bar {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--good));
}

.friends-card-list {
  display: grid;
  gap: 14px;
}

.friend-block {
  border-radius: var(--radius);
  padding: 16px;
}

.friend-block h3 {
  margin: 0 0 12px;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.friend-sprite-row {
  border-top: 1px solid var(--line);
  padding: 12px 0;
  display: grid;
  grid-template-columns: 190px 1fr 1fr;
  gap: 12px;
}

.friend-sprite-row:last-child {
  padding-bottom: 0;
}

.friend-sprite-name {
  font-weight: 850;
}

.friend-sprite-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.have-list,
.missing-list {
  color: var(--muted);
  font-size: 14px;
}

.have-list strong {
  color: var(--good);
}

.missing-list strong {
  color: var(--bad);
}

.name-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.name-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.table-wrap {
  border-radius: var(--radius);
  overflow: auto;
  max-height: 72vh;
}

table {
  width: 100%;
  min-width: 850px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #151a2d;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  text-align: left;
  background: #121625;
  min-width: 245px;
}

th:first-child {
  z-index: 3;
  background: #151a2d;
}

tr.family-break td {
  border-top: 2px solid rgba(114, 243, 255, 0.22);
}

.check {
  color: var(--good);
  font-size: 20px;
  font-weight: 900;
}

.cross {
  color: var(--faint);
  font-size: 18px;
}

.table-sprite-name {
  display: block;
  font-weight: 850;
  color: var(--text);
}

.table-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: 999px;
  color: #061018;
  background: linear-gradient(135deg, var(--accent), var(--good));
  font-weight: 900;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  transition: 0.2s ease;
}

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

.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: 980px) {
  .hero {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 24px;
  }

  .hero-card {
    width: 100%;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }

  .filters {
    justify-content: stretch;
  }

  .search {
    width: 100%;
  }

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

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

  .friend-sprite-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 9px;
  }

  .hero {
    min-height: auto;
    border-radius: 20px;
    padding: 20px;
  }

  .control-panel {
    padding: 10px;
  }

  .field-row,
  .create-form {
    flex-direction: column;
    align-items: stretch;
  }

  .tabs {
    top: 4px;
    overflow-x: auto;
    padding: 6px;
  }

  .tab {
    flex: 0 0 auto;
    padding: 0 14px;
  }

  .sprite-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    padding: 16px;
  }

  .sprite-option {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .sprite-option > .badge {
    grid-column: 2;
    width: fit-content;
  }

  .sprite-option-content {
    grid-column: 2;
  }

  h1 {
    letter-spacing: -0.06em;
  }
}
