:root {
  color-scheme: dark;
  --bg: #08080f;
  --panel: #121325;
  --panel-2: #181a30;
  --line: rgba(130, 110, 255, .28);
  --text: #eef0ff;
  --muted: #8b8fc4;
  --accent: #4f7fff;
  --accent-2: #8b5cf6;
  --accent-3: #7c93ff;
  --danger: #ff6b9d;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px rgba(0, 8, 30, .55);
  --glow: 0 0 0 1px rgba(124, 110, 255, .25), 0 0 24px rgba(124, 110, 255, .18), 0 18px 46px rgba(0, 10, 30, .55);
  --glow-strong: 0 0 0 1px rgba(124, 110, 255, .55), 0 0 18px rgba(124, 110, 255, .55), 0 0 60px rgba(124, 110, 255, .28);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* {
  box-sizing: border-box;
}

@keyframes floatGlow {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(2%, -3%, 0) scale(1.06); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(124, 110, 255, .3), 0 0 22px rgba(124, 110, 255, .22), 0 18px 46px rgba(0, 10, 30, .55); }
  50% { box-shadow: 0 0 0 1px rgba(124, 110, 255, .55), 0 0 42px rgba(124, 110, 255, .4), 0 18px 46px rgba(0, 10, 30, .55); }
}

@keyframes shimmerText {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(.9); }
  to { opacity: 1; transform: scale(1); }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 10%, rgba(124, 110, 255, .16), transparent 42%),
    radial-gradient(circle at 85% 25%, rgba(109, 140, 255, .14), transparent 45%),
    radial-gradient(circle at 50% 90%, rgba(110, 150, 255, .10), transparent 50%),
    linear-gradient(180deg, #05070f 0%, #060a17 50%, #050810 100%);
  animation: floatGlow 16s ease-in-out infinite;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease), background .25s var(--ease), color .25s var(--ease);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1460px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  animation: fadeInUp .5s var(--ease) both;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(124, 110, 255, .6);
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 68px);
  line-height: 1;
  letter-spacing: -.01em;
  font-weight: 900;
}

.neon-text {
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3), var(--accent-2));
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmerText 6s linear infinite;
  filter: drop-shadow(0 0 18px rgba(124, 110, 255, .45));
}

.stats-pill {
  min-width: 148px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(12, 22, 40, .65);
  backdrop-filter: blur(10px);
  text-align: right;
  box-shadow: var(--glow);
}

.stats-pill span {
  display: block;
  font-size: 30px;
  font-weight: 900;
  color: var(--accent-3);
  text-shadow: 0 0 16px rgba(110, 150, 255, .5);
}

.stats-pill small,
.meta-line {
  color: var(--muted);
}

.mode-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 7px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 12, 24, .65);
  backdrop-filter: blur(10px);
  animation: fadeInUp .55s var(--ease) both;
}

.mode-tabs button,
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: transparent;
  padding: 11px 18px;
  font-weight: 800;
}

.mode-tabs button:hover,
.segmented button:hover {
  color: var(--text);
  border-color: var(--line);
}

.mode-tabs button.active,
.segmented button.active {
  color: #f5f6ff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 22px rgba(124, 110, 255, .55), 0 6px 18px rgba(0, 0, 0, .35);
}

.icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(124, 110, 255, .16);
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeInUp .4s var(--ease) both;
}

.formula {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 14px;
  margin-bottom: 22px;
}

.slot {
  position: relative;
  display: grid;
  min-height: 208px;
  place-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: linear-gradient(160deg, rgba(124, 110, 255, .07), rgba(12, 21, 38, .5));
  box-shadow: var(--glow);
  padding: 18px;
  text-align: center;
}

button.slot:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 110, 255, .55);
  box-shadow: var(--glow-strong);
}

button.slot.active {
  border-color: var(--accent);
  animation: pulseGlow 2.4s ease-in-out infinite;
}

.slot.result {
  border-color: rgba(110, 150, 255, .4);
  background: linear-gradient(160deg, rgba(110, 150, 255, .10), rgba(12, 21, 38, .5));
}

.image-wrap {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
}

.image-wrap img {
  max-width: 130px;
  max-height: 130px;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(124, 110, 255, .35)) drop-shadow(0 14px 18px rgba(0, 0, 0, .4));
  transition: transform .3s var(--ease);
}

button.slot:hover .image-wrap img {
  transform: scale(1.06);
}

.image-wrap img[src=""] {
  display: none;
}

.slot-name {
  font-size: 20px;
  font-weight: 900;
}

.gender {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}

.gender:hover {
  transform: scale(1.12) rotate(8deg);
}

.male {
  background: linear-gradient(135deg, #3fa7ff, #2452ff);
  box-shadow: 0 0 16px rgba(63, 167, 255, .65);
}

.female {
  background: linear-gradient(135deg, #ff5fc9, #c23fff);
  box-shadow: 0 0 16px rgba(255, 95, 201, .65);
}

.operator {
  align-self: center;
  color: var(--accent-3);
  font-size: 36px;
  font-weight: 900;
  text-shadow: 0 0 18px rgba(110, 150, 255, .55);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar.compact {
  display: block;
  margin: 12px 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(8, 15, 28, .6);
  backdrop-filter: blur(8px);
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease);
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 110, 255, .18), 0 0 20px rgba(124, 110, 255, .3);
}

.search-box svg {
  width: 22px;
  min-width: 22px;
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(124, 110, 255, .6));
}

.search-box circle,
.search-box path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-box span {
  white-space: nowrap;
  color: var(--muted);
  font-weight: 800;
}

.sort-box {
  display: flex;
  gap: 8px;
}

select,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--panel);
  padding: 0 14px;
}

select:hover,
.icon-btn:hover {
  border-color: var(--accent);
}

.icon-btn {
  width: 46px;
  font-weight: 900;
  color: var(--accent);
}

.pal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}

.compact-grid {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
}

.pal-card,
.mini-card,
.combo-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(14, 24, 42, .55);
  animation: popIn .3s var(--ease) both;
}

.pal-card {
  min-height: 178px;
  padding: 12px;
  color: var(--text);
  text-align: left;
}

.pal-card:hover {
  transform: translateY(-4px);
  border-color: rgba(124, 110, 255, .6);
  box-shadow: var(--glow-strong);
}

.pal-card.selected {
  border-color: var(--accent);
  background: rgba(124, 110, 255, .12);
  box-shadow: var(--glow-strong);
}

.pal-art {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 72px;
}

.pal-art img {
  width: 70px;
  height: 70px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(124, 110, 255, .25));
  transition: transform .3s var(--ease);
}

.pal-card:hover .pal-art img {
  transform: scale(1.08);
}

.elements {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.elements img {
  width: 24px;
  height: 24px;
}

.pal-title {
  display: block;
  margin: 8px 0 3px;
  font-weight: 900;
}

.pal-sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rarity {
  display: inline-flex;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.common { background: rgba(125, 155, 196, .18); color: #cfe0ef; }
.rare { background: rgba(63, 167, 255, .2); color: #8fd4ff; }
.epic { background: rgba(160, 100, 255, .2); color: #cbaaff; }
.legendary {
  background: rgba(139, 92, 246, .2);
  color: #c9b8ff;
  box-shadow: 0 0 12px rgba(139, 92, 246, .35);
}

.combo-layout {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 18px;
}

.target-panel,
.results-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(8, 15, 28, .5);
  backdrop-filter: blur(10px);
  padding: 16px;
  box-shadow: var(--glow);
}

.target {
  width: 100%;
  min-height: 190px;
}

.results-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .03);
}

.result-search {
  min-width: 220px;
}

.combo-results {
  display: grid;
  gap: 12px;
  max-height: 748px;
  overflow: auto;
  padding-right: 4px;
}

.combo-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 10px;
  transition: transform .25s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease);
}

.combo-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 110, 255, .5);
  box-shadow: var(--glow);
}

.mini-card {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 68px;
  padding: 7px;
}

.mini-card img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(124, 110, 255, .25));
}

.mini-name {
  overflow-wrap: anywhere;
  font-weight: 900;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

/* scrollbars */
.compact-grid::-webkit-scrollbar,
.combo-results::-webkit-scrollbar {
  width: 8px;
}

.compact-grid::-webkit-scrollbar-thumb,
.combo-results::-webkit-scrollbar-thumb {
  background: rgba(124, 110, 255, .35);
  border-radius: 999px;
}

.compact-grid::-webkit-scrollbar-track,
.combo-results::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 960px) {
  .formula,
  .combo-layout,
  .combo-card {
    grid-template-columns: 1fr;
  }

  .operator {
    text-align: center;
  }

  .toolbar,
  .results-head {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 0;
  }
}

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-pill {
    text-align: left;
  }

  .mode-tabs {
    width: 100%;
  }

  .mode-tabs button {
    flex: 1;
    justify-content: center;
    padding-inline: 8px;
  }

  .pal-grid {
    grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  }

  .slot {
    min-height: 170px;
  }
}
