* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #14161a;
  --panel: #1e2127;
  --text: #e8eaed;
  --dim: #9aa0a8;
  --accent: #4c8dff;
  --ok: #35c46f;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center;
          justify-content: center; padding: 24px; gap: 20px; }
h1 { font-size: 1.6rem; font-weight: 650; text-align: center; }
.card { background: var(--panel); border-radius: 14px; padding: 28px 32px; max-width: 620px;
        display: flex; flex-direction: column; gap: 14px; }
.card ul { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.fineprint { color: var(--dim); font-size: 0.85rem; }
.nick { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--dim); }
.nick input { background: var(--bg); border: 1px solid #333842; border-radius: 8px;
              color: var(--text); padding: 10px 12px; font-size: 1rem; }
button.primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 13px 22px; font-size: 1.05rem; font-weight: 600; cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }
button.secondary {
  background: var(--panel); color: var(--text); border: 1px solid #333842; border-radius: 10px;
  padding: 11px 20px; font-size: 1rem; cursor: pointer;
}
button.secondary:hover { border-color: var(--accent); }
button.primary:disabled { opacity: 0.4; cursor: default; }
.error { color: #ff7b72; }

/* ---- trial screen: two phases.
   mode-ref  = the original alone, as large as the window allows.
   mode-ab   = A and B side by side, as large as the window allows.
   All three <video> elements stay loaded and playing throughout; the mode
   class only controls which stage is visible, so playback stays in sync. ---- */
#screen-trial { justify-content: flex-start; gap: 10px; padding: 10px 12px 16px; position: relative; }
.trialbar { width: 98vw; display: flex; align-items: center; gap: 14px;
            color: var(--dim); font-size: 0.9rem; }
#strip { flex: 1; display: flex; gap: 3px; flex-wrap: wrap; }
#strip .cell { flex: 1; min-width: 8px; max-width: 26px; height: 10px; border-radius: 3px;
  border: 1px solid #3a3f49; background: transparent; padding: 0; cursor: pointer; }
#strip .cell.done { background: var(--accent); border-color: var(--accent); }
#strip .cell.done:hover { filter: brightness(1.3); }
#strip .cell.cur { border-color: #fff; box-shadow: 0 0 0 1px #fff inset; }
#strip .cell.locked { cursor: default; opacity: 0.45; }
.dimhint { font-size: 0.85rem; }
figure { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
figcaption { color: var(--dim); font-size: 0.9rem; letter-spacing: 0.04em;
             text-transform: uppercase; }
video { background: #000; border-radius: 10px; display: block; }

/* phase visibility: the original stays on screen in BOTH phases (mode-ab
   shrinks it above A/B); mode-ref shows the reference alone */
#screen-trial.mode-ref .ab-stage { display: none; }
#screen-trial.mode-ab  .ref-stage { margin-bottom: 0; gap: 4px; }
#screen-trial.mode-ab  .ab-stage  { margin-top: 12px; }   /* one centered block with the original */

/* phase 1: the original, near-fullscreen.
   Video widths are set in pixels by fitVideos() in app.js — CSS max-limits
   cannot UPSCALE a video past its natural size, and the goal here is the
   largest aspect-correct fit the window allows. */
.ref-stage { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 98vw;
             margin-top: auto; margin-bottom: auto; }
.ref-stage video { height: auto; }

/* phase 2: A and B, each about half the window */
.ab-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 98vw;
            margin-top: auto; margin-bottom: auto; }
.ab-row { display: flex; gap: 14px; width: 100%; justify-content: center; align-items: flex-end; }
.choice { flex: 0 1 auto; min-width: 0; }
.choice video { height: auto; margin: 0 auto; cursor: pointer; border: 2px solid transparent; }
.choice video:hover { border-color: var(--accent); }
button.pick {
  width: 100%; max-width: 560px; background: var(--panel); color: var(--text); border: 1px solid #333842;
  border-radius: 10px; padding: 11px; font-size: 1rem; font-weight: 600; cursor: pointer;
}
button.pick:hover { background: var(--accent); border-color: var(--accent); }
button.pick:disabled { opacity: 0.4; cursor: default; }
button.pick.chosen { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
button.pick.chosen::after { content: " · your answer"; color: var(--ok); font-weight: 500; }
kbd { background: #2a2e36; border-radius: 4px; padding: 1px 7px; font-size: 0.85em;
      border: 1px solid #3a3f49; }
button.primary kbd { background: rgba(255,255,255,0.18); border-color: transparent; color: #fff; }

/* row under A/B: reference-full-size on the left, the play countdown beside it */
.under-row { display: flex; align-items: center; width: 100%; gap: 12px; }
.under-row .ghost { width: auto; color: var(--dim); background: transparent; }
.under-row .ghost:hover { color: var(--text); background: var(--panel); border-color: #4a505c; }

.veil { position: absolute; inset: 0; background: rgba(20,22,26,0.85); display: flex;
        align-items: center; justify-content: center; color: var(--dim); font-size: 1.1rem;
        z-index: 5; }
.flash-ok { animation: flash 0.25s; }
@keyframes flash { 0% { outline: 3px solid var(--ok); } 100% { outline: 0 solid transparent; } }

#toast {
  position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 80px);
  background: #3a2f13; color: #ffd479; border: 1px solid #6b5518; border-radius: 10px;
  padding: 10px 18px; font-size: 0.95rem; transition: transform 0.25s; z-index: 20;
}
#toast.show { transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .ab-row { flex-direction: column; align-items: center; gap: 10px; }
  .choice { width: 96vw; max-width: none; }
  .choice video { max-height: 36vh; }
  .under-row { flex-wrap: wrap; justify-content: center; }
}

/* ---- KAVA study additions ---- */
.consent { border: 1px solid #333842; border-radius: 10px; padding: 12px 14px; font-size: 0.9rem; color: var(--dim); }
a.primary { display: inline-block; text-align: center; text-decoration: none; background: var(--accent); color: #fff;
  border-radius: 10px; padding: 13px 22px; font-size: 1.05rem; font-weight: 600; }
.veil .card { max-width: 560px; text-align: left; }
.veil .card h1 { text-align: left; font-size: 1.3rem; }
#size-veil, #feedback-veil, #comment-veil { z-index: 6; background: rgba(20,22,26,0.94); }
textarea { background: var(--bg); border: 1px solid #333842; border-radius: 8px; color: var(--text);
  padding: 10px 12px; font: inherit; resize: vertical; width: 100%; }
#play-gate { margin-left: 8px; }
/* videos are sized in pixels by fitVideos(); A and B never scale with the window */
.choice video { max-width: none; }
