:root{
  --ink:#0f172a;
  --muted:#64748b;
  --shadow: 0 18px 45px rgba(15,23,42,.12);
  --shadow2: 0 10px 24px rgba(15,23,42,.10);
  --r:24px;

  --blue: rgba(59,130,246,.18);
  --green: rgba(34,197,94,.18);
  --orange: rgba(251,146,60,.18);
  --red: rgba(239,68,68,.18);
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--ink);
  background:
    radial-gradient(circle at 12% 12%, rgba(59,130,246,.14), transparent 45%),
    radial-gradient(circle at 88% 18%, rgba(34,197,94,.12), transparent 45%),
    radial-gradient(circle at 30% 92%, rgba(251,146,60,.12), transparent 45%),
    linear-gradient(180deg, #f6fbff, #fff7ff);
  min-height:100vh;
}

/* Topbar */
.topbar{
  max-width:1100px;
  margin:0 auto;
  padding:18px 16px 10px;
  display:flex;
  gap:12px;
  align-items:flex-start;
}
.back{
  text-decoration:none;
  padding:10px 12px;
  border-radius:14px;
  background:rgba(15,23,42,.06);
  color:var(--ink);
  font-weight:900;
  border:1px solid rgba(15,23,42,.08);
}
.pill{
  display:inline-flex;
  padding:7px 10px;
  border-radius:999px;
  font-weight:1000;
  font-size:12px;
  color:#334155;
  background: rgba(15,23,42,.06);
  border:1px solid rgba(15,23,42,.08);
}
.title h1{
  margin:8px 0 0;
  font-size: clamp(24px, 3.6vw, 38px);
  letter-spacing:-.02em;
}
.subtitle{
  margin:6px 0 0;
  color:var(--muted);
  font-size: 14px;
  font-weight:700;
}

/* Layout */
.page{max-width:1100px;margin:0 auto;padding:0 16px 26px;}
.panel{
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 18px;
  backdrop-filter: blur(8px);
  margin-top: 10px;
}
.panelTop{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:12px;
  flex-wrap:wrap;
}
.panelTop h2{margin:0}
.muted{margin:0;color:var(--muted);font-size:13px;font-weight:800}

.labGrid{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media(min-width:980px){
  .labGrid{grid-template-columns: 1fr 1.15fr 1fr;}
}

.card{
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: var(--r);
  box-shadow: var(--shadow2);
  padding: 16px;
}
.cardTitle{margin:0 0 10px;font-size:16px}

/* Reactants tray */
.tray{
  display:grid;
  gap:14px;
  justify-items:center;
  margin-top: 8px;
}

.chipBtn{
  width:78px;height:78px;
  border-radius: 24px;
  border: 1px solid rgba(15,23,42,.10);
  font-weight:1000;
  font-size: 28px;
  cursor:pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  box-shadow: 0 10px 20px rgba(15,23,42,.08);
  background: var(--blue);
}
.chipBtn:hover{transform: translateY(-2px)}
.chipBtn:active{transform: translateY(-1px) scale(.99)}
.chipBtn.on{background: var(--green);}

.compoundWrap{
  width: 220px;
  border-radius: 24px;
  padding: 12px;
  border: 2px dashed rgba(59,130,246,.25);
  background: rgba(255,255,255,.78);
  text-align:center;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.compoundWrap.dragOver{
  border-color: rgba(34,197,94,.55);
  box-shadow: 0 18px 45px rgba(34,197,94,.18);
}
.compound{
  width: 160px;
  height: 92px;
  margin: 0 auto;
  border-radius: 26px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(15,23,42,.05);
  font-weight: 1000;
  position:relative;
  overflow:hidden;
}
.compound span{
  width:54px;height:54px;
  border-radius: 18px;
  display:grid;
  place-items:center;
  background: rgba(59,130,246,.12);
  border: 1px solid rgba(15,23,42,.10);
  font-size: 22px;
  transition: transform .22s ease, opacity .22s ease, background .22s ease;
}
.compoundHint{
  margin-top:8px;
  color: var(--muted);
  font-weight:900;
  font-size: 12px;
}

/* Center zone */
.mid{position:relative}
.zone{
  position:relative;
  height: 240px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(59,130,246,.10), rgba(34,197,94,.06));
  border: 1px solid rgba(15,23,42,.08);
  overflow:hidden;
  display:grid;
  place-items:center;
  text-align:center;
  padding: 14px;
}
.eqBig{
  font-weight: 1000;
  font-size: 18px;
  letter-spacing: .01em;
  color:#0f172a;
}
.eqArrow{opacity:.7; padding:0 8px}
.eqRight{opacity:.85}

.slots{
  margin-top: 12px;
  display:flex;
  gap: 10px;
  justify-content:center;
}
.slot{
  width:78px;height:78px;
  border-radius: 24px;
  display:grid;
  place-items:center;
  font-weight:1000;
  font-size: 22px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(15,23,42,.05);
  opacity:.5;
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}
.slot.on{
  opacity:1;
  transform: scale(1.05);
  background: var(--green);
}

.controls{
  margin-top:12px;
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:center;
}
.btn{
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(15,23,42,.06);
  border-radius: 18px;
  padding: 10px 14px;
  font-weight: 1000;
  cursor:pointer;
}
.btn.primary{
  background: rgba(59,130,246,.16);
  border-color: rgba(59,130,246,.22);
  color:#1e3a8a;
}
.btn:active{transform: scale(.99);}

.status{
  margin-top:10px;
  padding: 8px 10px;
  border-radius: 999px;
  font-weight: 1000;
  font-size: 12px;
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.10);
  text-align:center;
}

.note{
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(251,146,60,.12);
  border: 1px dashed rgba(251,146,60,.25);
  color:#7c2d12;
  font-weight:900;
  font-size: 12px;
  text-align:center;
}

/* Products */
.productsBox{
  height: 220px;
  border-radius: 24px;
  border: 1px solid rgba(15,23,42,.08);
  background: linear-gradient(180deg, rgba(34,197,94,.08), rgba(59,130,246,.06));
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 16px;
  position:relative;
  overflow:hidden;
}
.productChip{
  width:92px;height:92px;
  border-radius: 28px;
  display:grid;
  place-items:center;
  font-weight: 1000;
  font-size: 32px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(255,255,255,.92);
  box-shadow: 0 18px 35px rgba(15,23,42,.12);
  opacity: 0;
  transform: translateY(14px) scale(.9);
  transition: opacity .25s ease, transform .25s ease;
}
.productChip.show{
  opacity: 1;
  transform: translateY(0) scale(1);
}

.miniExplain{
  margin-top: 12px;
  padding: 12px 12px;
  border-radius: 18px;
  background: rgba(59,130,246,.10);
  border: 1px dashed rgba(59,130,246,.22);
  color:#1e3a8a;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;
}

/* FX sparks */
.fx{position:absolute; inset:0; pointer-events:none;}
.spark{
  position:absolute;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(251,191,36,.95);
  box-shadow: 0 0 14px rgba(251,191,36,.65);
  animation: sparkUp .85s ease-out forwards;
}
@keyframes sparkUp{
  0%{ transform: translate(0,0) scale(1); opacity:1;}
  100%{ transform: translate(var(--dx), var(--dy)) scale(.2); opacity:0;}
}

/* Swap animation helpers */
.kickOut{
  animation: kickOut .55s ease forwards;
}
@keyframes kickOut{
  0%{ transform: translateX(0) scale(1); opacity:1;}
  60%{ transform: translateX(70px) translateY(-10px) rotate(10deg) scale(.95); opacity:1;}
  100%{ transform: translateX(110px) translateY(22px) rotate(18deg) scale(.85); opacity:0;}
}
.mergeIn{
  animation: mergeIn .55s ease forwards;
}
@keyframes mergeIn{
  0%{ transform: translateX(-16px) scale(.9); opacity:.5;}
  100%{ transform: translateX(0) scale(1); opacity:1;}
}
