:root {
  --bg: #07080d;
  --panel: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9edf7;
  --muted: #97a1b8;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(900px 600px at 15% -10%, rgba(124, 92, 255, 0.20), transparent 60%),
    radial-gradient(800px 500px at 90% 0%, rgba(34, 211, 238, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(20px, 5vw, 56px);
  background: rgba(7, 8, 13, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
}

.mark {
  color: var(--accent-2);
  font-size: 0.9rem;
}

.nav nav {
  display: flex;
  gap: 22px;
  font-size: 0.92rem;
  color: var(--muted);
}

.nav nav a:hover { color: var(--text); }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px) 80px;
}

.hero {
  padding: clamp(56px, 9vw, 104px) 0 clamp(40px, 6vw, 64px);
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 14px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 600;
}

.hero h1 {
  margin: 0 0 20px;
  font-size: clamp(2.1rem, 5.4vw, 3.6rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.grad {
  background: linear-gradient(100deg, #a78bfa, #22d3ee 60%, #f0abfc);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lede {
  margin: 0 0 28px;
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  color: var(--muted);
  max-width: 60ch;
}

.cta { display: flex; flex-wrap: wrap; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.11); }
.btn:active { transform: translateY(0); }

.btn.primary {
  background: linear-gradient(120deg, #7c5cff, #4f46e5);
  border-color: transparent;
  box-shadow: 0 10px 30px -12px rgba(124, 92, 255, 0.9);
}

.btn.primary:hover { background: linear-gradient(120deg, #8b6dff, #5b52f0); }

.btn.ghost { background: transparent; }

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  color: var(--muted);
}

.facts strong { color: var(--text); }

.panel {
  margin-top: 28px;
  padding: clamp(22px, 3.4vw, 36px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel-head { margin-bottom: 24px; }

.panel-head h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.panel-head p { margin: 0; color: var(--muted); font-size: 0.93rem; }

.builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: clamp(24px, 4vw, 48px);
  align-items: start;
}

.controls { display: grid; gap: 16px; }

.row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.row > label { flex: 1 1 180px; }
.row > label.narrow { flex: 0 1 110px; }
.row > label.grow { flex: 1 1 220px; }

label {
  display: grid;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: normal;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea { resize: vertical; line-height: 1.5; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(124, 92, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

input[type="file"] {
  padding: 9px;
  font-size: 0.85rem;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.25);
  width: 100%;
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.preview {
  position: sticky;
  top: 88px;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
}

#card {
  width: 100%;
  max-width: 380px;
  height: auto;
  border-radius: 16px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.95);
}

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

.thumb {
  margin: 0;
  position: relative;
  display: grid;
  gap: 8px;
}

.thumb canvas {
  width: 100%;
  height: auto;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 16px 34px -22px rgba(0, 0, 0, 0.95);
}

.thumb canvas:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 44px -20px rgba(124, 92, 255, 0.55);
}

.thumb figcaption {
  font-size: 0.82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb .del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.65);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.thumb:hover .del { opacity: 1; }
.thumb .del:hover { color: #ff6b6b; }

.empty {
  margin: 0;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.lib-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.lib-bar input,
.lib-bar select {
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
}

.lib-bar input { flex: 1 1 200px; min-width: 0; }

.lib-bar input:focus,
.lib-bar select:focus {
  outline: none;
  border-color: rgba(124, 92, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

.lib-count {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.empty.wide { grid-column: 1 / -1; }

.btn[hidden] { display: none; }

.mtg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
}

.mtg-search {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.mtg-set {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.mtg-set select {
  flex: 1 1 auto;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.mtg-set select:focus {
  outline: none;
  border-color: rgba(124, 92, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

.mtg-search input {
  flex: 1 1 auto;
  padding: 11px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
}

.mtg-search input:focus {
  outline: none;
  border-color: rgba(124, 92, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
}

.mtg-img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  cursor: pointer;
  display: block;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 16px 34px -22px rgba(0, 0, 0, 0.95);
}

.mtg-img:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 44px -20px rgba(124, 92, 255, 0.55);
}

.gen-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.gen-bar label { flex: 0 1 150px; }

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

.gen-actions .btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.82rem;
}

.gen-card canvas { cursor: default; }

.prose p { color: var(--muted); max-width: 68ch; }
.prose h2 { margin-top: 0; font-size: 1.35rem; letter-spacing: -0.02em; }

footer {
  border-top: 1px solid var(--line);
  padding: 28px clamp(20px, 5vw, 56px);
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

footer p { margin: 0; }

@media (max-width: 900px) {
  .builder { grid-template-columns: 1fr; }
  .preview { position: static; order: -1; }
  #card { max-width: 300px; }
}

@media (max-width: 560px) {
  .nav nav { gap: 14px; font-size: 0.85rem; }
  .facts { gap: 18px; }
  .mtg-search { flex-wrap: wrap; }
}