🎮ArcadeLab

Organic Qualitative Analysis Lab

by SolarPhoenix81
77 lines13.8 KB
▶ Play
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Organic Qualitative Analysis Lab</title>
<style>
*{box-sizing:border-box}body{margin:0;font-family:Arial,Helvetica,sans-serif;background:#0f2040;color:#12233f}
header{background:#071426;color:#fff;padding:18px 20px;text-align:center}header h1{margin:0;font-size:26px}header p{margin:6px 0 0;opacity:.85}
.wrap{max-width:1080px;margin:0 auto;padding:16px}.card{background:#fff;border-radius:14px;padding:16px;margin-bottom:14px;box-shadow:0 6px 20px rgba(0,0,0,.2)}
.row{display:flex;gap:14px;flex-wrap:wrap}.col{flex:1;min-width:280px}
button{border:0;border-radius:10px;padding:10px 14px;cursor:pointer;font-weight:700;background:#0e9aa7;color:#fff;margin:4px 4px 4px 0}
button:hover{opacity:.9}.ghost{background:#eef2f7;color:#12233f}.danger{background:#e63946}.stage{padding:9px 11px;border-radius:10px;background:#eef2f7;cursor:pointer;margin:4px;display:inline-block;font-size:13px;font-weight:700}.stage.active{background:#0e9aa7;color:#fff}
.lab{display:flex;gap:16px;align-items:center;flex-wrap:wrap}.tube{width:110px;height:180px;border:4px solid #333;border-top:0;border-radius:0 0 50px 50px;position:relative;overflow:hidden;background:#f8f8f8}.liquid{position:absolute;bottom:0;left:0;right:0;height:65%;background:#4aa3ff;transition:background 1s}.bubbles{position:absolute;bottom:10px;width:100%;height:60px}.bubbles i{position:absolute;width:10px;height:10px;border-radius:50%;background:rgba(255,255,255,.8);animation:up 1.2s infinite}@keyframes up{from{transform:translateY(50px);opacity:0}to{transform:translateY(-40px);opacity:1}}
.precip{position:absolute;bottom:0;width:100%;height:0;background:#ffca3a;transition:height 1s}.mirror{position:absolute;inset:0;background:linear-gradient(135deg,#eee,#999,#fff);opacity:0;transition:.8s}.eq{background:#fff7d6;border-left:5px solid #ffb703;padding:10px;border-radius:8px;font-family:monospace;white-space:pre-wrap}table{width:100%;border-collapse:collapse}th,td{border:1px solid #ddd;padding:8px;text-align:left;font-size:14px}th{background:#0f2040;color:#fff}
.q{margin:12px 0}.opt{display:block;background:#eef2f7;padding:9px;border-radius:8px;margin:5px 0;cursor:pointer}.opt.correct{background:#c8f7c5}.opt.wrong{background:#ffd6d6}
.hidden{display:none}.badge{background:#ffd166;padding:4px 10px;border-radius:20px;font-weight:700;font-size:12px}
</style></head><body>
<header><h1>🧪 Organic Qualitative Analysis Lab</h1><p>Complete Qualitative Analysis • Click a stage • Run the test • Identify the unknown</p>
<p><span class="badge" id="progress">Progress: 0 / 8 tests</span> <span class="badge" id="sampleBadge">Sample: A — Unknown</span></p></header>
<div class="wrap">
<div class="card"><h2>1. Choose Your Unknown Sample</h2>
<button onclick="setSample('A')">Sample A</button><button onclick="setSample('B')">Sample B</button><button onclick="setSample('C')">Sample C</button>
<button class="ghost" onclick="resetAll()">🔄 Reset</button><button class="danger" onclick="replay()">▶ Replay</button>
<p id="sampleInfo"><b>Sample A selected.</b> It is a colourless liquid. Find its functional group using the tests below. <i>Teacher tip: Don't reveal answers — let students predict first!</i></p></div>

<div class="card"><h2>2. Click an Experimental Stage</h2><div id="stages"></div></div>

<div class="card row"><div class="col"><h2 id="stageTitle">Stage</h2><p><b>Aim:</b> <span id="aim"></span></p><p><b>Reagents:</b> <span id="reagents"></span></p><p><b>Procedure:</b> <span id="procedure"></span></p>
<button onclick="runTest()">▶ Run This Test</button><button class="ghost" onclick="nextStage()">Next Stage →</button>
<div class="eq" id="equation"></div><p id="explain"></p></div>
<div class="col"><h3>🔬 Observation</h3><div class="lab"><div class="tube"><div class="liquid" id="liquid"></div><div class="precip" id="precip"></div><div class="mirror" id="mirror"></div><div class="bubbles" id="bubbles"></div></div>
<div><h2 id="obsTitle">Ready</h2><p id="obsText">Click “Run This Test” to see colour change / precipitate.</p><p><b>Inference:</b> <span id="inference">—</span></p></div></div>
<p><b>⚠️ Safety:</b> Wear goggles + gloves. Use fume cupboard. Do not taste / smell directly.</p></div></div>

<div class="card"><h2>3. Results Table</h2><table><thead><tr><th>Test</th><th>Observation</th><th>Inference</th></tr></thead><tbody id="results"></tbody></table><h3 id="conclusion">Conclusion: Run tests to identify the compound.</h3></div>

<div class="card"><h2>4. 🎯 Audience Quiz — Click an answer!</h2><div id="quiz"></div><h3 id="score">Score: 0 / 5</h3><button onclick="resetQuiz()">Reset Quiz</button></div>
</div>
<script>
const SAMPLES={A:{name:"Ethanol (Alcohol)",group:"Alcohol (–OH)"},B:{name:"Acetaldehyde (Aldehyde)",group:"Aldehyde (–CHO)"},C:{name:"Benzoic Acid",group:"Carboxylic Acid (–COOH)"}};
let sample='A', current=0, done=new Set(), score=0, answered={};
const STAGES=[
{title:"1. Preliminary Tests",aim:"Check state, solubility & odour.",reagents:"Water, NaHCO₃, NaOH, dil. HCl",procedure:"Add a few drops to each solvent. Shake. Note solubility.",eq:"Soluble in NaHCO₃ → Acidic compound\nSoluble in NaOH → Phenol / Acid",explain:"Solubility hints at acidic / basic functional groups.",obs:{A:"Soluble in water. No effervescence.",B:"Soluble in water. Pungent odour.",C:"Insoluble in water. Soluble in NaHCO₃."},inf:{A:"Polar compound, not strong acid.",B:"Polar carbonyl compound.",C:"Carboxylic acid present."},color:"#4aa3ff",precip:0,mirror:0,bubbles:false},
{title:"2. Lassaigne's Test (N, S, Halogen)",aim:"Detect N, S, X in organic compound.",reagents:"Sodium metal, FeSO₄, FeCl₃, AgNO₃",procedure:"Fuse with Na → extract → test extract.",eq:"Na + C + N → NaCN\n2NaCN + FeSO₄ → Na₄[Fe(CN)₆]\n3Na₄[Fe(CN)₆] + 4FeCl₃ → Fe₄[Fe(CN)₆]₃ (Prussian Blue)",explain:"Sodium converts elements into ionic salts that are easy to test.",obs:{A:"No Prussian blue. No black precipitate.",B:"No Prussian blue.",C:"No Prussian blue."},inf:{A:"No N, S, halogen.",B:"No N, S, halogen.",C:"No N, S, halogen."},color:"#cfe8ff",precip:0,mirror:0,bubbles:false},
{title:"3. Bromine Water Test",aim:"Test for C=C / C≡C unsaturation.",reagents:"Bromine water (orange-brown)",procedure:"Add bromine water dropwise. Shake.",eq:"C=C + Br₂ → C(Br)–C(Br)  (addition)",explain:"Bromine adds across double bond, so orange colour disappears if unsaturated.",obs:{A:"Orange colour REMAINS.",B:"Orange colour REMAINS.",C:"Orange colour REMAINS."},inf:{A:"Saturated.",B:"Saturated (aldehyde, not alkene).",C:"Saturated."},color:"#ff9f1c",precip:0,mirror:0,bubbles:false},
{title:"4. Baeyer's Test (KMnO₄)",aim:"Confirm unsaturation.",reagents:"Cold dilute KMnO₄ (purple)",procedure:"Add 2 drops KMnO₄. Shake.",eq:"C=C + [O] + H₂O → Diol + MnO₂ (brown)",explain:"Purple KMnO₄ is decolourised and brown MnO₂ forms if unsaturated.",obs:{A:"Purple remains (no brown ppt).",B:"Purple remains.",C:"Purple remains."},inf:{A:"Saturated.",B:"Saturated.",C:"Saturated."},color:"#9b5de5",precip:0,mirror:0,bubbles:false},
{title:"5. Alcohol Test — Sodium + Iodoform",aim:"Test for –OH and CH₃–CHOH– group.",reagents:"Na metal, I₂ + NaOH",procedure:"Add Na → effervescence. Then I₂/NaOH → warm.",eq:"2R–OH + 2Na → 2R–ONa + H₂↑\nCH₃CHOH– + I₂/NaOH → CHI₃ (yellow ppt) + HCOONa",explain:"Alcohol gives H₂ with Na. Ethanol gives yellow iodoform.",obs:{A:"Brisk H₂ effervescence + YELLOW iodoform ppt!",B:"No H₂. No yellow ppt.",C:"H₂? No — acid gives CO₂ with NaHCO₃, not iodoform."},inf:{A:"Alcohol present, methyl alcohol group.",B:"No alcohol.",C:"No alcohol."},color:"#ffca3a",precip:35,mirror:0,bubbles:true},
{title:"6. Ferric Chloride Test — Phenol",aim:"Test for phenol.",reagents:"Neutral FeCl₃",procedure:"Add 2 drops FeCl₃ to sample.",eq:"6C₆H₅OH + FeCl₃ → [Fe(OC₆H₅)₆]³⁻ + 3H⁺ + 3Cl⁻\n(Violet complex)",explain:"Phenol forms violet complex. None of A/B/C is phenol, so this is a negative control.",obs:{A:"No violet colour.",B:"No violet colour.",C:"No violet colour."},inf:{A:"Not phenol.",B:"Not phenol.",C:"Not phenol."},color:"#ffe08a",precip:0,mirror:0,bubbles:false},
{title:"7. Tollens' + Fehling's — Aldehyde vs Ketone",aim:"Distinguish aldehyde from ketone.",reagents:"Tollens' reagent, Fehling's A+B",procedure:"Warm with Tollens' → mirror. Warm with Fehling's → red ppt.",eq:"R–CHO + 2[Ag(NH₃)₂]⁺ + 3OH⁻ → RCOO⁻ + 2Ag↓ + 4NH₃ + 2H₂O\nR–CHO + 2Cu²⁺ + 5OH⁻ → RCOO⁻ + Cu₂O↓ (brick-red) + 3H₂O",explain:"Only aldehydes are easily oxidised to give silver mirror + brick-red Cu₂O.",obs:{A:"No mirror. Fehling's stays blue.",B:"SILVER MIRROR + BRICK-RED ppt!",C:"No mirror. Fehling's stays blue."},inf:{A:"Not aldehyde.",B:"Aldehyde CONFIRMED.",C:"Not aldehyde."},color:"#ff595e",precip:40,mirror:1,bubbles:false},
{title:"8. NaHCO₃ Test — Carboxylic Acid",aim:"Test for –COOH.",reagents:"NaHCO₃ solution",procedure:"Add NaHCO₃. Watch for effervescence.",eq:"R–COOH + NaHCO₃ → RCOONa + CO₂↑ + H₂O",explain:"Only carboxylic acids are strong enough to release CO₂ from bicarbonate. Phenol does NOT.",obs:{A:"No effervescence.",B:"No effervescence.",C:"BRISK effervescence — CO₂ turns lime water milky!"},inf:{A:"Not carboxylic acid.",B:"Not carboxylic acid.",C:"Carboxylic acid CONFIRMED."},color:"#80ed99",precip:0,mirror:0,bubbles:true},
];
function renderStages(){document.getElementById('stages').innerHTML=STAGES.map((s,i)=>`<span class="stage ${i===current?'active':''} ${done.has(i)?'✅':''}" onclick="go(${i})">${s.title}</span>`).join('');showStage();}
function go(i){current=i;renderStages();}
function showStage(){let s=STAGES[current];document.getElementById('stageTitle').textContent=s.title;document.getElementById('aim').textContent=s.aim;document.getElementById('reagents').textContent=s.reagents;document.getElementById('procedure').textContent=s.procedure;document.getElementById('equation').textContent=s.eq;document.getElementById('explain').textContent=s.explain;document.getElementById('obsTitle').textContent="Ready — "+s.title;document.getElementById('obsText').textContent="Click Run This Test.";document.getElementById('inference').textContent="—";document.getElementById('liquid').style.background="#dbeafe";document.getElementById('precip').style.height="0";document.getElementById('mirror').style.opacity=0;document.getElementById('bubbles').innerHTML="";}
function runTest(){let s=STAGES[current];let isPositive=(current===4&&sample==='A')||(current===6&&sample==='B')||(current===7&&sample==='C');
document.getElementById('obsTitle').textContent=isPositive?"✅ POSITIVE":"❌ NEGATIVE";document.getElementById('obsText').textContent=s.obs[sample];document.getElementById('inference').textContent=s.inf[sample];
document.getElementById('liquid').style.background=s.color;
document.getElementById('precip').style.height=(isPositive?s.precip:0)+"px";
document.getElementById('mirror').style.opacity=(current===6&&sample==='B')?0.85:0;
document.getElementById('bubbles').innerHTML=s.bubbles&&isPositive?"<i style='left:20%'></i><i style='left:50%;animation-delay:.3s'></i><i style='left:75%;animation-delay:.6s'></i>":"";
done.add(current);renderResults();renderStages();document.getElementById('progress').textContent=`Progress: ${done.size} / 8 tests`;
if(done.size>=3){document.getElementById('conclusion').textContent="Conclusion so far: Likely "+SAMPLES[sample].group+" → "+SAMPLES[sample].name+" (confirm with all tests)";}}
function renderResults(){let rows="";STAGES.forEach((s,i)=>{if(done.has(i))rows+=`<tr><td>${s.title}</td><td>${s.obs[sample]}</td><td>${s.inf[sample]}</td></tr>`});document.getElementById('results').innerHTML=rows||"<tr><td colspan=3>No tests run yet.</td></tr>";}
function nextStage(){if(current<STAGES.length-1){current++;renderStages();}else alert("All stages done! Check Conclusion + Quiz.");}
function setSample(x){sample=x;document.getElementById('sampleBadge').textContent="Sample: "+x+" — Unknown";document.getElementById('sampleInfo').innerHTML=`<b>Sample ${x} selected.</b> Colourless liquid. Run tests to find its group.`;resetAll(false);}
function resetAll(clearSample=true){done.clear();current=0;document.getElementById('progress').textContent="Progress: 0 / 8 tests";document.getElementById('conclusion').textContent="Conclusion: Run tests to identify the compound.";renderResults();renderStages();}
function replay(){resetAll();alert("Replay started! Run tests again from Stage 1.");}
const QUIZ=[
{q:"Bromine water decolourises. What does it show?",o:["Unsaturation (C=C)","Carboxylic acid","Alcohol","Phenol"],a:0},
{q:"Silver mirror in Tollens' test means?",o:["Ketone","Aldehyde","Phenol","Alkene"],a:1},
{q:"Fehling's test gives brick-red ppt with?",o:["Ketone only","Aldehyde only","Alcohol only","Phenol only"],a:1},
{q:"NaHCO₃ brisk effervescence proves?",o:["Phenol","Alcohol","Carboxylic acid","Aldehyde"],a:2},
{q:"Violet colour with FeCl₃ means?",o:["Alcohol","Phenol","Acid","Aldehyde"],a:1},
];
function renderQuiz(){document.getElementById('quiz').innerHTML=QUIZ.map((qq,i)=>`<div class="q"><b>Q${i+1}. ${qq.q}</b>${qq.o.map((op,j)=>`<span class="opt" id="q${i}o${j}" onclick="answer(${i},${j},this)">${op}</span>`).join('')}</div>`).join('');}
function answer(i,j,el){if(answered[i]!==undefined)return;answered[i]=j;let correct=QUIZ[i].a;if(j===correct){el.classList.add('correct');score++;}else{el.classList.add('wrong');document.getElementById(`q${i}o${correct}`).classList.add('correct');}document.getElementById('score').textContent=`Score: ${score} / 5`;if(Object.keys(answered).length===5)alert(`Quiz done! Score ${score}/5. ${score>=4?"Excellent! 🎉":"Revise the stages and try again."}`);}
function resetQuiz(){score=0;answered={};document.getElementById('score').textContent="Score: 0 / 5";renderQuiz();}
renderStages();renderResults();renderQuiz();
</script></body></html>

Game Source: Organic Qualitative Analysis Lab

Creator: SolarPhoenix81

Libraries: none

Complexity: moderate (77 lines, 13.8 KB)

The full source code is displayed above on this page.

Remix Instructions

To remix this game, copy the source code above and modify it. Add a ARCADELAB header at the top with "remix_of: organic-qualitative-analysis-lab-solarphoenix81" to link back to the original. Then publish at arcadelab.ai/publish.