/* ==========================================================================
   Participant screen — mobile-first, one-handed, 320px-safe.
   ========================================================================== */

body {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  position: relative;
}
/* Paper tooth. Very low opacity — you feel it more than you see it. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--grain);
  opacity: 0.035;
  pointer-events: none;
  z-index: 100;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

/* .link connection indicator lives in base.css (shared with admin). */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 18px 24px;
  gap: 18px;
}

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  font: 500 0.6rem/1.4 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray);
  border-top: 1px solid var(--line);
}
.foot__actions { display: flex; gap: 8px; flex: none; }

.screen { display: none; flex: 1; flex-direction: column; gap: 18px; }
.screen.is-active { display: flex; }

/* Phase-swappable body inside a persistent question shell — media above it
   survives preview→voting untouched. */
.qbody { display: flex; flex-direction: column; gap: 18px; flex: 1; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.screen.is-active > * { animation: rise 0.45s var(--ease) both; }
.screen.is-active > *:nth-child(2) { animation-delay: 0.05s; }
.screen.is-active > *:nth-child(3) { animation-delay: 0.1s; }
.screen.is-active > *:nth-child(4) { animation-delay: 0.15s; }

/* ------------------------------------------------------------- name screen */

.hero {
  font-weight: 900;
  font-size: clamp(2.1rem, 11vw, 3.2rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin: 0;
}
.hero em {
  font-style: normal;
  color: var(--red);
}
.lede {
  margin: 0;
  color: var(--gray);
  font-size: 1rem;
  line-height: 1.5;
  max-width: 34ch;
}

.field { display: grid; gap: 10px; }
.field input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 18px;
  font-size: 1.25rem;
  font-weight: 600;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 4px;
}
.field input::placeholder { color: #b9b4ab; font-weight: 400; }
.field input:focus { outline: none; box-shadow: 0 0 0 4px var(--paper-2); }

.cta {
  width: 100%;
  min-height: var(--tap);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s var(--ease), background 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 0 0 var(--accent-deep);
}
.cta:active { transform: translateY(3px); box-shadow: 0 1px 0 0 var(--accent-deep); background: var(--accent-deep); }
.cta[disabled] { background: var(--gray); box-shadow: none; opacity: 0.6; }

.err {
  margin: 0;
  color: var(--red);
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 1.2em;
}

/* ------------------------------------------------------------ lobby / wait */

.wait { display: grid; gap: 8px; place-content: center; text-align: center; flex: 1; }
.wait__big {
  font-weight: 900;
  font-size: clamp(1.7rem, 8vw, 2.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
}
.wait__sub { color: var(--gray); margin: 0; font-size: 1rem; }

.counter {
  font: 900 3.6rem/1 var(--sans);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

@keyframes pulse {
  0%, 100% { opacity: 0.25; }
  50%      { opacity: 1; }
}
.dots span {
  display: inline-block;
  width: 8px; height: 8px;
  margin: 0 3px;
  border-radius: 50%;
  background: var(--ink);
  animation: pulse 1.4s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

/* ----------------------------------------------------------------- question */

.qhead { display: grid; gap: 10px; }
.qprompt {
  margin: 0;
  font-weight: 800;
  font-size: clamp(1.3rem, 6vw, 1.75rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.media { display: grid; gap: 10px; }
.media--pair { grid-template-columns: 1fr 1fr; }
.media figure { margin: 0; display: grid; gap: 6px; }
.media img { width: 100%; border: 1px solid var(--line); border-radius: 4px; }
.media audio, .media video { width: 100%; border-radius: 4px; }
.media video { border: 1px solid var(--line); background: #000; }
.media figcaption {
  font: 700 0.7rem/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gray);
}

.missing {
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
  min-height: 90px;
  padding: 14px;
  border: 1.5px dashed var(--line);
  border-radius: 4px;
  color: var(--gray);
  font: 600 0.72rem/1.5 var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--paper-2);
}

.stage-note {
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  padding: 26px 18px;
  border: 1.5px solid var(--line);
  border-radius: 4px;
  background: var(--paper-2);
}
.stage-note strong { font-size: 1.15rem; font-weight: 800; }
.stage-note span { color: var(--gray); font-size: 0.9rem; }

/* --------------------------------------------------------------- answering */

.opts { display: grid; gap: 12px; flex: 1; align-content: stretch; }
.opts--binary { grid-template-rows: 1fr 1fr; min-height: 46svh; }

.opt {
  position: relative;
  min-height: var(--tap);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  background: var(--ink);
  border-radius: 6px;
  overflow: hidden;
  transition: transform 0.12s var(--ease), opacity 0.25s, filter 0.25s;
}
.opt__key {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-content: center;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  font: 800 0.85rem/1 var(--mono);
  opacity: 0.75;
}
.opt:active { transform: scale(0.985); }

.opts--binary .opt {
  justify-content: center;
  font-size: clamp(2.2rem, 13vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.opts--binary .opt__key { display: none; }
.opt--real { background: var(--green); }
.opt--fake { background: var(--red); }

/* Depth: buttons sit on a shadow and physically depress when tapped. */
.opt {
  box-shadow: 0 5px 0 0 rgba(0, 0, 0, 0.22);
}
.opt:active:not([disabled]) {
  transform: translateY(4px);
  box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.22);
}

/* Locked-in state: the chosen answer stays lit, the rest recede. */
.opts.is-locked .opt { opacity: 0.32; filter: grayscale(0.7); pointer-events: none; box-shadow: none; }
.opts.is-locked .opt.is-mine { opacity: 1; filter: none; }
.opts.is-locked .opt.is-mine::after {
  content: "✓";
  position: absolute;
  right: 16px;
  font-size: 1.4rem;
}

/* Post-answer states used by the homework reveal, where the buttons stay on
   screen and become the answer key. */
.opt.is-correct {
  background: var(--green);
  opacity: 1;
  box-shadow: 0 0 0 3px var(--green-wash), 0 5px 0 0 var(--green-deep);
}
.opt.is-correct::after { content: "✓"; position: absolute; right: 16px; font-size: 1.4rem; }
.opt.is-wrong {
  background: var(--red);
  opacity: 1;
  box-shadow: 0 0 0 3px var(--red-wash), 0 5px 0 0 var(--red-deep);
}
.opt.is-wrong::after { content: "✗"; position: absolute; right: 16px; font-size: 1.4rem; }
.opt.is-dim { opacity: 0.3; filter: grayscale(0.8); box-shadow: none; }
.opt[disabled] { cursor: default; }

/* Final seconds: the whole screen leans in. */
@keyframes urgent-pulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(210, 35, 42, 0); }
  50%      { box-shadow: inset 0 0 0 6px rgba(210, 35, 42, 0.18); }
}
body.is-urgent { animation: urgent-pulse 1s ease-in-out infinite; }
body.is-urgent .timer { border-color: var(--red); }

.locked {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  font-weight: 800;
  background: var(--paper-2);
}

/* ------------------------------------------------------------------ reveal */

.verdict { display: grid; gap: 20px; place-items: center; text-align: center; padding: 8px 0; }
.verdict__stamp { display: grid; place-items: center; min-height: 120px; }
.verdict__line {
  margin: 0;
  font-weight: 900;
  font-size: clamp(1.5rem, 7vw, 2rem);
  letter-spacing: -0.02em;
}
.verdict.is-right .verdict__line { color: var(--green-deep); }
.verdict.is-wrong .verdict__line { color: var(--red-deep); }

@keyframes flash-right { from { background: var(--green-wash); } to { background: var(--paper); } }
@keyframes flash-wrong { from { background: var(--red-wash); } to { background: var(--paper); } }
body.flash-right { animation: flash-right 1.1s var(--ease) both; }
body.flash-wrong { animation: flash-wrong 1.1s var(--ease) both; }

@keyframes note-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.note {
  margin: 0;
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  background: var(--paper-2);
  font-size: 0.98rem;
  line-height: 1.55;
  animation: note-in 0.5s var(--ease) 0.45s both;
}

.scoreline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.scoreline div { background: var(--paper); padding: 14px; text-align: center; }
.scoreline dt {
  margin: 0 0 4px;
  font: 600 0.6rem/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gray);
}
.scoreline dd {
  margin: 0;
  font-weight: 900;
  font-size: 1.9rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------- ended */

.podium { display: grid; gap: 8px; }

@keyframes podium-in {
  from { opacity: 0; transform: translateX(-24px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.podium__row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  animation: podium-in 0.6s var(--slam) both;
}
.podium__row.is-me { border-color: var(--ink); border-width: 2px; background: var(--paper-2); }
.podium__row:nth-child(1) {
  border-color: var(--accent);
  border-width: 2px;
  box-shadow: 0 6px 24px -10px var(--accent);
}
.podium__rank {
  font: 900 1.1rem/1 var(--sans);
  color: var(--gray);
  font-variant-numeric: tabular-nums;
}
.podium__row:nth-child(1) .podium__rank { color: var(--red); }
.podium__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium__score { font: 800 1rem/1 var(--mono); font-variant-numeric: tabular-nums; }

@media (min-width: 560px) {
  main { max-width: 560px; margin: 0 auto; width: 100%; }
}
