Here’s the full, production‑ready code (HTML, CSS, JS) for your NEET exam simulator app.
---
## 1) `index.html`
```html
NEET UG Previous Year Question Paper Simulator
```
---
## 2) `style.css`
```css
:root {
--bg: #f5f7fb;
--bg-alt: #ffffff;
--text: #1f2933;
--muted: #6b7280;
--primary: #2563eb;
--primary-dark: #1d4ed8;
--secondary: #4b5563;
--border: #e5e7eb;
--danger: #dc2626;
--warning: #f59e0b;
--success: #16a34a;
--palette-attempted: #22c55e;
--palette-not-attempted: #ef4444;
--palette-review: #3b82f6;
--palette-not-visited: #ffffff;
--palette-current-border: #facc15;
--shadow-soft: 0 10px 25px rgba(15, 23, 42, 0.08);
}
.app.dark-mode {
--bg: #020617;
--bg-alt: #020617;
--text: #e5e7eb;
--muted: #9ca3af;
--primary: #60a5fa;
--primary-dark: #3b82f6;
--secondary: #9ca3af;
--border: #1f2937;
--danger: #f87171;
--warning: #fbbf24;
--success: #4ade80;
--palette-attempted: #22c55e;
--palette-not-attempted: #ef4444;
--palette-review: #3b82f6;
--palette-not-visited: #020617;
--palette-current-border: #facc15;
}
/* Global */
*,
*::before,
*::after {
box-sizing: border-box;
}
html,
body {
margin: 0;
padding: 0;
height: 100%;
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
background: var(--bg);
color: var(--text);
}
body {
-webkit-font-smoothing: antialiased;
}
.app {
min-height: 100vh;
display: flex;
flex-direction: column;
}
/* Top Bar */
.top-bar {
position: sticky;
top: 0;
z-index: 50;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 1.25rem;
background: var(--bg-alt);
border-bottom: 1px solid var(--border);
}
.exam-title {
font-weight: 600;
font-size: 0.95rem;
}
.top-bar-right {
display: flex;
align-items: center;
gap: 0.75rem;
}
.timer {
font-weight: 600;
color: var(--danger);
}
/* Screens */
.screen {
display: none;
padding: 1.25rem;
}
.screen.active {
display: block;
}
/* Instructions */
.instructions-card {
max-width: 720px;
margin: 2rem auto;
padding: 1.75rem;
background: var(--bg-alt);
border-radius: 0.75rem;
box-shadow: var(--shadow-soft);
border: 1px solid var(--border);
}
.instructions-card h1 {
margin-top: 0;
margin-bottom: 1rem;
font-size: 1.5rem;
}
.instructions-list {
margin: 0 0 1rem;
padding-left: 1.25rem;
color: var(--muted);
}
.instructions-list li {
margin-bottom: 0.35rem;
}
.note {
font-size: 0.9rem;
color: var(--danger);
margin-bottom: 1.25rem;
}
/* Layout */
.exam-layout {
display: grid;
grid-template-columns: 2fr 1fr;
gap: 1rem;
}
.left-panel,
.right-panel {
background: var(--bg-alt);
border-radius: 0.75rem;
border: 1px solid var(--border);
box-shadow: var(--shadow-soft);
padding: 1rem;
}
/* Left Panel */
.exam-info {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.75rem;
border-bottom: 1px solid var(--border);
padding-bottom: 0.5rem;
}
.exam-name {
font-weight: 600;
}
.exam-meta {
font-size: 0.85rem;
color: var(--muted);
display: flex;
gap: 0.75rem;
}
.question-area {
margin-top: 0.5rem;
}
.question-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
#questionNumberLabel {
font-weight: 600;
}
.subject-tag {
font-size: 0.75rem;
padding: 0.15rem 0.5rem;
border-radius: 999px;
background: rgba(37, 99, 235, 0.1);
color: var(--primary);
}
.question-text {
padding: 0.75rem;
border-radius: 0.5rem;
background: rgba(148, 163, 184, 0.08);
margin-bottom: 0.75rem;
min-height: 80px;
}
/* Options */
.options-list {
display: grid;
gap: 0.5rem;
}
.option-item {
display: flex;
align-items: flex-start;
gap: 0.5rem;
padding: 0.5rem 0.6rem;
border-radius: 0.5rem;
border: 1px solid var(--border);
cursor: pointer;
transition: background 0.15s, border-color 0.15s;
}
.option-item input[type="radio"] {
margin-top: 0.2rem;
}
.option-label {
font-weight: 600;
margin-right: 0.25rem;
}
.option-item:hover {
background: rgba(37, 99, 235, 0.04);
border-color: var(--primary);
}
/* Question Actions */
.question-actions {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 1rem;
}
/* Right Panel */
.palette-header h2 {
margin: 0 0 0.5rem;
font-size: 1rem;
}
.subject-tabs {
display: flex;
flex-wrap: wrap;
gap: 0.25rem;
margin-bottom: 0.75rem;
}
.subject-tab {
flex: 1;
min-width: 0;
padding: 0.35rem 0.5rem;
font-size: 0.75rem;
border-radius: 999px;
border: 1px solid var(--border);
background: transparent;
color: var(--muted);
cursor: pointer;
}
.subject-tab.active {
background: var(--primary);
color: #fff;
border-color: var(--primary);
}
.palette-container {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 0.35rem;
max-height: 320px;
overflow-y: auto;
padding-right: 0.25rem;
}
.palette-btn {
position: relative;
width: 100%;
padding: 0.35rem 0;
font-size: 0.7rem;
border-radius: 0.35rem;
border: 1px solid var(--border);
background: var(--palette-not-visited);
color: var(--text);
cursor: pointer;
}
.palette-btn.current {
box-shadow: 0 0 0 2px var(--palette-current-border);
}
.palette-btn.attempted {
background: var(--palette-attempted);
color: #fff;
}
.palette-btn.not-attempted {
background: var(--palette-not-attempted);
color: #fff;
}
.palette-btn.review {
background: var(--palette-review);
color: #fff;
}
/* Legend */
.palette-legend {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.35rem;
font-size: 0.7rem;
margin-top: 0.75rem;
color: var(--muted);
}
.legend-box {
display: inline-block;
width: 12px;
height: 12px;
border-radius: 2px;
margin-right: 0.25rem;
border: 1px solid var(--border);
}
.legend-attempted {
background: var(--palette-attempted);
}
.legend-not-attempted {
background: var(--palette-not-attempted);
}
.legend-review {
background: var(--palette-review);
}
.legend-not-visited {
background: var(--palette-not-visited);
}
.legend-current {
border-color: var(--palette-current-border);
}
/* Palette Footer */
.palette-footer {
margin-top: 0.75rem;
border-top: 1px solid var(--border);
padding-top: 0.75rem;
}
.progress-wrapper {
margin-bottom: 0.5rem;
}
.progress-bar {
width: 100%;
height: 6px;
border-radius: 999px;
background: rgba(148, 163, 184, 0.3);
overflow: hidden;
}
.progress-fill {
height: 100%;
width: 0%;
background: var(--primary);
transition: width 0.2s;
}
.progress-text {
font-size: 0.75rem;
color: var(--muted);
margin-top: 0.25rem;
}
/* Buttons */
.btn {
border-radius: 0.5rem;
border: none;
padding: 0.45rem 0.9rem;
font-size: 0.85rem;
cursor: pointer;
font-weight: 500;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.25rem;
}
.btn.primary {
background: var(--primary);
color: #fff;
}
.btn.primary:hover {
background: var(--primary-dark);
}
.btn.secondary {
background: rgba(148, 163, 184, 0.15);
color: var(--secondary);
}
.btn.secondary:hover {
background: rgba(148, 163, 184, 0.25);
}
.btn.warning {
background: rgba(245, 158, 11, 0.15);
color: var(--warning);
}
.btn.warning:hover {
background: rgba(245, 158, 11, 0.25);
}
.btn.ghost {
background: transparent;
border: 1px solid var(--border);
color: var(--muted);
}
.btn.ghost:hover {
background: rgba(148, 163, 184, 0.1);
}
.btn.small {
padding: 0.25rem 0.6rem;
font-size: 0.75rem;
}
.btn.large {
padding: 0.6rem 1.2rem;
font-size: 0.95rem;
}
.btn.full-width {
width: 100%;
}
/* Modal */
.modal {
position: fixed;
inset: 0;
background: rgba(15, 23, 42, 0.55);
display: none;
align-items: center;
justify-content: center;
z-index: 100;
}
.modal.show {
display: flex;
}
.modal-content {
background: var(--bg-alt);
border-radius: 0.75rem;
padding: 1.25rem 1.5rem;
max-width: 420px;
width: 100%;
box-shadow: var(--shadow-soft);
border: 1px solid var(--border);
}
.modal-content h2 {
margin-top: 0;
}
.modal-actions {
display: flex;
justify-content: flex-end;
gap: 0.5rem;
margin-top: 1rem;
}
/* Results */
.results-wrapper {
max-width: 1100px;
margin: 1.5rem auto;
}
.results-wrapper h1 {
margin-top: 0;
margin-bottom: 1rem;
}
.results-grid {
display: grid;
grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
gap: 1rem;
margin-bottom: 1rem;
}
.card {
background: var(--bg-alt);
border-radius: 0.75rem;
border: 1px solid var(--border);
box-shadow: var(--shadow-soft);
padding: 1rem;
}
.stats-list {
list-style: none;
padding-left: 0;
margin: 0;
font-size: 0.9rem;
}
.stats-list li {
display: flex;
justify-content: space-between;
margin-bottom: 0.35rem;
}
.subject-analysis {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 0.75rem;
font-size: 0.9rem;
}
.answer-review {
margin-top: 1rem;
}
.answer-review-container {
max-height: 420px;
overflow-y: auto;
display: grid;
gap: 0.75rem;
padding-right: 0.25rem;
}
.review-question {
border-radius: 0.5rem;
border: 1px solid var(--border);
padding: 0.75rem;
background: rgba(148, 163, 184, 0.05);
}
.review-question-header {
display: flex;
justify-content: space-between;
font-size: 0.85rem;
margin-bottom: 0.35rem;
}
.review-question-text {
font-size: 0.9rem;
margin-bottom: 0.5rem;
}
.review-options {
display: grid;
gap: 0.25rem;
font-size: 0.85rem;
}
.review-option {
padding: 0.25rem 0.4rem;
border-radius: 0.35rem;
border: 1px solid transparent;
}
.review-option.correct {
background: rgba(22, 163, 74, 0.15);
border-color: var(--success);
}
.review-option.user-wrong {
background: rgba(220, 38, 38, 0.15);
border-color: var(--danger);
}
.review-option.correct-answer-border {
border-color: var(--success);
}
.review-explanation {
margin-top: 0.4rem;
font-size: 0.8rem;
color: var(--muted);
}
/* Responsive */
@media (max-width: 960px) {
.exam-layout {
grid-template-columns: 1.6fr 1.1fr;
}
}
@media (max-width: 768px) {
.screen {
padding: 0.75rem;
}
.exam-layout {
grid-template-columns: 1fr;
}
.right-panel {
order: -1;
}
.palette-container {
grid-template-columns: repeat(8, 1fr);
}
.results-grid {
grid-template-columns: 1fr;
}
}
@media (max-width: 480px) {
.top-bar {
flex-direction: column;
align-items: flex-start;
gap: 0.35rem;
}
.palette-container {
grid-template-columns: repeat(6, 1fr);
}
.question-actions {
flex-direction: column;
}
}
```
---
## 3) `app.js`
```javascript
// ====== CONFIG ======
const TOTAL_QUESTIONS = 180;
const DURATION_MINUTES = 180;
const MARK_CORRECT = 4;
const MARK_WRONG = -1;
// Question structure example; replace with real NEET questions.
function generateQuestions() {
const questions = [];
for (let i = 1; i <= TOTAL_QUESTIONS; i++) {
let subject = "";
if (i <= 45) subject = "Physics";
else if (i <= 90) subject = "Chemistry";
else subject = "Biology";
questions.push({
id: i,
subject,
text: `Sample Question ${i} (${subject}). Replace this with real NEET question text.`,
options: [
`Option A for Q${i}`,
`Option B for Q${i}`,
`Option C for Q${i}`,
`Option D for Q${i}`
],
correctIndex: Math.floor(Math.random() * 4), // replace with real correct index
explanation: `Explanation for Question ${i}. Replace with detailed solution.`
});
}
return questions;
}
const questions = generateQuestions();
// ====== STATE ======
let currentQuestionIndex = 0; // 0-based
let answers = {}; // { questionId: { selectedIndex, markedForReview, visited } }
let examStarted = false;
let examSubmitted = false;
let timerInterval = null;
let remainingSeconds = DURATION_MINUTES * 60;
let startTimestamp = null;
// ====== DOM ELEMENTS ======
const instructionsScreen = document.getElementById("instructionsScreen");
const examScreen = document.getElementById("examScreen");
const resultScreen = document.getElementById("resultScreen");
const startExamBtn = document.getElementById("startExamBtn");
const timerEl = document.getElementById("timer");
const subjectLabel = document.getElementById("subjectLabel");
const questionCounter = document.getElementById("questionCounter");
const questionNumberLabel = document.getElementById("questionNumberLabel");
const questionSubjectLabel = document.getElementById("questionSubjectLabel");
const questionTextEl = document.getElementById("questionText");
const optionsForm = document.getElementById("optionsForm");
const prevBtn = document.getElementById("prevBtn");
const nextBtn = document.getElementById("nextBtn");
const markReviewBtn = document.getElementById("markReviewBtn");
const clearResponseBtn = document.getElementById("clearResponseBtn");
const paletteContainer = document.getElementById("paletteContainer");
const subjectTabs = document.querySelectorAll(".subject-tab");
const progressFill = document.getElementById("progressFill");
const progressText = document.getElementById("progressText");
const submitExamBtn = document.getElementById("submitExamBtn");
const submitModal = document.getElementById("submitModal");
const confirmSubmitBtn = document.getElementById("confirmSubmitBtn");
const cancelSubmitBtn = document.getElementById("cancelSubmitBtn");
const resTotalQuestions = document.getElementById("resTotalQuestions");
const resAttempted = document.getElementById("resAttempted");
const resUnattempted = document.getElementById("resUnattempted");
const resCorrect = document.getElementById("resCorrect");
const resWrong = document.getElementById("resWrong");
const resMarks = document.getElementById("resMarks");
const resPercentage = document.getElementById("resPercentage");
const resTimeTaken = document.getElementById("resTimeTaken");
const phyCorrect = document.getElementById("phyCorrect");
const phyWrong = document.getElementById("phyWrong");
const phyMarks = document.getElementById("phyMarks");
const chemCorrect = document.getElementById("chemCorrect");
const chemWrong = document.getElementById("chemWrong");
const chemMarks = document.getElementById("chemMarks");
const bioCorrect = document.getElementById("bioCorrect");
const bioWrong = document.getElementById("bioWrong");
const bioMarks = document.getElementById("bioMarks");
const answerReviewContainer = document.getElementById("answerReviewContainer");
const toggleThemeBtn = document.getElementById("toggleThemeBtn");
const fullscreenBtn = document.getElementById("fullscreenBtn");
const appRoot = document.getElementById("app");
// ====== LOCAL STORAGE KEYS ======
const STORAGE_KEY = "neet_exam_state_v1";
// ====== INIT ======
loadStateFromStorage();
renderPalette();
renderQuestion();
updateProgressBar();
updateTimerDisplay();
// ====== EVENT LISTENERS ======
startExamBtn.addEventListener("click", () => {
if (examStarted) return;
examStarted = true;
startTimestamp = Date.now();
saveStateToStorage();
showScreen("exam");
startTimer();
});
prevBtn.addEventListener("click", () => {
if (currentQuestionIndex > 0) {
currentQuestionIndex--;
renderQuestion();
renderPalette();
}
});
nextBtn.addEventListener("click", () => {
if (currentQuestionIndex < TOTAL_QUESTIONS - 1) {
currentQuestionIndex++;
renderQuestion();
renderPalette();
}
});
markReviewBtn.addEventListener("click", () => {
const q = questions[currentQuestionIndex];
const state = getAnswerState(q.id);
state.markedForReview = !state.markedForReview;
setAnswerState(q.id, state);
renderPalette();
saveStateToStorage();
});
clearResponseBtn.addEventListener("click", () => {
const q = questions[currentQuestionIndex];
const state = getAnswerState(q.id);
state.selectedIndex = null;
state.markedForReview = false;
setAnswerState(q.id, state);
const selected = optionsForm.querySelector("input[name='option']:checked");
if (selected) selected.checked = false;
renderPalette();
updateProgressBar();
saveStateToStorage();
});
optionsForm.addEventListener("change", (e) => {
if (e.target.name === "option") {
const selectedIndex = parseInt(e.target.value, 10);
const q = questions[currentQuestionIndex];
const state = getAnswerState(q.id);
state.selectedIndex = selectedIndex;
state.visited = true;
setAnswerState(q.id, state);
renderPalette();
updateProgressBar();
saveStateToStorage();
}
});
subjectTabs.forEach((tab) => {
tab.addEventListener("click", () => {
subjectTabs.forEach((t) => t.classList.remove("active"));
tab.classList.add("active");
renderPalette(tab.dataset.subject);
});
});
submitExamBtn.addEventListener("click", () => {
if (!examStarted || examSubmitted) return;
openSubmitModal();
});
confirmSubmitBtn.addEventListener("click", () => {
closeSubmitModal();
submitExam();
});
cancelSubmitBtn.addEventListener("click", () => {
closeSubmitModal();
});
toggleThemeBtn.addEventListener("click", () => {
appRoot.classList.toggle("dark-mode");
toggleThemeBtn.textContent = appRoot.classList.contains("dark-mode")
? "Light Mode"
: "Dark Mode";
});
fullscreenBtn.addEventListener("click", () => {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen().catch(() => {});
} else {
document.exitFullscreen().catch(() => {});
}
});
// Warn on accidental refresh/close during exam
window.addEventListener("beforeunload", (e) => {
if (examStarted && !examSubmitted) {
e.preventDefault();
e.returnValue = "";
}
});
// ====== FUNCTIONS ======
function showScreen(name) {
instructionsScreen.classList.remove("active");
examScreen.classList.remove("active");
resultScreen.classList.remove("active");
if (name === "instructions") instructionsScreen.classList.add("active");
if (name === "exam") examScreen.classList.add("active");
if (name === "result") resultScreen.classList.add("active");
}
function renderQuestion() {
const q = questions[currentQuestionIndex];
const state = getAnswerState(q.id);
subjectLabel.textContent = `Subject: ${q.subject}`;
questionCounter.textContent = `Question ${q.id} of ${TOTAL_QUESTIONS}`;
questionNumberLabel.textContent = `Q. ${q.id}`;
questionSubjectLabel.textContent = q.subject;
questionTextEl.textContent = q.text;
optionsForm.innerHTML = "";
q.options.forEach((opt, idx) => {
const id = `q${q.id}_opt${idx}`;
const wrapper = document.createElement("label");
wrapper.className = "option-item";
const radio = document.createElement("input");
radio.type = "radio";
radio.name = "option";
radio.value = idx;
radio.id = id;
if (state.selectedIndex === idx) {
radio.checked = true;
}
const labelSpan = document.createElement("span");
labelSpan.className = "option-label";
labelSpan.textContent = String.fromCharCode(65 + idx) + ".";
const textSpan = document.createElement("span");
textSpan.textContent = opt;
wrapper.appendChild(radio);
wrapper.appendChild(labelSpan);
wrapper.appendChild(textSpan);
optionsForm.appendChild(wrapper);
});
// Mark as visited
state.visited = true;
setAnswerState(q.id, state);
renderPalette();
saveStateToStorage();
}
function renderPalette(filterSubject) {
const activeSubject =
filterSubject ||
document.querySelector(".subject-tab.active")?.dataset.subject ||
"Physics";
paletteContainer.innerHTML = "";
questions.forEach((q, index) => {
if (q.subject !== activeSubject) return;
const state = getAnswerState(q.id);
const btn = document.createElement("button");
btn.className = "palette-btn";
btn.textContent = q.id;
if (state.selectedIndex !== null) {
btn.classList.add("attempted");
} else if (state.visited) {
btn.classList.add("not-attempted");
}
if (state.markedForReview) {
btn.classList.remove("attempted", "not-attempted");
btn.classList.add("review");
}
if (!state.visited && state.selectedIndex === null && !state.markedForReview) {
// default not visited style
}
if (index === currentQuestionIndex) {
btn.classList.add("current");
}
btn.addEventListener("click", () => {
currentQuestionIndex = q.id - 1;
renderQuestion();
renderPalette(activeSubject);
});
paletteContainer.appendChild(btn);
});
}
function getAnswerState(questionId) {
if (!answers[questionId]) {
answers[questionId] = {
selectedIndex: null,
markedForReview: false,
visited: false
};
}
return { ...answers[questionId] };
}
function setAnswerState(questionId, state) {
answers[questionId] = { ...state };
}
function updateProgressBar() {
let attempted = 0;
Object.keys(answers).forEach((id) => {
if (answers[id].selectedIndex !== null) attempted++;
});
const percent = (attempted / TOTAL_QUESTIONS) * 100;
progressFill.style.width = `${percent}%`;
progressText.textContent = `${attempted} / ${TOTAL_QUESTIONS} Attempted`;
}
function startTimer() {
if (timerInterval) clearInterval(timerInterval);
timerInterval = setInterval(() => {
remainingSeconds--;
if (remainingSeconds <= 0) {
remainingSeconds = 0;
updateTimerDisplay();
clearInterval(timerInterval);
if (!examSubmitted) {
submitExam(true);
}
} else {
updateTimerDisplay();
}
saveStateToStorage();
}, 1000);
}
function updateTimerDisplay() {
const h = String(Math.floor(remainingSeconds / 3600)).padStart(2, "
NEET UG Previous Year Question Paper Simulator
Exam Instructions
- Total Questions: 180
- Duration: 180 Minutes
- Physics: 45 Questions (1–45)
- Chemistry: 45 Questions (46–90)
- Biology: 90 Questions (91–180)
- Marking Scheme: +4 for Correct, -1 for Wrong, 0 for Unattempted
Once the exam starts, the timer will begin automatically. Do not refresh or close the window during the test.
Exam: NEET UG
Q. 1
Physics
Exam Results
Overall Performance
- Total Questions:
- Attempted Questions:
- Unattempted Questions:
- Correct Answers:
- Wrong Answers:
- Total Marks Obtained: / 720
- Percentage Score: %
- Time Taken:
Subject Wise Analysis
Physics
Correct:
Wrong:
Marks:
Chemistry
Correct:
Wrong:
Marks:
Biology
Correct:
Wrong:
Marks: