/* Guess Who Game - a bright morning. Sky behind, white cards in front, one
   green button. One column, one hand. Motion is transform + opacity only,
   150-250ms, so nothing reflows mid-animation and the thumb never chases a
   moving button. */

:root {
  --sky-top: #BFE0FA;   /* sky */
  --sky-bottom: #EEF6FD;
  --fg: #17233A;        /* ink */
  --dim: rgba(23, 35, 58, 0.58);
  --card: #FFFFFF;      /* a card */
  --card-2: #F3F7FB;    /* a card on a card */
  --line: #E1EAF3;      /* card edge */
  --accent: #22A85E;    /* the one main action, selection, focus */
  --accent-ink: #FFFFFF;
  --good: #22A85E;      /* walk */
  --bad: #E5484D;       /* stop */
  --shadow: 0 10px 30px rgba(23, 35, 58, 0.10), 0 1px 2px rgba(23, 35, 58, 0.06);
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --display: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* the phone column: full width minus 16px gutters, capped at 520px */
  --col: min(calc(100vw - 32px), 488px);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--sky-bottom);
  background-image: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 55%, #FFFFFF 100%);
  background-attachment: fixed;
  color: var(--fg);
  font: 18px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  display: flex;
  flex-direction: column;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 8px 16px 0;
  padding-top: max(8px, env(safe-area-inset-top));
  height: 100vh;
  height: 100dvh;
}

.screen { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.screen-play { overflow-y: auto; overscroll-behavior: contain; }

/* ---------- title ---------- */

.screen-title { justify-content: center; text-align: center; gap: 8px; overflow-y: auto; }
h1 {
  margin: 0; font-family: var(--display); font-size: 42px; line-height: 1.05;
  letter-spacing: -0.02em; font-weight: 800; color: var(--fg);
}
.sub { margin: 0; color: var(--dim); font-size: 19px; line-height: 1.4; }

.errors {
  margin: 18px 0 0; padding: 14px 16px 14px 32px; text-align: left;
  background: rgba(229, 72, 77, 0.08);
  border: 1px solid rgba(229, 72, 77, 0.35);
  border-radius: 14px; color: #9E2B2F; font-size: 16px; line-height: 1.5;
  overflow-y: auto;
}
.errors li + li { margin-top: 6px; }

/* the title card: the street moving, and the people you will be choosing between */
.hero {
  display: flex; flex-direction: column; gap: 10px; width: 100%; min-height: 0; flex: 0 1 auto;
  margin: 14px 0 0; padding: 10px; border-radius: 26px; background: var(--card); box-shadow: var(--shadow);
}
/* the video the game comes from: upright 9:16, as tall as the screen allows */
.intro { position: relative; width: 100%; }
.introvid {
  display: block; width: 100%; border-radius: 18px; background: #0B1220; object-fit: cover;
  height: min(calc((var(--col) - 20px) * 16 / 9), 58vh);
}
.intro .introsound { position: absolute; top: 10px; right: 10px; cursor: pointer; }
.intro .introsound:active { opacity: 0.7; }
.credit { margin: 0; font-size: 15px; color: var(--dim); }
.credit a { color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }

.teaser {
  display: block; width: 100%;
  height: min(calc((var(--col) - 20px) * 4 / 3), 50vh);
  object-fit: cover; border-radius: 18px; background: #0B1220;
}
.faces { display: flex; gap: 10px; justify-content: center; width: 100%; flex: 0 0 auto; }
.face { flex: 0 1 120px; min-width: 0; }
.face img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; background: var(--card-2); }
.face span { display: block; margin-top: 6px; font: 600 15px/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.legal { margin: 24px 0 0; font-size: 15px; }
.terms {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 12px; color: var(--dim);
  text-decoration: underline; text-underline-offset: 3px;
  transition: opacity 150ms var(--ease);
}
.terms:active { opacity: 0.6; }

/* ---------- stage: a white card holding the clip ---------- */

.stage-wrap {
  flex: 0 0 auto; display: flex; flex-direction: column;
  padding: 10px 10px 12px; border-radius: 26px;
  background: var(--card); box-shadow: var(--shadow);
}

/* the stage fills the card's width; the footage (3:4, upright, from the
   glasses) covers it edge to edge, so there are never bars */
.stage {
  position: relative; flex: 0 0 auto; width: 100%;
  height: min(calc((var(--col) - 20px) * 4 / 3), 62vh);
  background: #0B1220; border-radius: 18px; overflow: hidden;
  box-shadow: 0 0 0 0 transparent;
  transition: box-shadow 220ms var(--ease);
}
/* the frame answers with the pedestrian signal: walk green, stop red */
.stage.good { box-shadow: 0 0 0 4px var(--good); }
.stage.bad { box-shadow: 0 0 0 4px var(--bad); }

.vid, .poster, .still {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0;
  transition: opacity 180ms var(--ease);
}
.vid.on, .poster.on, .still.on { opacity: 1; }
.poster { z-index: 1; }
.vid { z-index: 2; }
/* a picked or revealed person, shown full-frame over the paused clip; anchored
   to the top so a squarer stage crops the feet, never the head */
.still { z-index: 3; background: #0B1220; object-position: 50% 0; }

/* a soft floor so the caption and the time bar stay readable over bright footage */
.stage::after {
  content: ""; position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; height: 36%;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.55) 100%);
  pointer-events: none;
}

.stage-top {
  position: absolute; z-index: 5; top: 10px; left: 10px; right: 10px;
  display: flex; align-items: flex-start; justify-content: space-between;
  pointer-events: none;
}

.pill {
  position: relative; display: inline-flex; align-items: center;
  height: 38px; padding: 0 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.92); border: 1px solid rgba(255, 255, 255, 0.6);
  color: var(--fg); font: 600 16px/1 var(--display);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
/* invisible 44px+ hit area around the sound pill */
.mute::before { content: ""; position: absolute; inset: -6px -10px; }
.mute { pointer-events: auto; cursor: pointer; }
.mute { transition: opacity 150ms var(--ease); }
.mute:active { opacity: 0.7; }

/* the bottom row: caption and seconds left; the time bar runs under them */
.stage-bottom {
  position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 30px;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
}
.left {
  flex: 0 0 auto; height: 34px; padding: 0 12px; min-width: 52px; justify-content: center;
  font-variant-numeric: tabular-nums;
}
.left:empty { visibility: hidden; }


.caption {
  flex: 1 1 auto; min-width: 0; margin: 0;
  font-family: var(--display); font-size: 19px; font-weight: 700; color: #fff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9);
  opacity: 0; transform: translateY(4px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.caption.on { opacity: 1; transform: none; }

/* the time bar: a track along the bottom of the clip that fills as it plays,
   so you can see when it will end. Tap or drag it to jump around the clip. */
.progress {
  position: absolute; z-index: 5; left: 12px; right: 12px; bottom: 8px; height: 16px;
  overflow: hidden; border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  cursor: pointer; touch-action: none;
}
/* an invisible 44px-tall hit area, so a thumb lands on it */
.progress::before { content: ""; position: absolute; left: 0; right: 0; top: -14px; bottom: -14px; }
.progress i {
  display: block; height: 100%; border-radius: 999px;
  background: #fff; transform: scaleX(0); transform-origin: 0 50%;
}

/* the look ring: circles a passer-by for the moment they looked at the camera */
.ring {
  position: absolute; z-index: 4; pointer-events: none;
  border: 3px solid #FFB020; border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(0, 0, 0, 0.35);
  opacity: 0; transform: scale(0.8);
  transition: opacity 120ms var(--ease), transform 120ms var(--ease);
}
.ring.on { opacity: 1; transform: none; animation: ringpulse 900ms ease-in-out infinite; }
@keyframes ringpulse { 0%, 100% { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), inset 0 0 0 2px rgba(0, 0, 0, 0.35); } 50% { box-shadow: 0 0 0 6px rgba(255, 176, 32, 0.35), inset 0 0 0 2px rgba(0, 0, 0, 0.35); } }
.ringtag {
  position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px);
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: #FFB020; color: #17233A; font: 700 12px/1.4 var(--display);
}

/* the zebra crossing: one painted stripe per round. Grey = ahead, blue = now,
   walk green = right, stop red = wrong. */
.stripes { display: flex; gap: 8px; flex: 0 0 auto; height: 12px; margin-top: 12px; padding: 0 2px; }
.stripes i, .sq { display: block; flex: 1 1 0; border-radius: 999px; background: #DCE7F2; }
.stripes i.now { background: #3B82F6; animation: paint 1.6s ease-in-out infinite; }
.stripes i.hit, .sq.hit { background: var(--good); }
.stripes i.miss, .sq.miss { background: var(--bad); }
@keyframes paint { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.load { position: absolute; z-index: 6; left: 0; right: 0; top: 0; height: 3px; overflow: hidden; opacity: 0; transition: opacity 150ms var(--ease); }
.load.on { opacity: 1; }
.load::after {
  content: ""; position: absolute; top: 0; left: 0; height: 100%; width: 35%;
  background: rgba(255, 255, 255, 0.85); animation: slide 1.1s linear infinite;
}
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(320%); } }

.stagemsg {
  position: absolute; z-index: 7; left: 14px; right: 14px; top: 50%;
  transform: translateY(-50%); text-align: center;
  padding: 14px 16px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line);
  color: var(--fg); font-size: 16px; line-height: 1.4; word-break: break-word;
  box-shadow: var(--shadow);
}

/* ---------- question + options ---------- */

.question { margin: 16px 4px 10px; font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--fg); }

.options { display: flex; gap: 12px; align-items: flex-start; }

.option {
  flex: 1 1 0; min-width: 0; padding: 0; border: 0; background: none;
  color: var(--fg); font: inherit; text-align: center; cursor: pointer;
  opacity: 0; transform: translateY(10px); visibility: hidden;
  transition: opacity 220ms var(--ease), transform 220ms var(--ease), visibility 0s linear 220ms;
}
.options.in .option { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.options.in .option:nth-child(2) { transition-delay: 45ms; }
.options.in .option:nth-child(3) { transition-delay: 90ms; }
.options.in .option:nth-child(4) { transition-delay: 135ms; }
.options.done .option { pointer-events: none; }
.options.in .option.wrong { opacity: 0.6; }   /* must outrank .options.in .option */

.card {
  position: relative; display: block; width: 100%; aspect-ratio: 3 / 4;
  max-height: 26vh;   /* short screens: the cards squash rather than hide under the button */
  min-height: 44px; border-radius: 18px; overflow: hidden;
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 160ms var(--ease);
}
.option:active .card { transform: scale(0.97); }
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: 18px;
  border: 4px solid var(--ring, transparent); opacity: 0; pointer-events: none;
  transition: opacity 180ms var(--ease);
}
.option[aria-checked="true"] .card::after { --ring: #3B82F6; opacity: 1; }
.option.correct .card::after { --ring: var(--good); opacity: 1; }
.option.wrong .card::after { --ring: var(--bad); opacity: 1; }
.option.wrong .card { animation: shake 250ms var(--ease); }
@keyframes shake {
  0% { transform: translateX(0); } 17% { transform: translateX(-4px); }
  34% { transform: translateX(4px); } 50% { transform: translateX(-4px); }
  67% { transform: translateX(4px); } 84% { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}

.photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 0; }
.tile {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-family: var(--display); font-size: 17px; font-weight: 600;
  background: var(--card-2);
}
.olabel { display: block; margin-top: 8px; font-family: var(--display); font-size: 19px; font-weight: 600; }

/* ---------- score ---------- */

.screen-score { justify-content: flex-start; align-items: center; gap: 14px; padding: 18px 16px 12px; text-align: center; overflow-y: auto; border-radius: 26px; background: var(--card); box-shadow: var(--shadow); }
.screen-score > * { flex: 0 0 auto; }   /* a scrolling column must not squash the stripes to 0px */
.score { margin: 0; font-family: var(--display); font-size: 64px; line-height: 1; font-weight: 800; letter-spacing: -0.03em; }

/* the people they tapped: green ring and tick when right, red ring and cross when wrong */
.picks { display: flex; gap: 8px; width: 100%; justify-content: center; }
.pick { flex: 0 1 140px; min-width: 0; text-align: center; }
.pcard {
  position: relative; display: block; width: 100%; aspect-ratio: 3 / 4;
  border-radius: 14px; overflow: hidden; background: var(--card-2);
  border: 3px solid var(--bad);
}
.pick.right .pcard { border-color: var(--good); }
.pcard .tile { font-size: 15px; }
.pcard .photo + .tile { display: none; }
.mark {
  position: absolute; z-index: 2; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bad); color: #fff; font: 800 14px/24px var(--display); text-align: center;
}
.pick.right .mark { background: var(--good); }
.pname {
  display: block; margin-top: 5px; font: 600 14px/1.2 var(--display);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* the message they will send, shown before they send it */
.sharetext {
  display: block; width: 100%; min-height: 92px; padding: 12px 14px; margin: 0;
  border-radius: 14px; border: 1px solid var(--line); background: var(--card-2); color: var(--fg);
  font: 16px/1.45 var(--body); text-align: left; white-space: pre-wrap; resize: none;
}
.sharetext:focus { border-color: var(--accent); outline: none; }
.squares { display: flex; gap: 8px; width: min(100%, 280px); height: 14px; }
.sq { background: var(--bad); }
.total { margin: 0; color: var(--dim); font-size: 19px; font-weight: 600; }

/* ---------- share box, under the picks on the last score ---------- */

.sharebox { display: flex; flex-direction: column; gap: 10px; width: 100%; text-align: left; padding-bottom: 8px; }

.field {
  width: 100%; height: 52px; padding: 0 16px;
  border-radius: 14px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--fg);
  font: 18px/1 var(--body); text-align: center;
  transition: border-color 150ms var(--ease);
}
.field::placeholder { color: var(--dim); }
.field:focus { border-color: var(--accent); outline: none; }
.sharemsg { margin: 0; min-height: 22px; font-size: 15px; line-height: 22px; color: var(--dim); text-align: center; }
.sharemsg.bad { color: var(--bad); }

/* ---------- buttons: 60px, 20px text, green for the one main action ---------- */

.actions { flex: 0 0 auto; padding: 14px 0; padding-bottom: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.slot { position: relative; height: 60px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 60px; width: 100%; border: 0; border-radius: 18px;
  background: var(--accent); color: var(--accent-ink);
  font: 700 20px/1 var(--display); cursor: pointer;
  box-shadow: 0 8px 20px rgba(34, 168, 94, 0.30);
  transition: transform 160ms var(--ease), opacity 160ms var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.btn:disabled:active { transform: none; }

.slot .btn {
  position: absolute; inset: 0;
  opacity: 0; transform: scale(0.98); visibility: hidden; pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease), visibility 0s linear 180ms;
}
.slot .btn.show { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.slot .btn.show:active { transform: scale(0.985); }
.slot .btn.show:disabled { opacity: 0.35; }          /* beats .slot .btn.show, so disabled really looks disabled */
.slot .btn.show:disabled:active { transform: none; }
/* on the score screen Share is the main action, so Play again steps back */
.slot #again { background: var(--card); color: var(--fg); border: 1px solid var(--line); box-shadow: var(--shadow); }

.btn.ghost {
  height: 60px; width: auto; min-width: 168px; padding: 0 22px;
  background: var(--card); color: var(--fg); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.btn.ghost.wide { width: 100%; }
.btn.ghost.small { flex: 0 0 auto; height: 54px; min-width: 0; padding: 0 16px; font-size: 17px; }
.btn.busy { opacity: 0.55; }
.btn.busy:active { transform: none; }

:focus-visible { outline: 3px solid #3B82F6; outline-offset: 3px; }

/* ---------- desktop ---------- */

@media (min-width: 600px) and (min-height: 700px) {
  h1 { font-size: 52px; }
  .app { padding-top: 24px; }
}

/* ---------- reduced motion: state changes stay, movement goes ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; transition-delay: 0ms !important;
  }
  .option, .caption, .slot .btn, .ring { transform: none !important; }
  .load::after { animation: none; width: 100%; opacity: 0.35; }
  .stripes i.now, .ring.on { animation: none; }
}
