:root{
  --bg:#0f1724;
  --panel:#0b1220;
  --accent:#2dd4bf;
  --title:#7dd3fc;
  --muted:#93c5fd;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
    margin:0;
    font-family:Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    background: radial-gradient( circle at 10% 10%, rgba(45,212,191,0.06), transparent 10%),
                linear-gradient(180deg, rgba(10,14,23,1) 0%, rgba(6,10,17,1) 100%);
    color:#e6eef8;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:40px 20px;
    background-image: url("./lab_background.jpg");
    background-size: cover;        /* fills entire screen */
    background-position: center;   /* centers image */
    background-repeat: no-repeat;  /* prevents tiling */
    background-attachment: fixed;  /* subtle parallax effect */
}
.center{display:flex;flex-direction:column;align-items:center;width:100%;max-width:1100px}

.title{
  margin:0 10px 30px 0;
  font-weight:800;
  line-height:1;
  text-align:center;
  color:var(--title);
  font-size:clamp(36px, 8vw, 96px);
  font-family: "math", monospace, serif;
  letter-spacing: -0.02em;
  text-shadow: 0 6px 18px rgba(45,212,191,0.06), 0 2px 6px rgba(2,6,23,0.6);
}

.sim-area{
  margin-top:28px;
  display:flex;
  gap:20px;
  align-items:flex-start;
  width:100%;
  justify-content:center;
}

.right-panel{
  display:flex;
  flex-direction:row;
  gap:20px;
  flex-shrink:0;
  position:relative;
  z-index:10;
}

.sim-canvas{
  width:50vw;
  aspect-ratio:1/1;
  background: linear-gradient(180deg, rgba(12,18,28,0.95), rgba(8,12,18,0.9));
  border-radius:28px;
  border:1px solid rgba(125,211,252,0.06);
  box-shadow: 0 12px 40px rgba(2,6,23,0.7), inset 0 1px 0 rgba(255,255,255,0.02);
  display:block;
  max-width:100%;
  height:50vw;
  cursor:crosshair;
  flex-shrink:0;
  position: relative;
}

@media (max-width:520px){
  .title{font-size:32px}
  .sim-area{
    flex-direction:column;
    aspect-ratio:auto;
  }
  .sim-canvas{
    width:100%;
    height:auto;
    aspect-ratio:1/1;
  }
  .right-panel{
    flex-direction:column;
    width:100%;
  }
  .element-counter,
  .molecules-panel{
    width:100%;
    max-height:200px;
  }
}

/* Particle (simulation entity) styles */
.particle{
  position:absolute;
  width:18px;
  height:18px;
  border-radius:50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), rgba(45,212,191,0.18));
  box-shadow: 0 6px 14px rgba(2,6,23,0.6), inset 0 -4px 12px rgba(255,255,255,0.04);
  transform: translate(-50%,-50%);
  pointer-events: auto;
  transition: transform 0.12s linear, opacity 0.2s;
}

.particle.small{width:12px;height:12px}
.particle.large{width:28px;height:28px}

#sim-canvas{
  border: 3px solid #7dd3fc;
  width: 600px;
  height: 600px;
}

.element-counter,
.molecules-panel{
  background: linear-gradient(180deg, rgba(12,18,28,0.95), rgba(8,12,18,0.9));
  border-radius:28px;
  border:1px solid rgba(125,211,252,0.06);
  box-shadow: 0 12px 40px rgba(2,6,23,0.7), inset 0 1px 0 rgba(255,255,255,0.02);
  padding:24px;
  width: 200px;
  max-height:600px;
  overflow-y:auto;
  flex-shrink:0;
}

.element-counter h3,
.molecules-panel h3{
  margin:0 0 16px 0;
  color:var(--title);
  font-size:16px;
  font-weight:600;
  text-align:center;
}

.counter-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.counter-item{
  display:flex;
  align-items:center;
  padding:8px 12px;
  background:rgba(125,211,252,0.05);
  border-radius:8px;
  border:1px solid rgba(125,211,252,0.1);
  font-size:13px;
  font-weight:500;
  gap:4px;
}

.counter-item .element-name{
  color:var(--muted);
}

.counter-item .element-count{
  color:var(--accent);
  font-weight:700;
  min-width:30px;
  text-align:right;
  margin-left:auto;
}

.molecules-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.molecule-item{
  display:flex;
  flex-direction:column;
  padding:12px;
  background:rgba(125,211,252,0.05);
  border-radius:8px;
  border:1px solid rgba(125,211,252,0.1);
  font-size:13px;
  font-weight:500;
  cursor:pointer;
  transition: all 0.2s ease;
}

.molecule-item:hover{
  background:rgba(125,211,252,0.1);
  border-color:rgba(125,211,252,0.2);
}

.molecule-item.locked{
  opacity:0.5;
  cursor:not-allowed;
}

.molecule-name{
  color:var(--muted);
  font-weight:600;
}

.molecule-status{
  color:var(--accent);
  font-size:12px;
  margin-top:4px;
}

 .molecule-item.disappear {
   animation: molecule-shrink-disappear 1s linear forwards;
 }
 @keyframes molecule-shrink-disappear {
   0% { opacity: 1; transform: scale(1); }
   80% { opacity: 0.5; transform: scale(0.5); }
   100% { opacity: 0; transform: scale(0); display: none; }
 }

/* upgrade panel */

.upgrades-panel{
  background: linear-gradient(180deg, rgba(12,18,28,0.95), rgba(8,12,18,0.9));
  border-radius:28px;
  border:1px solid rgba(125,211,252,0.06);
  box-shadow: 0 12px 40px rgba(2,6,23,0.7), inset 0 1px 0 rgba(255,255,255,0.02);
  padding:24px;
  width: 220px;         /* tweak as you want */
  max-height:600px;
  overflow-y:auto;
  flex-shrink:0;
  position:relative;
  z-index:20;
  pointer-events:auto;
}

.upgrades-panel h3{
  margin:0 0 16px 0;
  color:var(--title);
  font-size:16px;
  font-weight:600;
  text-align:center;
}

.upgrades-list{
  display:flex;
  flex-direction:column;
  gap:10px;
  position:relative;
  pointer-events:auto;
}

/* Each upgrade entry is a button */
.upgrade-btn{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  pointer-events: auto;

  width:100%;
  padding:10px 12px;
  border-radius:10px;

  background:rgba(125,211,252,0.05);
  border:1px solid rgba(125,211,252,0.12);
  color:#e6eef8;

  font-size:13px;
  font-weight:600;

  cursor:pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.05s ease;
}

.upgrade-btn:hover{
  background:rgba(125,211,252,0.10);
  border-color:rgba(125,211,252,0.22);
}

.upgrade-btn:active{
  transform: translateY(1px);
}

.upgrade-btn:disabled{
  opacity:0.45;
  cursor:not-allowed;
}

.upgrade-btn.unaffordable {
  opacity: 0.45;
  cursor: not-allowed;
}

.upgrade-name{
  color:var(--muted);
  font-weight:600;
}

.upgrade-cost{
  color:var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight:800;
}

#element-tooltip-overlay{
  position:fixed;
  inset:0;
  background:rgba(2,6,23,0.72);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
}

.element-tooltip-card{
  width:min(460px, 92vw);
  background:linear-gradient(180deg, rgba(12,18,28,0.98), rgba(8,12,18,0.96));
  border-radius:18px;
  border:1px solid rgba(125,211,252,0.10);
  box-shadow:0 20px 70px rgba(2,6,23,0.8);
  padding:18px 18px 14px 18px;
}

.element-tooltip-title{
  font-weight:800;
  font-size:18px;
  color:#e6eef8;
  margin-bottom:8px;
}

.element-tooltip-desc{
  color:#93c5fd;
  font-size:13px;
  line-height:1.4;
  margin-bottom:14px;
}

.element-tooltip-close{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(45,212,191,0.25);
  background:rgba(45,212,191,0.12);
  color:#e6eef8;
  font-weight:700;
  cursor:pointer;
}
.element-tooltip-close:hover{
  background:rgba(45,212,191,0.18);
}

/* ===== Make Collect + Add Amount + Spawn buttons match Upgrade buttons ===== */

#collect-all-btn,
#spawn-amount-btn,
.spawn-btn {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;

  width:100%;
  padding:10px 12px;
  border-radius:10px;

  background:rgba(125,211,252,0.05);
  border:1px solid rgba(125,211,252,0.12);
  color:#e6eef8;

  font-size:13px;
  font-weight:600;

  cursor:pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.05s ease;
}

#collect-all-btn:hover,
#spawn-amount-btn:hover,
.spawn-btn:hover{
  background:rgba(125,211,252,0.10);
  border-color:rgba(125,211,252,0.22);
}

#collect-all-btn:active,
#spawn-amount-btn:active,
.spawn-btn:active{
  transform: translateY(1px);
}

#collect-all-btn:disabled,
#spawn-amount-btn:disabled,
.spawn-btn:disabled{
  opacity:0.45;
  cursor:not-allowed;
}

/* keep your unaffordable class behavior consistent */
.spawn-btn.unaffordable{
  opacity:0.45;
  cursor:not-allowed;
}

.control-buttons{
  display:flex;
  flex-direction:column;
  gap:10px;
  margin-bottom:14px;
}

.counter-add-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.counter-add-row{
  display:flex;
  gap:10px;
  align-items:center;
}

.counter-add-row .spawn-btn{
  width:92px;        /* fixed so it lines up */
  flex-shrink:0;
  justify-content:space-between;
}

.counter-add-row .counter-item{
  flex:1;            /* counter takes remaining space */
}
