:root{
  --bg:#f7fbff;
  --card:#ffffff;
  --ink:#0f172a;
  --muted:#64748b;
  --blue:#3b82f6;
  --pink:#fb7185;
  --green:#22c55e;
  --shadow: 0 14px 35px rgba(15, 23, 42, .10);
  --radius: 18px;

  /* Water surface is where darker water starts:
     water::before height = 55% (from bottom)
     so surface is at 45% from top. */
  --water-surface: 80%;
}

*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(251,113,133,.14), transparent 40%),
    radial-gradient(circle at 85% 20%, rgba(59,130,246,.12), transparent 45%),
    radial-gradient(circle at 35% 95%, rgba(34,197,94,.10), transparent 45%),
    var(--bg);
  min-height:100vh;
}
.topbar{
  display:flex;
  align-items:center;
  gap:12px;
  padding:18px 16px 10px;
  max-width:1200px;
  margin:0 auto;
}
.back{
  text-decoration:none;
  background: rgba(15,23,42,.06);
  padding:10px 12px;
  border-radius:14px;
  color: var(--ink);
  font-weight:800;
}
.title h1{margin:0; font-size: clamp(22px, 3vw, 34px);}
.title p{margin:4px 0 0; color:var(--muted); font-size:14px;}

.wrap{max-width:1200px; margin:0 auto; padding:0 16px 28px;}
.card{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
  border: 1px solid rgba(15,23,42,.06);
}
.muted{color:var(--muted)}
.grid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}
@media(min-width:980px){ .grid{grid-template-columns: 1.1fr .9fr} }

.simHeader{
  display:flex;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.chips{display:flex; gap:8px; flex-wrap:wrap}
.chip{
  padding:8px 10px;
  border-radius:999px;
  background: rgba(251,113,133,.14);
  color:#9f1239;
  font-weight:900;
  font-size:12px;
}

.simArea{margin-top:10px;}
.scene{
  display:grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media(min-width:860px){
  .scene{grid-template-columns: 1.2fr .8fr}
}

.water{
  position:relative;
  height: 280px;
  border-radius: 18px;
  border: 1px solid rgba(59,130,246,.18);
  overflow:hidden;
  background: linear-gradient(180deg, rgba(59,130,246,.10), rgba(59,130,246,.20));
}
.water::before{
  content:"";
  position:absolute;
  inset:auto 0 0 0;
  height: 55%;
  background: linear-gradient(180deg, rgba(59,130,246,.30), rgba(59,130,246,.45));
}
.waterLabel{
  position:absolute;
  left: 12px;
  top: 12px;
  background: rgba(255,255,255,.75);
  padding: 7px 10px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 12px;
  border: 1px solid rgba(15,23,42,.06);
}

/* ✅ Balloon is now INSIDE water container and anchored to the surface */
.balloonWrap{
  position:absolute;
  left: 50%;
  top: var(--water-surface);
  transform: translate(-50%, -100%);
  display:grid;
  place-items:center;
  pointer-events:none;
}

.balloon{
  width: 92px;
  height: 120px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.65), transparent 35%),
              rgba(251,113,133,.65);
  border: 2px solid rgba(251,113,133,.45);
  box-shadow: 0 18px 36px rgba(15,23,42,.12);
  transition: transform .12s ease;
  transform-origin: 50% 100%; /* ✅ scale from bottom so it "sits" on surface */
}

.string{
  width: 3px;
  height: 70px;
  background: rgba(15,23,42,.20);
  border-radius: 999px;
  margin-top: 8px;
}

.tempPanel{
  display:grid;
  gap: 10px;
}
.meter{
  border-radius: 18px;
  padding: 12px;
  border: 1px solid rgba(15,23,42,.08);
  background: rgba(255,255,255,.85);
}
.meterTop{
  font-weight:900;
  font-size: 12px;
  color: var(--muted);
  text-transform:uppercase;
  letter-spacing:.08em;
}
.meterVal{margin-top:6px; font-size:22px; font-weight: 900;}
.meterHint{margin-top:2px; font-size:12px}

.controls{
  margin-top: 12px;
  border-top: 1px dashed rgba(15,23,42,.14);
  padding-top: 12px;
}
.label{font-weight:900}
input[type="range"]{width:100%; accent-color: var(--pink);}
.minmax{
  display:flex; justify-content:space-between;
  font-size:12px; color:var(--muted);
}

.btnRow{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top: 10px;
}
.btn{
  border:0;
  cursor:pointer;
  font-weight: 900;
  border-radius: 16px;
  padding: 10px 14px;
  background: rgba(251,113,133,.22);
  border: 1px solid rgba(251,113,133,.35);
}
.btn.ghost{
  background: rgba(15,23,42,.06);
  border: 1px solid rgba(15,23,42,.10);
}
.btn:active{transform: scale(.99)}
.note{margin:10px 0 0; color:var(--muted); font-size:13px;}

.graph canvas{
  width:100%;
  height:auto;
  border-radius: 16px;
  border: 1px solid rgba(15,23,42,.08);
  background: rgba(255,255,255,.9);
}
.legend{margin-top:8px; font-size:12px;}
