/* Engagement Game, modular build. Page chrome only: the stimulus display
   (.stage) is a fixed mid-grey in every theme (README 4.3), and target colors
   live in the skin modules, not here. */

:root{
  --bg:#E9EDF0;
  --panel:#F7F9FA;
  --ink:#18222C;
  --muted:#56626E;
  --line:#C6CED5;
  --signal:#E3B21F;
  --signal-ink:#18222C;
  --good:#2E7A57;
  --bad:#B4432C;
  --font:"Atkinson Hyperlegible","Segoe UI",system-ui,-apple-system,Helvetica,Arial,sans-serif;
  --mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#11171D; --panel:#18212A; --ink:#E2E8ED; --muted:#98A4AF; --line:#2B3742;
    --good:#5CC196; --bad:#E27A62;
  }
}
:root[data-theme="dark"]{
  --bg:#11171D; --panel:#18212A; --ink:#E2E8ED; --muted:#98A4AF; --line:#2B3742;
  --good:#5CC196; --bad:#E27A62;
}
*{box-sizing:border-box}
[hidden]{display:none !important}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font);font-size:16px;line-height:1.5}
.wrap{max-width:1180px;margin:0 auto;padding:28px 20px 56px}
header{max-width:66ch;margin-bottom:22px}
h1{font-size:1.75rem;line-height:1.15;margin:0 0 6px;font-weight:700;letter-spacing:-0.01em}
header p{margin:0;color:var(--muted)}
h2{font-size:1.05rem;line-height:1.3;margin:0 0 8px;font-weight:700}
p{margin:0 0 10px}
.muted{color:var(--muted)}
.small{font-size:.88rem}
a{color:inherit}

.layout{display:grid;grid-template-columns:minmax(0,1fr) 320px;gap:24px;align-items:start}
@media (max-width:900px){.layout{grid-template-columns:1fr}}

/* ---- Participant display ---- */
/* The garden background below is fixed on purpose: it must not follow the viewer's theme. */
.stage{position:relative;aspect-ratio:16/10;border-radius:4px;overflow:hidden;outline:none;touch-action:manipulation;-webkit-user-select:none;user-select:none;box-shadow:0 0 0 1px rgba(0,0,0,.3)}
.stage:focus-visible{box-shadow:0 0 0 3px var(--signal)}

/* Board (render/board.js). TODO(Q10): spacing depends on visual angle. */
.holes{position:absolute;display:grid;justify-items:center;align-items:center;
  grid-template-columns:repeat(var(--cols,3),1fr);grid-template-rows:repeat(var(--rows,3),1fr)}
.holes.grid3x3{inset:6% 24% 16%;column-gap:4%;row-gap:1%}
.hole{width:100%;max-width:150px;display:flex;flex-direction:column;align-items:center}
.hole .art{width:100%}
.hole svg{width:100%;height:auto;display:block;overflow:visible}

/* Only the active stimulus is drawn. No hole ever reacts to a press. */
.stim{display:none}
.hole[data-stim="mole_happy"] .stim[data-stim="mole_happy"],
.hole[data-stim="mole_sad"]   .stim[data-stim="mole_sad"]{display:inline}

/* Button labels under the board, one per column. */
.keycaps{position:absolute;left:24%;right:24%;bottom:4%;display:grid;
  grid-template-columns:repeat(var(--cols,3),1fr);justify-items:center}
.keycap{font-size:.8rem;font-weight:700;line-height:1;padding:4px 9px;border-radius:3px;
  background:#B9B9B9;color:#262626;font-variant-numeric:tabular-nums}

.hud{position:absolute;top:0;left:0;right:0;display:flex;justify-content:space-between;padding:10px 14px;font-weight:700;color:#1C1C1C;font-variant-numeric:tabular-nums;font-size:.95rem;pointer-events:none}
.overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:6%;background:rgba(128,128,128,.6)}
.overlay-card{max-width:31rem;background:#2B2B2B;color:#F1F1F1;padding:18px 22px;border-radius:4px}
.overlay-card h3{margin:0 0 6px;font-size:1.15rem}
.overlay-card p{font-size:.95rem}
.overlay-card p:last-child{margin-bottom:0}
.overlay-card .error{color:#F5B7A8;white-space:pre-wrap}
kbd{font-family:var(--font);font-weight:700;background:#E3E3E3;color:#1C1C1C;border-radius:3px;padding:0 6px}
.caption{margin-top:10px}

/* ---- Experimenter console ---- */
.console{background:var(--panel);border:1px solid var(--line);border-radius:4px;padding:18px}
.console section + section{margin-top:18px;padding-top:16px;border-top:1px solid var(--line)}
fieldset{border:0;margin:0 0 14px;padding:0;min-width:0}
legend{font-weight:700;font-size:.92rem;margin-bottom:4px;padding:0}
.opts{display:flex;flex-direction:column;gap:2px}
.opts label{display:flex;gap:8px;align-items:baseline;font-size:.92rem;cursor:pointer}
.opts label.disabled{color:var(--muted);cursor:not-allowed}
.row{display:grid;grid-template-columns:1fr auto;gap:8px;align-items:center;margin-bottom:8px;font-size:.92rem}
.row input[type=number],.row input[type=text]{width:5.6rem;font:inherit;font-size:.92rem;padding:4px 6px;border:1px solid var(--line);border-radius:3px;background:var(--bg);color:var(--ink);font-variant-numeric:tabular-nums}
.range-row{margin-bottom:10px;font-size:.92rem}
.range-row .top{display:flex;justify-content:space-between}
.range-row output{font-weight:700;font-variant-numeric:tabular-nums}
input[type=range]{width:100%;accent-color:var(--signal)}
input[type=radio],input[type=checkbox]{accent-color:var(--ink)}
.buttons{display:flex;gap:8px;flex-wrap:wrap}
button{font:inherit;font-weight:700;font-size:.95rem;padding:9px 14px;border-radius:4px;border:1px solid var(--ink);background:transparent;color:var(--ink);cursor:pointer}
button.primary{background:var(--signal);border-color:var(--signal);color:var(--signal-ink)}
button:disabled{opacity:.45;cursor:not-allowed}
button[aria-pressed="true"]{background:var(--ink);color:var(--bg)}
:focus-visible{outline:3px solid var(--signal);outline-offset:2px}
.measures{display:grid;grid-template-columns:1fr auto;gap:5px 12px;margin:0;font-size:.92rem}
.measures dt{color:var(--muted)}
.measures dd{margin:0;text-align:right;font-weight:700;font-variant-numeric:tabular-nums}

/* ---- Attention trace (render/trace.js) ---- */
.timeline{margin-top:30px}
.timeline > p{max-width:72ch}
.chart-wrap{background:var(--panel);border:1px solid var(--line);border-radius:4px;padding:12px 12px 4px;overflow-x:auto}
#chart{width:100%;min-width:560px;height:auto;display:block}
.vtc{fill:none;stroke:var(--ink);stroke-width:2;stroke-linejoin:round}
.vtc-dot{fill:var(--ink)}
.median{stroke:var(--muted);stroke-dasharray:5 5}
.axisline{stroke:var(--line)}
.tr{stroke:var(--signal);stroke-width:1.6}
.mk-com{fill:var(--bad)}
.mk-om{fill:none;stroke:var(--bad);stroke-width:1.8}
.axis{fill:var(--muted);font-size:13px;font-family:var(--font)}
.cursor{stroke:var(--muted);stroke-width:1}
.legend{display:flex;flex-wrap:wrap;gap:6px 20px;font-size:.86rem;color:var(--muted);margin:10px 0 0;padding:0;list-style:none}
.sw{display:inline-block;vertical-align:middle;margin-right:7px}
.sw-line{width:16px;height:2px;background:var(--ink)}
.sw-med{width:16px;border-top:2px dashed var(--muted)}
.sw-tr{width:2px;height:12px;background:var(--signal)}
.sw-tri{width:0;height:0;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:10px solid var(--bad)}
.sw-ring{width:10px;height:10px;border:2px solid var(--bad);border-radius:50%}

/* ---- Data ---- */
.data{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.35fr);gap:24px;margin-top:30px}
@media (max-width:900px){.data{grid-template-columns:1fr}}
.log{list-style:none;margin:0;padding:0;font-size:.88rem;font-variant-numeric:tabular-nums;max-height:330px;overflow:auto;border-top:1px solid var(--line)}
.log li{display:grid;grid-template-columns:4.6rem 8.6rem minmax(0,1fr);gap:8px;padding:5px 2px;border-bottom:1px solid var(--line)}
.log .t{color:var(--muted)}
.log .ev{font-weight:700}
.log .ev-hit,.log .ev-correct_rejection{color:var(--good)}
.log .ev-commission,.log .ev-omission,.log .ev-wrong_hole{color:var(--bad)}
.log .empty{display:block;color:var(--muted);padding:10px 2px}
.export-bar{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:8px}
.export-bar button{padding:6px 11px;font-size:.88rem}
textarea{width:100%;min-height:300px;font-family:var(--mono);font-size:.78rem;line-height:1.45;white-space:pre;overflow:auto;background:var(--panel);color:var(--ink);border:1px solid var(--line);border-radius:4px;padding:10px;resize:vertical}
#copy-status{min-height:1.4em;margin-top:6px}
.notes{margin-top:30px;max-width:72ch;border-top:1px solid var(--line);padding-top:16px}

@media (prefers-reduced-motion: reduce){ *{scroll-behavior:auto !important} }

/* ---- Experimenter console: link to the display, and the mirror ---- */
.link-bar{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:6px}
.link-status{margin:0;font-weight:700}
.link-status.warn{color:var(--bad)}
.mirror-title{margin-top:14px}
.stage.mirror{max-width:640px}
.error-text{color:var(--bad);white-space:pre-wrap}

/* ---- Participant display page (display.html) ----
   Decided September 21, 2026: the participant sees only the grey field and
   the moles, in its own tab or window, separate from the console. */
body.display-page{background:#808080;margin:0;overflow:hidden}
.display-stage{position:fixed;inset:0;aspect-ratio:auto;border-radius:0;box-shadow:none}
.display-stage:focus-visible{box-shadow:none}
.display-page .hole{max-width:24vh}
.display-page .keycap{font-size:1.1rem;padding:6px 12px}
.display-hint{position:absolute;left:0;right:0;bottom:1%;margin:0;text-align:center;font-size:.8rem;color:#2B2B2B}

/* Links that look like buttons ("Open participant display"). */
a.button{display:inline-block;font:inherit;font-weight:700;font-size:.95rem;padding:9px 14px;border-radius:4px;
  border:1px solid var(--ink);color:var(--ink);text-decoration:none;cursor:pointer}
a.button.primary{background:var(--signal);border-color:var(--signal);color:var(--signal-ink)}

/* Setup steps shown in the console until a display connects. */
.connect-card{background:var(--panel);border:1px solid var(--line);border-left:4px solid var(--signal);border-radius:4px;padding:14px 18px;margin:10px 0 0}
.connect-card h2{margin-top:0}
.connect-card ol{margin:0 0 8px;padding-left:1.3em}
.connect-card li{margin-bottom:6px}
.connect-card a{color:inherit}

/* Shown until a page's script runs and hides it: catches stale caches and file:// opens. */
.load-check{background:#FBE3DC;color:#5A1A0C;border:1px solid #B4432C;border-radius:4px;padding:12px 16px;margin-bottom:16px}
.display-load-check{position:fixed;top:12px;left:12px;right:12px;z-index:10}

/* Results panel on the display (testing only, showResultsOnDisplay). */
.results{position:absolute;top:4%;left:6%;right:6%;max-height:92%;overflow:auto;background:var(--panel);color:var(--ink);border-radius:6px;padding:20px 24px;box-shadow:0 4px 24px rgba(0,0,0,.35)}
.results h2{margin-top:0}
.results .chart-wrap{margin:10px 0}
.results-legend{color:var(--muted)}

/* ---- Feedback variants for piloting (all off by default, Q6) ---- */
/* Ring around a hole: white for a hit, red for a distractor pressed. */
.fx{fill:none;stroke:transparent;stroke-width:6}
.hole.fx-hit .fx{stroke:#F2F2F2}
.hole.fx-com .fx{stroke:#F0443A}
/* Hammer: hidden until it swings down from above, pivoting on its handle end.
   It lands at 35% of 260 ms (about 90 ms, HAMMER_LAND_MS in board.js), bounces
   back a little, and fades. */
.hammer{opacity:0;transform-box:view-box;transform-origin:116px 8px;transform:rotate(50deg);pointer-events:none}
.hole.swing .hammer{animation:hammer-swing 260ms ease-in forwards}
@keyframes hammer-swing{
  0%{opacity:1;transform:rotate(50deg)}
  35%{opacity:1;transform:rotate(0deg)}
  47%{opacity:1;transform:rotate(7deg)}
  59%{opacity:1;transform:rotate(0deg)}
  82%{opacity:1;transform:rotate(0deg)}
  100%{opacity:0;transform:rotate(0deg)}
}
/* The impact burst pops as the hammer lands, then fades. */
.impact{opacity:0;transform-box:view-box;transform-origin:58px 24px;pointer-events:none}
.hole.swing .impact{animation:impact-pop 260ms ease-out forwards}
@keyframes impact-pop{
  0%,33%{opacity:0;transform:scale(.5)}
  40%{opacity:1;transform:scale(1)}
  62%{opacity:1;transform:scale(1.18)}
  100%{opacity:0;transform:scale(1.3)}
}
/* A mole hit with the hammer on waits for the hammer (90 ms), is squashed
   hard on impact, then sinks; all done by 300 ms (HAMMER_SINK_DONE_MS).
   Display only. */
.hole.struck .target{animation:mole-struck 210ms ease-in 90ms both;transform-box:view-box;transform-origin:60px 92px}
@keyframes mole-struck{
  0%{transform:translate(0px,0px) scale(1,1)}
  18%{transform:translate(0px,7px) scale(1.16,0.7)}
  38%{transform:translate(0px,6px) scale(1.1,0.78)}
  100%{transform:translate(0px,84px) scale(1,1)}
}
/* Score, top centre of the participant display, with a bar that fills to the
   percentage. Its colour slides from dark red through orange and yellow to
   green (scoreColor in summary.js). */
.scorebox{position:absolute;top:1.5%;left:50%;transform:translateX(-50%);width:min(34vw,420px);text-align:center;pointer-events:none}
/* The value is the big element: bold, large, tabular numerals. */
.score-value{font-size:clamp(1.9rem,5.6vh,3.6rem);font-weight:800;line-height:1;color:#1C1C1C;font-variant-numeric:tabular-nums;letter-spacing:-.02em;text-shadow:0 1px 3px rgba(255,255,255,.55)}
.score-bar{margin-top:.9vh;height:clamp(10px,1.8vh,18px);background:#5A5A5A;border:2px solid #2B2B2B;border-radius:999px;overflow:hidden}
/* The label sits below the bar, small, spaced out, and quiet. */
.score-label{margin-top:.8vh;font-size:clamp(.65rem,1.6vh,.95rem);font-weight:700;letter-spacing:.24em;text-transform:uppercase;color:#243018;opacity:.85;line-height:1}
.score-fill{height:100%;width:0;background:#5A5A5A;border-radius:999px;transition:width .25s ease,background-color .25s ease}
/* Fill colour is set by display.js from scoreColor: a smooth dark red to green. */
/* With the score on, the grid moves down so the score never covers a mole. */
.display-page .stage.has-score .holes.grid3x3{top:17%}

/* Link for labmates (console). */
.share{margin:16px 0 4px;padding:12px 14px;border:1px solid var(--line);border-radius:4px;background:var(--bg)}
.share h3{margin:0 0 4px;font-size:.95rem}
.share-row{display:flex;gap:6px;flex-wrap:wrap}
.share-row input{flex:1 1 12rem;min-width:0;font:inherit;font-size:.82rem;padding:6px 8px;border:1px solid var(--line);border-radius:3px;background:var(--panel);color:var(--ink)}
.share-row button,.share-row a.button{padding:6px 11px;font-size:.88rem}

/* ---- The garden behind the holes (the only background) ----
   Sky with a few clouds, hills on the horizon, and grass, with brown holes
   (October 17, 2026; the plain grey option was removed in November 2026).
   It is static: nothing in it changes during a run. */
.stage{background:
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 200' preserveAspectRatio='none'%3E%3Cg fill='%23FFFFFF' fill-opacity='.85'%3E%3Cellipse cx='140' cy='70' rx='70' ry='22'/%3E%3Cellipse cx='185' cy='58' rx='45' ry='24'/%3E%3Cellipse cx='790' cy='95' rx='80' ry='20'/%3E%3Cellipse cx='840' cy='82' rx='46' ry='22'/%3E%3Cellipse cx='470' cy='40' rx='50' ry='14'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 100% 16% no-repeat,
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 100' preserveAspectRatio='none'%3E%3Cpath fill='%235E9C46' d='M0 100V58C90 30 170 34 250 52S410 40 500 30 660 22 760 46 900 60 1000 40V100Z'/%3E%3Cpath fill='%2373B550' d='M0 100V78C120 60 230 64 340 76S560 60 680 70 870 82 1000 68V100Z'/%3E%3C/svg%3E") 0 18% / 100% 12% no-repeat,
  linear-gradient(#6DB6E8, #CDE9F6) 0 0 / 100% 24% no-repeat,
  linear-gradient(#7BC24D, #4E9733) 0 100% / 100% 76% no-repeat,
  #7BC24D}
.mound{fill:#8A5A2E}
.pit{fill:#3A2213}
.lip{stroke:#6B4423}
.stage .keycap{background:#F1E6CF;color:#3A2213}
.stage .display-hint{color:#1E3A12}

/* Health bar (game style "health"): a shake and red flash when health drops,
   and a slow pulse when it is low (25 or below). */
.scorebox.hurt{animation:health-hurt 350ms ease-out}
@keyframes health-hurt{
  0%{transform:translateX(-50%)}
  20%{transform:translateX(calc(-50% - 7px))}
  40%{transform:translateX(calc(-50% + 7px))}
  60%{transform:translateX(calc(-50% - 4px))}
  80%{transform:translateX(calc(-50% + 3px))}
  100%{transform:translateX(-50%)}
}
.scorebox.hurt .score-bar{border-color:#FF3B30;box-shadow:0 0 10px #FF3B30}
.scorebox.low .score-bar{animation:health-low 900ms ease-in-out infinite}
@keyframes health-low{0%,100%{box-shadow:none}50%{box-shadow:0 0 10px #FF3B30}}

