:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --ink: #16202e;
  --muted: #64748b;
  --line: #dfe5ee;
  --brand: #1f4fd8;
  --brand-dark: #17389a;
  --green: #17a34a;
  --red: #dc2626;
  --purple: #7c3aed;
  --grey: #b6bfcc;
  --q-size: 17px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', 'Noto Sans Bengali', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

/* Bengali glyphs fall through to Noto Sans Bengali wherever they appear. */
[lang='bn'],
[lang='bn'] * {
  font-family: 'Noto Sans Bengali', 'Inter', system-ui, sans-serif;
  line-height: 1.9;
}

.hidden {
  display: none !important;
}

button {
  font: inherit;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary {
  background: var(--brand);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}

.danger {
  background: var(--red);
  color: #fff;
  width: 100%;
}

select {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

/* ---------- Instructions / Result sheet ---------- */

.sheet {
  max-width: 900px;
  margin: 32px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px 32px 32px;
}

.sheet h1 {
  margin: 0 0 4px;
  font-size: 20px;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  list-style: none;
  margin: 14px 0 20px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.facts li {
  display: flex;
  flex-direction: column;
}

.facts span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.instructions-body {
  max-height: 340px;
  overflow-y: auto;
  padding-right: 12px;
  color: #2b3648;
}

.lang-pick,
.agree {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.row {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

/* ---------- Test layout ---------- */

#screen-test {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  margin: 0;
  font-size: 16px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13px;
  color: var(--muted);
}

.timer strong {
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  font-size: 16px;
}

.timer.urgent strong {
  color: var(--red);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  min-height: 0;
}

.question-pane {
  overflow-y: auto;
  padding: 22px 28px 40px;
  background: var(--panel);
}

.question-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.qnum {
  font-size: 14px;
  color: var(--muted);
}

.qnum strong {
  color: var(--ink);
  font-size: 16px;
}

.marks em {
  font-style: normal;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 20px;
  margin-left: 6px;
}

.marks .pos {
  background: #e6f6ec;
  color: var(--green);
}

.marks .neg {
  background: #fdeaea;
  color: var(--red);
}

.preamble {
  color: #33405a;
  margin-bottom: 14px;
  font-size: var(--q-size);
}

.preamble:empty {
  display: none;
}

.qtext {
  font-size: var(--q-size);
  margin-bottom: 20px;
}

.qtext img,
.preamble img,
.options img {
  max-width: 100%;
  vertical-align: middle;
}

.options {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-width: 760px;
}

.options li label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: var(--q-size);
}

.options li label:hover {
  border-color: var(--brand);
}

.options li input:checked + span {
  font-weight: 600;
}

.options li:has(input:checked) label {
  border-color: var(--brand);
  background: #f2f6ff;
}

/* ---------- Palette ---------- */

.palette-pane {
  background: #f7f9fc;
  border-left: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.legend {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.dot.answered {
  background: var(--green);
}
.dot.not-answered {
  background: var(--red);
}
.dot.not-visited {
  background: var(--grey);
}
.dot.marked {
  background: var(--purple);
}
.dot.answered-marked {
  background: var(--purple);
  box-shadow: inset -4px -4px 0 0 var(--green);
}

.palette-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.palette button {
  padding: 0;
  height: 34px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--grey);
  border: none;
}

.palette button.answered {
  background: var(--green);
}
.palette button.not-answered {
  background: var(--red);
}
.palette button.marked {
  background: var(--purple);
}
.palette button.answered-marked {
  background: var(--purple);
  box-shadow: inset -6px -6px 0 0 var(--green);
}

.palette button.current {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
}

/* ---------- Action bar ---------- */

.actionbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.spacer {
  flex: 1;
}

/* ---------- Result ---------- */

.result-title {
  color: var(--muted);
  margin-top: 0;
}

.scoreboard {
  display: flex;
  gap: 32px;
  align-items: center;
  flex-wrap: wrap;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7f9fc;
}

.score-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 150px;
}

.score-main span {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  color: var(--brand);
}

.score-main small {
  color: var(--muted);
}

.score-breakdown {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 14px 24px;
  flex: 1;
}

.score-breakdown li {
  display: flex;
  flex-direction: column;
}

.score-breakdown span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-breakdown strong {
  font-size: 18px;
}

.review {
  margin-top: 26px;
  display: grid;
  gap: 16px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.review-item header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.tag {
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.tag.correct {
  background: #e6f6ec;
  color: var(--green);
}
.tag.wrong {
  background: #fdeaea;
  color: var(--red);
}
.tag.skipped {
  background: #eef1f6;
  color: var(--muted);
}

.review-item ol {
  padding-left: 20px;
  margin: 10px 0;
}

.review-item li.is-correct {
  color: var(--green);
  font-weight: 600;
}

.review-item li.is-chosen-wrong {
  color: var(--red);
  text-decoration: line-through;
}

.solution {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  color: #2b3648;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .palette-pane {
    border-left: none;
    border-top: 1px solid var(--line);
  }
}
