:root {
  --bg: #808080;          /* mean gray, as the stimulus background */
  --panel: #f6f6f4;
  --ink: #1d1d1b;
  --muted: #5b5b57;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --good: #217a3c;
  --bad: #b3261e;
  --line: #d6d6d0;
  font-family: Vazirmatn, "Segoe UI", Tahoma, "Geeza Pro", "Noto Sans Arabic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; width: 100vw; height: 100vh; display: none; touch-action: none; }
body.running #stage { display: block; cursor: none; }
#app { position: fixed; inset: 0; overflow-y: auto; padding: 16px; display: flex; align-items: flex-start; justify-content: center; }
body.running #app { pointer-events: none; }
.card { background: var(--panel); border-radius: 14px; max-width: 760px; width: 100%; margin: 4vh auto; padding: 24px 28px;
  box-shadow: 0 2px 18px rgba(0,0,0,.18); line-height: 1.85; font-size: 16px; }
.card h1 { font-size: 22px; margin: 0 0 8px; }
.card h2 { font-size: 18px; margin: 18px 0 6px; }
.card p, .card li { margin: 6px 0; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 10px 22px; cursor: pointer; background: var(--accent); color: var(--accent-ink); }
button.secondary { background: #e4e4df; color: var(--ink); }
button:disabled { opacity: .45; cursor: default; }
input[type=text] { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; width: 100%; max-width: 360px; background: #fff; }
label.check { display: flex; gap: 10px; align-items: flex-start; }
label.check input { margin-top: 8px; width: 18px; height: 18px; }
table.summary { border-collapse: collapse; width: 100%; font-size: 14px; }
table.summary th, table.summary td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: center; }
.progress { height: 10px; background: #e4e4df; border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.kbd { display: inline-block; border: 1px solid #999; border-bottom-width: 3px; border-radius: 6px; padding: 0 8px; font-family: ui-monospace, monospace; background: #fff; direction: ltr; }
.warn { background: #fff4d6; border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.err { background: #fde3e1; border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.ok { background: #e2f3e6; border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.lang { position: fixed; top: 10px; left: 10px; z-index: 5; }
[dir=ltr] .lang { left: auto; right: 10px; }
.lang button { padding: 4px 12px; font-size: 13px; background: rgba(255,255,255,.75); color: var(--ink); }
body.running .lang { display: none; }

/* calibration card */
.calib-wrap { display: flex; justify-content: center; margin: 14px 0; }
.calib-card { background: linear-gradient(135deg, #3a6fc4, #6d97dd); border-radius: 3.5%/5.6%; position: relative; }
.calib-card::after { content: ""; position: absolute; left: 9%; top: 32%; width: 13%; height: 22%; background: #d8c27a; border-radius: 12%; }
input[type=range] { width: 100%; }

/* response overlay (drawn above the canvas during the response phases) */
#resp { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; flex-direction: column; gap: 22px; z-index: 4; }
body.responding #resp { display: flex; pointer-events: auto; }
body.responding #stage { cursor: default; }
#resp .q { font-size: 22px; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5); text-align: center; padding: 0 16px; }
#resp .choices { display: flex; gap: 6vw; direction: ltr; }
#resp .choice { min-width: 170px; padding: 18px 20px; font-size: 20px; border-radius: 14px; background: #fff; color: var(--ink); box-shadow: 0 2px 10px rgba(0,0,0,.25); }
#resp .choice small { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
#resp .slider { width: min(680px, 86vw); height: 64px; position: relative; touch-action: none; cursor: pointer; direction: ltr; }
#resp .track { position: absolute; left: 0; right: 0; top: 28px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #f1d3cf, #fff, #cfe8d6); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
#resp .thumb { position: absolute; top: 14px; width: 36px; height: 36px; margin-left: -18px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; display: none; box-shadow: 0 1px 6px rgba(0,0,0,.35); }
#resp .ticks { position: absolute; left: 0; right: 0; top: 44px; display: flex; justify-content: space-between; font-size: 13px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
#resp .value { font-size: 30px; color: #fff; min-height: 40px; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
#resp .ends { width: min(680px, 86vw); display: flex; justify-content: space-between; font-size: 14px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); direction: ltr; }
#resp .fb { font-size: 26px; font-weight: 700; padding: 8px 20px; border-radius: 12px; background: #fff; }
@media (max-width: 560px) {
  .card { padding: 18px 16px; font-size: 15px; }
  #resp .choice { min-width: 38vw; padding: 16px 8px; font-size: 18px; }
}
