:root {
  --bg: #05051d;
  --bg-soft: #0b1140;
  --panel: rgba(10, 15, 48, .96);
  --panel-2: rgba(32, 14, 72, .97);
  --panel-3: rgba(255, 255, 255, .08);
  --text: #fffdf6;
  --muted: #cbd5ff;
  --line: rgba(0, 231, 255, .36);
  --line-strong: rgba(255, 214, 58, .72);
  --gold: #ffb800;
  --gold-2: #fff06a;
  --blue: #00e7ff;
  --violet: #b65cff;
  --pink: #ff3bd4;
  --green: #42ff9c;
  --red: #ff416c;
  --slot: #2d7dff;
  --slot-dark: #322066;
  --shadow: 0 32px 95px rgba(0, 0, 0, .58), 0 0 36px rgba(0, 231, 255, .12);
  color-scheme: dark;
}

body.light {
  --bg: #fff4c7;
  --bg-soft: #fff8e2;
  --panel: rgba(255, 251, 235, .96);
  --panel-2: rgba(255, 239, 199, .98);
  --panel-3: rgba(255, 120, 40, .09);
  --text: #261005;
  --muted: #74512a;
  --line: rgba(255, 121, 31, .38);
  --line-strong: rgba(0, 153, 255, .48);
  --gold: #ff8a00;
  --gold-2: #ffd22e;
  --blue: #008cff;
  --violet: #8b35ff;
  --pink: #e300a9;
  --green: #00a85a;
  --red: #d71952;
  --slot: #ffe17a;
  --slot-dark: #ff9d2e;
  --shadow: 0 24px 70px rgba(255, 120, 0, .22), 0 0 30px rgba(0, 140, 255, .14);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 184, 0, .52), transparent 30rem),
    radial-gradient(circle at 88% 10%, rgba(0, 231, 255, .38), transparent 32rem),
    radial-gradient(circle at 78% 88%, rgba(255, 59, 212, .32), transparent 34rem),
    radial-gradient(circle at 18% 82%, rgba(66, 255, 156, .22), transparent 28rem),
    linear-gradient(135deg, #05051d 0%, #071a4d 42%, #2a0b54 72%, #10051e 100%);
  color: var(--text);
}
body.light {
  background:
    radial-gradient(circle at 7% 8%, rgba(255, 184, 0, .55), transparent 30rem),
    radial-gradient(circle at 92% 10%, rgba(0, 156, 255, .30), transparent 32rem),
    radial-gradient(circle at 80% 88%, rgba(255, 59, 212, .22), transparent 34rem),
    linear-gradient(135deg, #fff0ac 0%, #fffdf0 45%, #ffd9ef 100%);
}

button, input, select { font: inherit; }
button { cursor: pointer; transition: transform .16s ease, filter .16s ease, border-color .16s ease, background .16s ease; }
button:active { transform: translateY(1px); }

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 4px 2px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold-2);
  letter-spacing: .16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 800;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 4vw, 52px);
  letter-spacing: -.055em;
  line-height: .95;
  text-shadow: 0 8px 28px rgba(0,0,0,.45), 0 0 24px rgba(0,231,255,.18);
}
h2 { margin-bottom: 0; font-size: 20px; letter-spacing: -.02em; }

.top-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 440px) 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background:
    linear-gradient(180deg, var(--panel), var(--panel-2)),
    linear-gradient(135deg, rgba(0, 231, 255, .18), rgba(255, 59, 212, .08), rgba(255, 184, 0, .10));
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.11);
  backdrop-filter: blur(14px);
  position: relative;
  overflow: hidden;
}
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(0,231,255,.18), transparent 32%, rgba(255,59,212,.14), rgba(255,214,58,.10));
  mask: linear-gradient(#000, transparent 52%);
}

.controls-panel { padding: 20px; position: sticky; top: 18px; }
.preview-panel { padding: 20px; min-width: 0; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0,231,255,.12), rgba(255,59,212,.06));
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.field { display: grid; gap: 8px; margin-bottom: 14px; position: relative; z-index: 1; }
.field span, .mini-label { font-size: 12px; color: var(--muted); margin: 0 0 3px; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px 13px;
  background: rgba(2, 5, 28, .58);
  color: var(--text);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
select option { background: #141927; color: #fff7e7; }
body.light input, body.light select { background: rgba(255, 255, 255, .72); }
body.light select option { background: #fff9ef; color: #22190f; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 231, 255, .18), 0 0 18px rgba(0, 231, 255, .20); }

.lang-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .16);
  border-radius: 17px;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}
.lang-switch button, .ghost-btn, .danger-btn, .primary-btn {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(0, 0, 0, .04));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.lang-switch button.active, .primary-btn {
  background: linear-gradient(135deg, #fff06a 0%, #ffb800 42%, #ff5f1f 100%);
  color: #220b00;
  border-color: rgba(255, 255, 255, .48);
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(255, 184, 0, .36), 0 0 24px rgba(255, 95, 31, .22), inset 0 1px 0 rgba(255,255,255,.66);
}
.danger-btn { color: #ffdada; border-color: rgba(255, 112, 112, .38); }
body.light .danger-btn { color: #7c2121; }
.ghost-btn:hover, .danger-btn:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.primary-btn:hover { filter: brightness(1.12) saturate(1.15); transform: translateY(-1px); }

.selected-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(0, 231, 255, .18), rgba(255, 59, 212, .10), rgba(255, 184, 0, .12));
  border-radius: 19px;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}
.selected-box strong { display: block; }

.search-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.results {
  display: grid;
  gap: 8px;
  max-height: 490px;
  overflow: auto;
  padding-right: 4px;
  position: relative;
  z-index: 1;
  scrollbar-width: thin;
}

.result-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0,231,255,.10), rgba(255,59,212,.055));
  color: var(--text);
  border-radius: 17px;
  padding: 9px;
}
.result-card:hover, .result-card:focus { border-color: var(--gold-2); background: linear-gradient(135deg, rgba(255,184,0,.20), rgba(0,231,255,.14)); box-shadow: 0 0 18px rgba(255,184,0,.16); }
.result-card strong { display: block; font-size: 13px; line-height: 1.22; }
.result-card small { color: var(--muted); }
.result-card .add-sign { color: var(--gold-2); font-weight: 900; font-size: 18px; }

.icon-box {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(255,255,255,.32), rgba(0,231,255,.12), rgba(0,0,0,.20));
  border: 1px solid rgba(0,0,0,.34);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 4px 10px rgba(0,0,0,.24);
  font-size: 11px;
  font-weight: 900;
  color: var(--gold-2);
  position: relative;
}
.icon-box img { width: 100%; height: 100%; image-rendering: pixelated; object-fit: cover; display: block; }
.icon-box .fallback { padding: 2px; text-align: center; font-size: 10px; }

.preview-title { align-items: flex-start; }
#subtitle { margin: 5px 0 0; color: var(--muted); }
.alchemy-frame {
  overflow: auto;
  border-radius: 20px;
  padding: 16px;
  background:
    radial-gradient(circle at top left, rgba(255, 240, 106, .28), transparent 18rem),
    radial-gradient(circle at bottom right, rgba(0, 231, 255, .18), transparent 22rem),
    linear-gradient(135deg, rgba(11, 24, 70, .97), rgba(42, 11, 84, .96));
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), inset 0 -24px 42px rgba(0,0,0,.22), 0 0 26px rgba(0,231,255,.12);
  position: relative;
  z-index: 1;
}
body.light .alchemy-frame { background: linear-gradient(135deg, #e4d5bd, #cbbba2); }

.alchemy-grid {
  width: max-content;
  min-width: 100%;
  display: grid;
  grid-template-columns: 86px repeat(8, 72px);
  gap: 5px;
  align-items: stretch;
}
.round-label {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff6de;
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  text-shadow: 1px 1px 0 #000;
  border-radius: 8px;
  background: linear-gradient(180deg, #235dff, #6727d9 62%, #2b165d);
  border: 1px solid rgba(0,231,255,.38);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.10);
}
body.light .round-label { color: #2b2218; text-shadow: none; background: linear-gradient(180deg, #f1e5ce, #c8b79e); }
.slot {
  width: 72px;
  min-height: 64px;
  border: 1px solid rgba(17, 20, 31, .92);
  outline: 1px solid rgba(255, 241, 184, .22);
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.34), transparent 28px),
    linear-gradient(180deg, var(--slot), #6140d9 56%, var(--slot-dark));
  border-radius: 7px;
  position: relative;
  padding: 5px;
  display: grid;
  grid-template-rows: 38px 1fr;
  justify-items: center;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.13), 0 6px 12px rgba(0,0,0,.18);
}
.slot:hover { filter: brightness(1.20) saturate(1.18); transform: translateY(-1px); box-shadow: 0 0 18px rgba(0,231,255,.20), inset 0 1px 0 rgba(255,255,255,.18); }
.slot.selected {
  box-shadow: 0 0 0 3px rgba(255, 240, 106, .95), 0 0 32px rgba(255, 184, 0, .62), 0 0 18px rgba(0,231,255,.32), inset 0 1px 0 rgba(255,255,255,.25);
  z-index: 1;
}
.slot .icon-box { width: 38px; height: 38px; border-radius: 5px; }
.slot-name {
  width: 100%;
  margin-top: 3px;
  color: #fffbe8;
  font-size: 9px;
  line-height: 1.03;
  text-align: center;
  text-shadow: 1px 1px 1px #000;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.slot-qty {
  position: absolute;
  right: 4px;
  bottom: 3px;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  text-shadow: 1px 1px 1px #000, -1px -1px 1px #000;
}
.empty-slot { opacity: .52; }

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .controls-panel { position: static; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .alchemy-grid { grid-template-columns: 76px repeat(8, 64px); }
  .slot { width: 64px; min-height: 62px; }
  .round-label { min-height: 62px; font-size: 13px; }
}


/* Paleta viva / neon */
.topbar .primary-btn,
.preview-title .primary-btn {
  background: linear-gradient(135deg, #fff06a 0%, #ffb800 38%, #ff5f1f 100%);
}

.panel:hover {
  border-color: rgba(255, 214, 58, .58);
}

.results::-webkit-scrollbar { width: 10px; }
.results::-webkit-scrollbar-track { background: rgba(255,255,255,.05); border-radius: 999px; }
.results::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--blue), var(--violet));
  border-radius: 999px;
}

.slot .icon-box {
  box-shadow: 0 0 10px rgba(0, 231, 255, .20), inset 0 1px 0 rgba(255,255,255,.20);
}
