/* ==========================================================================
   quiz.css — the shared question modal
   Deliberately identical in all three games so the learning instrument stays
   constant across conditions in the study.
   ========================================================================== */

#feQuiz {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  padding-top: max(10px, env(safe-area-inset-top));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: rgba(30, 41, 80, .55);
  backdrop-filter: blur(8px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#feQuiz.hidden { display: none; }

/* The ? modal wears the same shell as the quiz, one z-index up so it can sit
   over a start card. */
#feHelp {
  position: fixed;
  inset: 0;
  z-index: 940;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(30, 41, 80, .5);
  backdrop-filter: blur(8px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
#feHelp .qcard {
  width: 100%;
  max-width: 560px;
  max-height: 100%;
  padding: 18px 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-modal);
  overflow-y: auto;
}
.helphead { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.helpx {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.helpx:hover { color: var(--text); border-color: var(--line2); }
#feHelp .expl { margin: 0 0 10px; font-size: 13.5px; line-height: 1.6; color: var(--muted); }
#feHelp .expl b { color: var(--text); }

#feQuiz .qcard {
  width: 100%;
  max-width: 600px;
  max-height: 100%;
  padding: 16px 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-modal);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 700px) { #feQuiz .qcard { padding: 22px 24px 24px; } }

.qhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
}
.qlabel {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent2);
}
.qtags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(91, 87, 240, .12);
  color: var(--accent2);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .7px;
  text-transform: uppercase;
}
.tag.d1 { background: rgba(34, 197, 94, .14); color: var(--good2); }
.tag.d2 { background: rgba(242, 176, 30, .18); color: var(--gold2); }
.tag.d3 { background: rgba(239, 68, 68, .12); color: var(--bad2); }

.qtimer {
  height: 5px;
  margin: 0 0 14px;
  border-radius: 999px;
  background: var(--surface3);
  overflow: hidden;
}
.qtimer.hidden { display: none; }
.qtimer i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--good);
  transition: background .3s ease;
}
.qtimer i.warn { background: var(--gold); }
.qtimer i.danger { background: var(--bad); }

.qtext {
  margin: 0 0 14px;
  font-size: 16.5px;
  font-weight: 650;
  line-height: 1.45;
  color: var(--text);
}
@media (min-width: 700px) { .qtext { font-size: 18px; } }

.opts { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 620px) { .opts { grid-template-columns: 1fr 1fr; gap: 10px; } }

.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tap);
  padding: 11px 12px;
  border: 1px solid var(--line2);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color .12s ease, background .12s ease, transform .06s ease;
}
.opt:active:not(:disabled) { transform: scale(.985); }
.opt:hover:not(:disabled) { border-color: var(--accent); background: rgba(91, 87, 240, .08); }
.opt:disabled { cursor: default; }
.opt .badge {
  flex: 0 0 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.opt.correct { background: rgba(18, 161, 80, .14); border-color: var(--good); }
.opt.correct .badge { background: var(--good); }
.opt.wrong { background: rgba(239, 68, 68, .12); border-color: var(--bad); }
.opt.wrong .badge { background: var(--bad); }
.opt.dim { opacity: .34; }

.result { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.result.hidden { display: none; }
.verdict { margin: 0 0 6px; font-size: 16px; font-weight: 800; }
.verdict.ok { color: var(--good2); }
.verdict.no { color: var(--bad2); }
.answerline { margin: 0 0 6px; font-size: 14px; font-weight: 700; line-height: 1.4; color: var(--text); }
.expl { margin: 0 0 14px; font-size: 14px; line-height: 1.6; color: var(--muted); }

/* ==========================================================================
   Tools: the reference sheet and the calculator, in a drawer beside the card
   ========================================================================== */
#feQuiz .qwrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 100%;
}
#feQuiz[data-tool] .qwrap { max-width: 960px; }
#feQuiz .qwrap .qcard { flex: 1 1 auto; min-width: 0; }

.qtools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.qtools .btn-sm { margin-left: auto; }
.qtool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--line2);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.qtool:hover { border-color: var(--accent); color: var(--accent); }
.qtool[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.tag.multi { background: rgba(217, 119, 6, .14); color: #b45309; }

/* multi select: picked options wait for Submit */
.opts.multi .opt .badge { border-radius: 6px; }
.opt.picked { border-color: var(--accent); background: rgba(91, 87, 240, .10); }
.opt.picked .badge { background: var(--accent); }

.qdrawer {
  flex: 0 0 340px;
  width: 340px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-modal);
  overflow: hidden;
}
.qdrawer.hidden { display: none; }
.qdhead {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface2);
}
.qdtabs { flex: 1 1 auto; display: flex; gap: 4px; }
.qdtabs button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.qdtabs button.on { background: #fff; border-color: var(--line2); color: var(--text); }
.qdx {
  width: 34px; height: 34px;
  border: none; border-radius: 8px; background: none;
  color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.qdx:hover { color: var(--text); background: var(--surface3); }
.qdbody { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px; }

/* reference sheet */
.qrsec { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.qrsec b { color: var(--accent); font-size: 10.5px; letter-spacing: 1.2px; text-transform: uppercase; }
.qreqs { display: grid; gap: 6px; margin: 0 0 10px; }
.qreqs code {
  display: block;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface2);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}
.qrnote { margin: 0 0 8px; font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.qrnote b { color: var(--text); }

/* calculator */
.calc { display: flex; flex-direction: column; gap: 8px; }
.cdisp {
  position: relative;
  padding: 10px 12px 8px;
  border: 1px solid var(--line2);
  border-radius: 12px;
  background: #eef3ee;
}
.cmode { position: absolute; top: 6px; right: 10px; font-size: 9.5px; font-weight: 800; letter-spacing: 1px; color: var(--muted); }
.cexpr {
  width: 100%;
  border: none;
  background: none;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 17px;
  color: var(--text);
  outline: none;
  padding: 8px 0 2px;
}
.cres {
  min-height: 26px;
  text-align: right;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.cres.err { font-size: 14px; font-weight: 600; color: var(--bad); }
.ckeys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.ck {
  min-height: 38px;
  padding: 4px 2px;
  border: 1px solid var(--line2);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}
.ck:active { transform: scale(.96); }
.ck.fn { background: var(--surface3); font-size: 12.5px; }
.ck.op { background: var(--accent-soft, #eceafe); color: var(--accent); font-size: 17px; }
.ck.ac { background: rgba(239, 68, 68, .12); color: var(--bad); }
.ck.eq { background: var(--action); border-color: var(--action); color: #fff; font-size: 18px; }

/* phones: the drawer becomes a sheet under the card, same scroll */
@media (max-width: 860px) {
  #feQuiz .qwrap { flex-direction: column; align-items: stretch; max-height: none; }
  #feQuiz[data-tool] .qwrap { max-width: 600px; }
  #feQuiz .qwrap .qcard { max-height: none; }
  .qdrawer { flex: 0 0 auto; width: 100%; max-height: 60vh; }
  #feQuiz { align-items: flex-start; }
}
