/* One fixed light theme on purpose: every participant sees the stimuli under identical conditions. */
:root {
  color-scheme: light;
  --paper: #f6f5f1;
  --card: #ffffff;
  --ink: #1c2329;
  --muted: #5d6670;
  --line: #dedbd3;
  --accent: #23439c;
  --accent-ink: #ffffff;
  --accent-soft: #e5eaf7;
  --lead: #c0583f;
  --follow: #2e7d89;
  --warn-bg: #fff4dc;
  --warn-line: #e6c375;
  --now-bg: #1c2329;
  --now-ink: #f6f5f1;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper); color: var(--ink);
  font: 15px/1.55 Inter, "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
}
[hidden] { display: none !important; }
h1, h2 { line-height: 1.25; text-wrap: balance; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.prose { max-width: 68ch; }
.prose ul { padding-left: 1.2em; }
.prose li { margin: .25em 0; }

.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line); background: var(--card);
}
.brand { font-weight: 600; }
.step { color: var(--muted); font-size: .9rem; }
main { max-width: 1240px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.screen.card { max-width: 780px; margin: 24px auto; }

button {
  font: inherit; border-radius: 8px; padding: 9px 18px; cursor: pointer; border: 1px solid transparent;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.secondary { background: var(--card); color: var(--accent); border-color: var(--accent); }
button.small { padding: 3px 10px; font-size: .85rem; }
button:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.actions { display: flex; justify-content: flex-end; margin-top: 18px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 0; }
.check input { margin-top: 4px; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.soundcheck { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.defs dt { font-weight: 600; margin-top: .5em; }
.defs dd { margin: 0 0 0 0; color: var(--muted); }
textarea { width: 100%; font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }

fieldset { border: 0; padding: 0; margin: 0 0 18px; }
legend { font-weight: 600; margin-bottom: 6px; }
.opt { display: flex; gap: 10px; align-items: center; padding: 4px 0; }

.sw { display: inline-block; width: .8em; height: .8em; border-radius: 50%; vertical-align: -.05em; margin-right: .3em; }
.sw.lead { background: var(--lead); }
.sw.follow { background: var(--follow); }

/* trial */
.trial-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; font-weight: 600; }
.progress { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.badge { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 999px; padding: 1px 10px; font-size: .8rem; }
.now { display: flex; gap: 12px; align-items: baseline; background: var(--now-bg); color: var(--now-ink);
       border-radius: var(--radius) var(--radius) 0 0; padding: 10px 16px; min-height: 3.6em; }
.now-tag { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .7; flex: none; }
#now-text { min-width: 0; }
.stage { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--now-bg); padding: 0 4px 4px; }
.view { margin: 0; position: relative; min-width: 0; }
.view figcaption { position: absolute; top: 10px; left: 12px; z-index: 2; font-weight: 700; font-size: 1.3rem;
                   background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; }
.canvas { aspect-ratio: 4 / 3; width: 100%; cursor: grab; touch-action: none; }
.canvas:active { cursor: grabbing; }
.canvas canvas { width: 100% !important; height: 100% !important; display: block; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--now-ink); background: rgba(28, 35, 41, .55); font-weight: 600; }
.transport { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-top: 0;
             border-radius: 0 0 var(--radius) var(--radius); padding: 10px 14px; flex-wrap: wrap; }
.play { min-width: 96px; }
.timebar { flex: 1; min-width: 120px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.timebar i { display: block; height: 100%; width: 0; background: var(--ink); }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 7.5em; text-align: right; }
.legend { color: var(--muted); font-size: .9rem; }
.legend .sw:last-of-type { margin-left: .8em; }

.lower { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; align-items: start; }
.moves ol { list-style: none; margin: 0; padding: 0; }
.moves li { display: grid; grid-template-columns: 6.2em minmax(0, 1fr); gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); }
.moves li .t { font-variant-numeric: tabular-nums; font-size: .85rem; padding-top: .1em; }
.moves li.on { background: var(--accent-soft); color: var(--ink); }
.gate { color: var(--muted); font-style: italic; }
.q { padding: 10px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.q .prompt { font-weight: 600; }
.q .help { color: var(--muted); font-size: .88rem; margin-bottom: 6px; }
.choices { display: flex; gap: 8px; }
.choices button { flex: 1; background: var(--card); border: 1.5px solid var(--line); font-weight: 700; color: var(--ink); }
.choices button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.questions.locked .q { opacity: .45; }
.q .qtext { font-size: .93rem; margin-bottom: 2px; }
/* 1-5 rating grid: anchor labels on top, then one row of buttons for A and one for B */
.scale { display: grid; gap: 6px; align-items: center; margin-top: 8px; }
.scale .anchor { font-size: .72rem; line-height: 1.2; color: var(--muted); text-align: center; overflow-wrap: anywhere; }
.scale .side { font-weight: 700; text-align: center; }
.scale button { min-width: 0; padding: 7px 0; background: var(--card); border: 1.5px solid var(--line); font-weight: 600; color: var(--ink); }
.scale button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.q.choice { border-top: 2px solid var(--ink); margin-top: 6px; }

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; }
  .lower { grid-template-columns: minmax(0, 1fr); }
}
