:root {
  color-scheme: dark;
  --bg: #101032;
  --bg-2: #171a43;
  --panel: #20255d;
  --panel-2: #11162f;
  --text: #f6f8ff;
  --muted: #bbc6ee;
  --line: rgba(255, 255, 255, 0.14);
  --brand: #35e7ff;
  --brand-2: #fff200;
  --accent: #ff37a6;
  --good: #36ff93;
  --danger: #ff5d73;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
  --radius: 8px;
}

:root.light {
  color-scheme: light;
  --bg: #f2f5ff;
  --bg-2: #dce7ff;
  --panel: #ffffff;
  --panel-2: #eff4ff;
  --text: #121833;
  --muted: #56617d;
  --line: rgba(18, 24, 51, 0.14);
  --brand: #0078ff;
  --brand-2: #ffd800;
  --accent: #d91887;
  --good: #008d51;
  --danger: #d43149;
  --shadow: 0 16px 42px rgba(18, 24, 51, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(53, 231, 255, 0.28), transparent 34rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
label.file-button {
  cursor: pointer;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.hero-panel,
.controls,
.tabs,
.dialog-header,
.dialog-actions,
.card-heading,
.control-row,
.action-grid,
.top-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 18px;
}

.top-actions {
  gap: 8px;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: clamp(3rem, 16vw, 5.2rem);
}

.login-card label,
.admin-layout label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.form-error {
  min-height: 1.25rem;
  margin: 0;
  color: var(--danger);
  font-weight: 900;
}

.form-success {
  min-height: 1.25rem;
  margin: 0;
  color: var(--good);
  font-weight: 900;
}

h1,
h2,
h3,
.progress-ring strong,
.stats-grid span {
  margin: 0;
  font-family: Impact, "Arial Black", sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2.5rem, 12vw, 5.8rem);
  line-height: 0.82;
  text-shadow: 3px 4px 0 rgba(0, 0, 0, 0.28);
}

h2 {
  font-size: clamp(1.8rem, 7vw, 3.2rem);
  line-height: 0.95;
}

h3 {
  font-size: clamp(1rem, 5vw, 1.45rem);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand-2);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-panel {
  justify-content: space-between;
  gap: 18px;
  min-height: 188px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(120deg, rgba(53, 231, 255, 0.18), transparent 52%),
    linear-gradient(135deg, var(--panel), var(--panel-2));
  box-shadow: var(--shadow);
}

.hero-copy {
  max-width: 40rem;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.progress-ring {
  position: relative;
  width: 116px;
  height: 116px;
  flex: 0 0 auto;
}

.progress-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring circle {
  fill: none;
  stroke-width: 12;
}

.progress-ring circle:first-child {
  stroke: rgba(255, 255, 255, 0.16);
}

#progressCircle {
  stroke: var(--good);
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
}

.progress-ring strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
}

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

.stats-grid article,
.controls,
.compare-view,
.sprite-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  box-shadow: var(--shadow);
}

.stats-grid article {
  padding: 14px;
}

.stats-grid span {
  display: block;
  font-size: clamp(1.7rem, 5vw, 2rem);
}

.stats-grid p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.controls {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 14px;
}

.search-box span,
.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 24%, transparent);
}

.control-row,
.action-grid {
  gap: 10px;
}

.control-row {
  flex-wrap: wrap;
}

.control-row > *,
.action-grid > * {
  flex: 1;
}

.control-row > * {
  min-width: min(12rem, 100%);
}

button,
.file-button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 900;
  text-transform: uppercase;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), #5d49ff);
}

.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.danger-button {
  background: var(--danger);
}

.file-button {
  display: grid;
  place-items: center;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
}

.tabs {
  gap: 8px;
  margin: 14px 0;
}

.tab {
  flex: 1;
  background: color-mix(in srgb, var(--panel-2) 84%, transparent);
  color: var(--muted);
}

.tab.active {
  background: var(--brand-2);
  color: #101032;
}

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

.sprite-card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sprite-art {
  aspect-ratio: 1.12;
  min-height: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 255, 255, 0.45), transparent 26%),
    linear-gradient(135deg, var(--art-a, #26d8ff), var(--art-b, #7b4dff));
}

.sprite-figure {
  width: min(135px, 58vw);
  aspect-ratio: 1;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.28));
}

.sprite-figure svg {
  width: 100%;
  height: 100%;
}

.sprite-art img {
  width: 86%;
  height: 86%;
  max-height: 210px;
  object-fit: contain;
  padding: 4px;
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 14px;
}

.card-heading {
  justify-content: space-between;
  gap: 12px;
}

.rarity-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  margin: 0 0 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--rarity-color, var(--brand));
  color: #101032;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ability,
.location,
.compare-row span {
  color: var(--muted);
  line-height: 1.45;
}

.ability {
  margin: 12px 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.location {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.meta-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}

.meta-list div {
  min-width: 0;
  padding: 8px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel-2) 88%, transparent);
}

dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
}

dd {
  margin: 2px 0 0;
  font-weight: 900;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  line-height: 1.05;
}

.owned-button {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.owned-button.is-owned {
  background: var(--good);
  color: #101032;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: auto;
}

.mastered-button {
  min-width: 58px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.mastered-button span:first-child {
  display: block;
  font-size: 1.25rem;
  line-height: 1;
}

.mastered-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.mastered-button.is-mastered {
  background: var(--brand-2);
  color: #101032;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 20%, transparent);
}

.owned-button:disabled,
.mastered-button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.compare-view {
  padding: 18px;
}

.compare-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.compare-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.compare-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.compare-summary-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
}

.compare-summary-card:hover,
.compare-summary-card.is-active {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 18%, transparent);
}

.compare-summary strong {
  display: block;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 1.7rem;
  line-height: 1;
}

.compare-summary span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.compare-list {
  display: grid;
  gap: 8px;
}

.compare-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel-2) 86%, transparent);
}

.compare-both {
  border-left-color: var(--good);
}

.compare-you {
  border-left-color: var(--brand);
}

.compare-them {
  border-left-color: var(--accent);
}

.compare-row img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.compare-row strong {
  display: block;
  overflow-wrap: anywhere;
  font-family: Impact, "Arial Black", sans-serif;
  letter-spacing: 0;
  text-transform: uppercase;
}

.compare-status {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.compare-status span {
  min-height: 28px;
  display: grid;
  place-items: center;
  padding: 4px 6px;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.compare-status .has {
  background: var(--good);
  color: #101032;
}

.compare-status .missing {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.empty-state {
  padding: 22px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

dialog {
  width: min(680px, calc(100vw - 24px));
  max-height: min(840px, calc(100vh - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(6, 8, 22, 0.74);
}

#adminDialog {
  width: min(840px, calc(100vw - 24px));
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 16px;
}

.admin-layout section {
  display: grid;
  align-content: start;
  gap: 10px;
}

.admin-layout .full {
  grid-column: 1 / -1;
}

.check-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.user-list {
  display: grid;
  gap: 8px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--panel-2);
}

.user-row strong {
  overflow-wrap: anywhere;
}

.user-row small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.dialog-header,
.dialog-actions {
  justify-content: space-between;
  gap: 12px;
}

.dialog-header {
  margin-bottom: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.dialog-actions {
  margin-top: 16px;
}

.dialog-actions div {
  display: flex;
  gap: 8px;
}

@media (min-width: 720px) {
  .app-shell {
    padding: 28px;
  }

  .controls {
    display: grid;
    grid-template-columns: 1.1fr 1.7fr 0.95fr;
    align-items: end;
  }

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

@media (min-width: 1040px) {
  .sprite-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    align-self: stretch;
    gap: 8px;
    max-width: 360px;
  }

  .top-actions .secondary-button {
    min-height: 40px;
    padding: 0 10px;
    font-size: 0.9rem;
  }

  #themeToggle {
    grid-column: 2;
    justify-self: end;
    width: 48px;
    min-width: 48px;
    min-height: 40px;
  }

  .hero-panel {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .control-row,
  .action-grid,
  .compare-toolbar,
  .dialog-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .compare-toolbar {
    grid-template-columns: 1fr;
  }

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

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

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-layout {
    display: grid;
  }
}
