:root{
  --ink:#0f172a;
  --muted:#64748b;
  --bg1:#fff7ed;
  --bg2:#f6fbff;

  --shadow: 0 18px 45px rgba(15,23,42,.12);
  --shadow2: 0 10px 24px rgba(15,23,42,.10);
  --r:24px;

  --orange: rgba(251,146,60,.22);
  --red: rgba(239,68,68,.20);
  --blue: rgba(59,130,246,.18);
  --green: rgba(34,197,94,.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(251,146,60,.16), transparent 45%),
    radial-gradient(circle at 88% 18%, rgba(239,68,68,.14), transparent 45%),
    radial-gradient(circle at 30% 92%, rgba(59,130,246,.14), transparent 45%),
    radial-gradient(circle at 78% 92%, rgba(34,197,94,.12), transparent 45%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  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}

/* Compound */
.compoundStage{display:grid; gap:14px; place-items:center;}
.compound{
  width: 170px;
  height: 170px;
  border-radius: 46px;
  border: 1px solid rgba(15,23,42,.10);
  background: rgba(251,146,60,.12);
  box-shadow: 0 22px 45px rgba(15,23,42,.14);
  display:grid;
  place-items:center;
  position:relative;
  overflow:hidden;
  transform: translateY(0);
  transition: transform .18s ease, filter .18s ease;
}
.compoundText{
  font-weight: 1000;
  font-size: 44px;
  letter-spacing: .02em;
  z-index: 2;
}
.heatGlow{
  position:absolute;
  inset:-20%;
  background: radial-gradient(circle, rgba(239,68,68,.0), rgba(239,68,68,.0), rgba(251,146,60,.0));
  filter: blur(10px);
  opacity: .0;
  transition: opacity .2s ease;
}
.compound.heating .heatGlow{opacity: 1;}
.compound.shake{animation: shake .35s ease-in-out 1;}

@keyframes shake{
  0%{transform: translateX(0)}
  25%{transform: translateX(-6px) rotate(-2deg)}
  50%{transform: translateX(6px) rotate(2deg)}
  75%{transform: translateX(-4px) rotate(-1deg)}
  100%{transform: translateX(0)}
}

/* cracks */
.crack{
  position:absolute;
  width: 120px;
  height: 2px;
  background: rgba(15,23,42,.35);
  border-radius: 999px;
  opacity: 0;
  transform: rotate(0deg);
  z-index: 3;
  transition: opacity .2s ease;
}
.c1{ top: 55%; left: 18%; transform: rotate(25deg); }
.c2{ top: 48%; left: 22%; transform: rotate(-18deg); width: 110px; }
.c3{ top: 62%; left: 26%; transform: rotate(10deg); width: 95px; }

.compound.cracked .crack{opacity: .9;}

/* Thermo */
.thermo{
  width:100%;
  padding:12px 12px;
  border-radius: 20px;
  background: rgba(59,130,246,.08);
  border: 1px dashed rgba(59,130,246,.22);
}
.thermoTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.thermoLabel{
  font-weight: 1000;
  font-size: 12px;
  color:#1e3a8a;
}
.thermoValue{
  font-size: 12px;
  color:#1e3a8a;
  font-weight: 900;
}
input[type=range]{width:100%;}
.thermoHint{
  margin-top:8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  text-align:center;
}

/* Reaction zone */
.actionCard{position:relative}
.reactionZone{
  position:relative;
  height: 240px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(239,68,68,.10), rgba(59,130,246,.06));
  border: 1px solid rgba(15,23,42,.08);
  display:grid;
  place-items:center;
  text-align:center;
  overflow:hidden;
}
.zoneText{
  color: var(--muted);
  font-weight: 1000;
  line-height: 1.15;
}
.zoneText small{font-weight:900; opacity:.85;}

.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(239,68,68,.16);
  border-color: rgba(239,68,68,.20);
  color:#7f1d1d;
}
.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;
}

/* smoke */
.fx.smoke{
  position:absolute;
  top: 30px;
  width: 200px;
  height: 200px;
  opacity: 0;
  transition: opacity .2s ease;
  pointer-events:none;
}
.reactionZone.on .fx.smoke{opacity:.28;}
.fx.smoke::before, .fx.smoke::after{
  content:"";
  position:absolute;
  inset:0;
  background:
    radial-gradient(circle at 30% 70%, rgba(255,255,255,.95), transparent 40%),
    radial-gradient(circle at 55% 45%, rgba(255,255,255,.85), transparent 45%),
    radial-gradient(circle at 70% 80%, rgba(255,255,255,.9), transparent 40%);
  filter: blur(1px);
  animation: floaty 1.5s ease-in-out infinite;
}
.fx.smoke::after{opacity:.8; animation-delay:.3s;}
@keyframes floaty{
  0%{ transform: translateY(14px) scale(.95); opacity:.22;}
  50%{ transform: translateY(-10px) scale(1.05); opacity:.55;}
  100%{ transform: translateY(14px) scale(.95); opacity:.22;}
}

/* sparks */
.fx.sparks{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;}
}

/* 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:86px;height:86px;
  border-radius: 26px;
  display:grid;
  place-items:center;
  font-weight: 1000;
  font-size: 34px;
  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(34,197,94,.10);
  border: 1px dashed rgba(34,197,94,.22);
  color:#14532d;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.3;
}
