:root {
  --bg: #0d0f12;
  --bg-2: #12161b;
  --panel: #161b21;
  --panel-2: #1c222a;
  --line: #29313b;
  --line-2: #343e4a;
  --text: #e9edf2;
  --muted: #95a0ad;
  --accent: #74d97a;
  --accent-2: #4fb85a;
  --accent-ink: #0b1a0c;
  --dirt: #8b5e3c;
  --warn: #f2b84b;
  --bad: #ef6b6b;
  --radius: 14px;
  --pixel: "Pixelify Sans", ui-monospace, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(116, 217, 122, .10), transparent 60%),
    radial-gradient(900px 400px at 110% 0%, rgba(139, 94, 60, .12), transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  min-height: 100vh;
}

a { color: var(--accent); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1 1 auto; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1080px; margin: 0 auto; padding: 18px 20px;
}
.brand {
  display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none;
  font: 700 22px var(--pixel); letter-spacing: .5px;
}
.brand img { image-rendering: pixelated; }
.tag {
  font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
}

main { max-width: 1080px; margin: 0 auto; padding: 0 20px 40px; }

.hero { padding: 26px 0 22px; }
.hero h1 {
  margin: 0 0 12px; font: 700 clamp(32px, 6vw, 54px)/1.05 var(--pixel); letter-spacing: .5px;
}
.hero h1 span { color: var(--accent); }
.hero p { margin: 0; max-width: 640px; color: var(--muted); font-size: 16px; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 0 0 16px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 12px; }
.card-head h2, .results-head h2 { margin: 0; font: 700 20px var(--pixel); letter-spacing: .3px; }

textarea, input, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { width: 100%; resize: vertical; min-height: 92px; font-size: 16px; }
textarea:focus, input:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(116, 217, 122, .15); }
select { padding: 8px 10px; }

.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; }
.row.end { justify-content: flex-end; }
.field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.examples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  font: 500 13px var(--sans); color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; cursor: pointer; transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--accent-2); background: #1f2a22; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 14px var(--sans); color: var(--text); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 10px 16px; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .05s, background .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .18);
}
.btn.primary:hover { background: #86e48b; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

.icon-btn {
  border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: 8px;
  width: 30px; height: 30px; cursor: pointer; font-size: 15px; flex: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); background: var(--panel-2); }

.notes { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.notes li {
  font-size: 14px; color: #f6deb0; background: rgba(242, 184, 75, .08); border: 1px solid rgba(242, 184, 75, .25);
  border-radius: 10px; padding: 8px 12px;
}

.criteria { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.crit {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 10px;
}
.crit.neg { border-color: rgba(239, 107, 107, .35); }
.crit.empty { color: var(--muted); justify-content: center; padding: 14px; }
.crit-kind {
  font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: .6px; color: var(--accent-ink);
  background: var(--accent); border-radius: 6px; padding: 3px 7px;
}
.crit.neg .crit-kind { background: var(--bad); color: #2a0b0b; }
.crit-label { font-weight: 600; flex: 1 1 200px; }
.crit .icon-btn { margin-left: auto; }
.ctl { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.num { width: 84px; padding: 6px 8px; border-radius: 8px; }

.adder { margin-top: 12px; border: 1px dashed var(--line-2); border-radius: 12px; padding: 10px 12px; }
.adder summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.adder-body { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 12px; }
.adder-body .field input { width: 96px; }
[hidden] { display: none !important; }

.progress-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.bar { height: 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin-top: 12px; }
.bar div {
  height: 100%; width: 0; transition: width .6s linear;
  background: repeating-linear-gradient(90deg, var(--accent-2) 0 12px, var(--accent) 12px 24px);
  animation: slide 1s linear infinite;
}
.bar div.done { animation: none; background: var(--accent); }
@keyframes slide { from { background-position: 0 0; } to { background-position: 24px 0; } }

.diagnostic { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.diagnostic h4 { margin: 0 0 8px; font-size: 14px; }
.diagnostic p { margin: 10px 0 0; color: var(--muted); }
.rates { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.rates li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 8px; border-radius: 8px; }
.rates li.worst { background: rgba(239, 107, 107, .1); color: #ffd0d0; }

.results-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 26px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.result {
  background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.result:hover { border-color: var(--line-2); }
.result-top { display: flex; align-items: center; gap: 10px; }
.rank { font: 700 14px var(--pixel); color: var(--muted); }
.seed {
  flex: 1; font: 600 16px var(--mono); color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; overflow-x: auto; white-space: nowrap;
}
.quality { height: 6px; border-radius: 999px; background: var(--bg); overflow: hidden; }
.quality span { display: block; height: 100%; background: linear-gradient(90deg, var(--warn), var(--accent)); }
.spawn { margin: 0; font-size: 14px; color: var(--muted); }
.hits { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.hits li { padding-left: 16px; position: relative; }
.hits li::before { content: ""; position: absolute; left: 2px; top: 8px; width: 7px; height: 7px; background: var(--accent); border-radius: 2px; }
.hits li.neg::before { background: var(--bad); }
.result-actions { display: flex; gap: 8px; margin-top: auto; }

.analyze { margin-top: 28px; }
.analyze input { min-width: 0; }

dialog {
  width: min(1180px, 96vw); height: min(820px, 92vh); padding: 0; border: 1px solid var(--line-2);
  border-radius: 16px; background: var(--panel); color: var(--text); overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(5, 7, 9, .7); backdrop-filter: blur(3px); }
.map-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.map-head h3 { margin: 0; font: 600 18px var(--mono); }
.map-body { flex: 1; display: grid; grid-template-columns: 1fr 280px; min-height: 0; }
.map-canvas { position: relative; min-height: 0; background: #0b0d10; }
.map-canvas canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.map-canvas canvas:active { cursor: grabbing; }
.map-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.map-zoom { position: absolute; right: 12px; bottom: 12px; display: grid; gap: 6px; }
.map-zoom .btn { width: 36px; height: 36px; padding: 0; font-size: 18px; background: rgba(22, 27, 33, .9); }
.map-tip {
  position: absolute; pointer-events: none; background: rgba(12, 14, 17, .94); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; display: grid; gap: 2px; max-width: 280px;
}
.tip-struct { color: var(--warn); }
.map-side { border-left: 1px solid var(--line); padding: 12px 14px; overflow-y: auto; }
.side-block { margin-bottom: 16px; }
.side-block h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.legend { display: grid; gap: 4px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.legend-item input { accent-color: var(--accent); }
.legend-item .muted { margin-left: auto; font-size: 12px; }
.dot {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font: 700 11px var(--sans); color: rgba(0, 0, 0, .85); border: 1px solid rgba(0, 0, 0, .6);
}
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; z-index: 50;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 16px;
  transition: opacity .25s, transform .25s; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: var(--bad); }

footer { max-width: 1080px; margin: 0 auto; padding: 10px 20px 40px; color: var(--muted); font-size: 13px; }

@media (max-width: 760px) {
  main, .top, footer { padding-left: 16px; padding-right: 16px; }
  .card { padding: 14px; }
  .row .btn.primary { width: 100%; }
  .grid { grid-template-columns: 1fr; }
  dialog { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; border-radius: 0; }
  .map-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .map-side { border-left: 0; border-top: 1px solid var(--line); max-height: 34vh; }
  .num { width: 72px; }
}
