:root {
  --bg: #161b24;
  --card: #222936;
  --card-line: #323b4b;
  --fg: #f2f4f8;
  --muted: #a9b2c3;
  --accent: #5cc8d6;
  --accent-fg: #0d1a1f;
  --stage: #353535;
  --att: #00ffff;
  --err: #ff7070;
  --line: #8a8a8a;
  --draft: #ffcc66;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: radial-gradient(ellipse at top, #222a3a 0%, var(--bg) 60%) fixed var(--bg); }
body { margin: 0; color: var(--fg); overscroll-behavior: none; -webkit-text-size-adjust: 100%;
  font: 18px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }

.page { max-width: 640px; margin: 32px auto; padding: 32px 28px; background: var(--card);
  border: 1px solid var(--card-line); border-radius: 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); }
.page p { margin: 0 0 14px; }
h1, h2 { margin: 0 0 22px; font-weight: 700; line-height: 1.3; }
h1 { font-size: 1.7em; text-align: center; }
h1::after { content: ''; display: block; width: 56px; height: 3px; margin: 14px auto 0; border-radius: 2px; background: var(--accent); }
h2 { font-size: 1.35em; }
fieldset { border: 0; margin: 0 0 24px; padding: 0; min-width: 0; }
legend { padding: 0 0 8px; font-weight: 700; }
label.opt, label.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; margin: 0 0 8px;
  border: 1px solid var(--card-line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
label.opt:hover, label.check:hover { border-color: var(--muted); }
label.opt:has(input:checked), label.check:has(input:checked) { border-color: var(--accent); background: rgba(92, 200, 214, 0.08); }
label.check { margin-top: 24px; font-weight: 600; }
input[type=radio], input[type=checkbox] { width: 22px; height: 22px; margin: 3px 0 0; flex: none; accent-color: var(--accent); }
input[type=number], input[type=text], select { width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--card-line); background: #1a202b; color: var(--fg); }
.combo { position: relative; }
.suggest { position: absolute; top: 100%; right: 0; left: 0; z-index: 5; margin-top: 4px; max-height: 50vh; overflow-y: auto;
  background: #1a202b; border: 1px solid var(--card-line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.suggest div { padding: 10px 12px; cursor: pointer; }
.suggest div + div { border-top: 1px solid var(--card-line); }
.suggest div:hover, .suggest div:first-child { background: rgba(92, 200, 214, 0.1); }
input:disabled { opacity: 0.45; cursor: not-allowed; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button { display: block; width: 100%; margin-top: 24px; padding: 15px; font: inherit; font-weight: 700;
  border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-fg); cursor: pointer; transition: filter .15s; }
button:hover { filter: brightness(1.08); }
button:active { filter: brightness(0.95); }
.lead { font-weight: 600; }
.page a { color: var(--accent); }
.likert { padding: 14px; border: 1px solid var(--card-line); border-radius: 12px; }
.likert legend { float: right; width: 100%; padding: 0 0 10px; font-weight: 600; }
.scale { clear: both; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.scale label { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; text-align: center;
  border: 1px solid var(--card-line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.scale label:hover { border-color: var(--muted); }
.scale label:has(input:checked) { border-color: var(--accent); background: rgba(92, 200, 214, 0.12); }
.scale input { margin: 0; }
.scale .n { font-weight: 700; }
.scale .t { font-size: 12px; line-height: 1.25; color: var(--muted); }
.groups { width: 100%; margin: 4px 0 18px; border-collapse: collapse; }
.groups th, .groups td { padding: 10px 12px; border: 1px solid var(--card-line); text-align: right; vertical-align: top; }
.groups thead th { background: rgba(255, 255, 255, 0.05); }
.groups tbody th { width: 28%; }
.faces { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.faces img { display: block; width: 100%; height: auto; border-radius: 4px; }
.hint { text-align: center; font-size: 0.85em; color: var(--muted); margin-top: 12px; }
.draft { color: var(--draft); font-weight: bold; }
/* The old-browser notice appears only if app.js has not replaced it after 8 s. */
.nojs { visibility: hidden; animation: reveal 0s 8s forwards; }
@keyframes reveal { to { visibility: visible; } }

.cat { color: var(--fg); }
.att { color: var(--att); }
.x { color: var(--err); font-weight: bold; }
.notice { font-weight: bold; }

/* Left/right are physical sides even though the page is RTL. */
.labels { display: flex; justify-content: space-between; align-items: flex-start; direction: ltr; gap: 12px; }
.label { direction: rtl; text-align: center; font-size: clamp(20px, 5vw, 28px); line-height: 1.3; min-width: 30%; }
.label .key { font-size: 15px; opacity: 0.75; }
.part { direction: rtl; padding-top: 4px; white-space: nowrap; text-decoration: underline; }
.brief { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 4px 8px; font-size: 17px; line-height: 1.5; }
.brief p { margin: 0 0 12px; }
.brief .go { margin-top: 16px; text-align: center; }
.zone.start { background: rgba(92, 200, 214, 0.15); border-color: var(--accent); }

#stage { position: fixed; top: 0; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; padding: 16px;
  background: var(--stage); user-select: none; -webkit-user-select: none; touch-action: manipulation; }
/* min-height 0 lets the photo box shrink, so the tap zones stay on screen and in place in landscape. */
#stim { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; visibility: hidden; }
#stim img { width: 195px; max-width: 55vw; max-height: 100%; height: auto; object-fit: contain; }
#stim .word { color: var(--att); font-size: clamp(30px, 8vw, 40px); }
#err { flex: none; text-align: center; color: var(--err); font-size: 52px; line-height: 1; height: 56px; visibility: hidden; }
.zones { flex: none; display: flex; direction: ltr; gap: 12px; height: 26vh; min-height: 56px; margin-top: 8px; }
.zone { flex: 1; display: flex; align-items: center; justify-content: center; border: 2px solid var(--line);
  border-radius: 12px; }
.zone:active { background: rgba(255, 255, 255, 0.12); }

@media (pointer: coarse) {
  #stim { align-items: flex-end; padding-bottom: 8px; }
}

@media (pointer: fine) {
  #stage { top: 24px; right: 24px; bottom: 24px; left: 24px; max-width: 900px; max-height: 700px; margin: auto;
    border: 1px solid var(--card-line); border-radius: 18px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45); }
}

@media (max-width: 520px) {
  body { font-size: 17px; }
  .page { margin: 0; min-height: 100vh; padding: 28px 18px 40px; border: 0; border-radius: 0; box-shadow: none; }
}
