*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --surface:      #ffffff;
  --surface-hi:   #f8f9fa;
  --border:       #dadce0;
  --text:         #202124;
  --text-muted:   #5f6368;
  --green:        #188038;
  --green-border: #34a853;
  --red:          #c5221f;
  --red-border:   #ea4335;
  --accent:       #1a73e8;
  --accent-dim:   #e8f0fe;
  --blue-header:  #1a73e8;
  /* End card / narrow widget width */
  --widget-w: clamp(280px, 28vw, 420px);
}

html, body {
  height: 100%;
}

body {
  background-color: #edf2fb;
  color: var(--text);
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

/* ── Loading ─────────────────────────────────────── */

#loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Game screen — flex row: [viewer] [captcha] ───── */

#game-screen {
  display: flex;
  flex-direction: row;
  align-items: stretch; /* viewer height = captcha widget height */
  gap: 20px;
  position: relative;
  z-index: 60;
}

/* ── Preview panel (left of the widget) ─────────── */

#img-viewer {
  width: calc(2 * var(--widget-w));
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 3px 12px rgba(0,0,0,0.09);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#img-viewer-inner {
  flex: 1;
  min-height: 0; /* prevent flex blowout from tall images */
  background: var(--surface-hi);
  overflow: hidden;
  position: relative;
}

/* Two stacked layers (image + its fill): the incoming one fades in over the outgoing one */
.viewer-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.09s linear;
}
.viewer-layer.on { opacity: 1; }
.viewer-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#img-viewer-footer {
  padding: 0.6rem 1rem;
  min-height: 2.75rem;
  border-top: 1px solid var(--border);
  background: var(--surface-hi);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

#img-viewer-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Which option is being previewed: same badge as on the image, large, on the preview itself */
#viewer-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
#viewer-badge:empty { visibility: hidden; }

/* ── Captcha widget ──────────────────────────────── */

#captcha-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 3px 12px rgba(0,0,0,0.09);
  width: var(--widget-w);
  max-width: calc(100vw - 2rem);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: clamp(480px, 88vh, 780px);
}

/* ── Blue header ─────────────────────────────────── */

#captcha-header {
  position: relative;
  background: var(--blue-header);
  padding: 1rem 1.25rem 1.1rem;
  color: white;
}

#prompt-pre {
  font-size: 0.99rem;
  font-weight: 400;
  opacity: 0.88;
  margin-bottom: 0.25rem;
  letter-spacing: 0.01em;
}

#question-title {
  font-size: 1.38rem;
  font-weight: 700;
  line-height: 1.3;
}

/* ── Progress strip ──────────────────────────────── */

#progress-strip {
  padding: 0.55rem 1rem 0.6rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

#progress-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

#progress-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

#progress-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 22px;
  height: 22px;
  color: var(--border);
  transition: color 0.3s ease;
}

.dot svg { width: 100%; height: 100%; display: block; }

.dot.correct  { color: var(--green-border); }
.dot.wrong    { color: var(--red-border); }
.dot.current  { color: var(--accent); }

/* ── Round content (animation wrapper) ───────────── */

#round-content {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

/* ── Image options ───────────────────────────────── */

#options-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #fff;
  flex: 1;
  min-height: 0;
}

.option-img-wrap {
  position: relative;
  flex: 1;
  min-height: 80px;
  cursor: pointer;
  background: #fff;
  overflow: hidden;
}

/* Picture = image + its edge-colour fill, inside the white frame. Every fade and
   greying applies to this one box, so the fill can never drift from the image. */
.option-pic {
  position: absolute;
  inset: 7px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--fill, var(--surface-hi));
  transition: opacity 0.2s ease, filter 0.2s ease;
}

/* While the pointer is over the options, the others step back: easy to keep track
   of which one you're on while looking at the big preview */
/* (Mouse only: on phones a tap answers, with no hover highlight or dimming first) */
@media (hover: hover) {
  #options-container:hover .option-img-wrap:not(:hover):not(.disabled) .option-pic { opacity: 0.45; }
  .option-img-wrap:not(.disabled):hover .option-badge { transform: scale(1.12); }
}

/* Hover/correct/wrong borders via ::after so they paint ABOVE the image */
.option-img-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  box-shadow: inset 0 0 0 3px transparent;
  transition: box-shadow 0.12s;
}

@media (hover: hover) {
  .option-img-wrap:not(.disabled):hover::after {
    box-shadow: inset 0 0 0 4px var(--accent);
  }
}

/* Number badge: marks each image as a choice and matches the 1/2/3 keys */
.option-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

@media (hover: hover) {
  .option-img-wrap:not(.disabled):hover .option-badge {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }
}

.option-img-wrap.correct .option-badge {
  background: var(--green-border);
  border-color: var(--green-border);
  color: #fff;
}

.option-img-wrap.wrong .option-badge {
  background: var(--red-border);
  border-color: var(--red-border);
  color: #fff;
}

.option-img-wrap.correct::after {
  box-shadow: inset 0 0 0 3px var(--green-border);
}

.option-img-wrap.wrong::after {
  box-shadow: inset 0 0 0 3px var(--red-border);
}

.option-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.option-img-wrap.loading .option-pic {
  opacity: 0;
}

.option-spinner {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
}

.option-img-wrap.loading .option-spinner {
  display: flex;
}

.option-spinner::after {
  content: '';
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.img-overlay {
  position: absolute;
  inset: 7px; /* tint the picture, not the white frame */
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  transition: opacity 0.18s;
}

.option-img-wrap.correct .img-overlay {
  background: rgba(52, 168, 83, 0.18);
  opacity: 1;
}

.option-img-wrap.wrong .img-overlay {
  background: rgba(234, 67, 53, 0.15);
  opacity: 1;
}

.option-img-wrap { cursor: pointer; }
.option-img-wrap.disabled { cursor: default; }




/* Once answered, options that aren't part of the answer step back */
.option-img-wrap.disabled:not(.correct):not(.wrong):not(.answer) .option-pic {
  opacity: 0.3;
  filter: grayscale(1);
}
.option-img-wrap.disabled:not(.correct):not(.wrong):not(.answer) .option-badge { opacity: 0.4; }

/* "This was the answer" after a miss: a green "Answer" label in the corner, no border */
.option-img-wrap.answer .option-badge {
  width: auto;
  padding: 0 10px 0 6px;
  gap: 4px;
  border-radius: 13px;
  background: var(--green-border);
  border-color: var(--green-border);
  color: #fff;
  font-size: 12px;
}
.option-img-wrap.answer .img-overlay { background: rgba(52,168,83,0.1); opacity: 1; }

.option-img-wrap.correct::after,
.option-img-wrap.wrong::after { transition: box-shadow 0.15s; }
.option-img-wrap.correct::after { box-shadow: inset 0 0 0 4px var(--green-border) !important; }
.option-img-wrap.wrong::after   { box-shadow: inset 0 0 0 4px var(--red-border) !important; }

@keyframes badgePop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.option-img-wrap.correct .option-badge,
.option-img-wrap.wrong .option-badge { animation: badgePop 0.32s ease-out; }

/* ── Round change: tiles fade out in sequence, the header swaps, new tiles fade in ── */
.option-img-wrap { transition: opacity 0.2s ease, transform 0.2s ease; }
#question-title { transition: opacity 0.2s ease, transform 0.2s ease; }

#captcha-widget.swapping .option-img-wrap { opacity: 0; transform: scale(0.97); }
#captcha-widget.swapping #question-title  { opacity: 0; transform: translateY(-4px); }
#captcha-widget.swapping #opt-1 { transition-delay: 0.04s; }
#captcha-widget.swapping #opt-2 { transition-delay: 0.08s; }

@keyframes tileIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes titleIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
/* New round: the robot's name arrives first, the images follow */
#captcha-widget.arriving #question-title { animation: titleIn 0.24s ease-out both; }
#captcha-widget.arriving .option-img-wrap { animation: tileIn 0.26s ease-out 0.2s both; }
#captcha-widget.arriving #opt-1 { animation-delay: 0.26s; }
#captcha-widget.arriving #opt-2 { animation-delay: 0.32s; }

/* Last answer: the whole game steps away before the end view */
#game-screen { transition: opacity 0.35s ease, transform 0.35s ease; }
#game-screen.leaving { opacity: 0; transform: scale(0.98); }

/* Phones: full-screen button on each option (hidden where the preview panel exists) */
.option-zoom {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: rgba(32,33,36,0.55);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
}
.option-img-wrap.disabled .option-zoom { display: none !important; }

/* Share this image, any time (answered or not): on the desktop preview, and in the phones'
   full-screen view */
/* Desktop: a small icon, faint until you hover the preview */
#viewer-share {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 50%;
  background: rgba(32,33,36,0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease, background 0.15s ease;
}
#img-viewer:hover #viewer-share { opacity: 1; }
#viewer-share:hover { background: var(--accent); }
#viewer-share[hidden] { display: none; }
#zoom-share {
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 7px;
  font: 500 1rem Roboto, sans-serif;
  cursor: pointer;
  position: fixed;
  right: 16px;
  bottom: max(16px, env(safe-area-inset-bottom));
  height: 44px;
  padding: 0 18px 0 14px;
  border-radius: 22px;
  background: rgba(255,255,255,0.15);
  font-size: 1rem;
}


/* Share preview (desktop): the card, with Copy / Save */
#share-view {
  position: fixed;
  inset: 0;
  z-index: 420;
  background: rgba(32,33,36,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#share-view[hidden] { display: none; }
#share-panel {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  width: min(460px, 100%);
}
#share-heading { font-size: 0.95rem; font-weight: 500; margin: 2px 2px 10px; color: var(--text); }
/* The card sits on a grey mat with a shadow, so it reads as a picture, not more page */
#share-frame { background: #e8eaed; border-radius: 6px; padding: 18px; }
#share-img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 3px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.22);
}
#share-actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
#share-copy, #share-save {
  flex: 1;
  height: 40px;
  border-radius: 6px;
  font: 500 0.92rem Roboto, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
}
#share-copy { border: none; background: var(--accent); color: #fff; }
#share-copy[hidden] { display: none; }
#share-save { border: 1px solid var(--border); color: var(--accent); background: #fff; }
#share-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 6px;
  background: var(--surface-hi);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Phones: one option full screen, plain black, no animation */
#zoom-view {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#zoom-view[hidden] { display: none; }
#zoom-img { max-width: 100%; max-height: 100%; object-fit: contain; }
#zoom-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Captcha footer ──────────────────────────────── */

#captcha-footer {
  gap: 0.35rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-hi);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  min-height: 2.75rem;
}

/* Quiet way back to the landing page */
#back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  margin-left: -6px;
  transition: background 0.15s, color 0.15s;
}
#back-btn svg { width: 14px; height: 14px; }
#back-btn:hover { background: #eceff3; color: var(--text); }

/* Reads as an address: regular weight, light underline */
#footer-brand {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: #c6cad1;
  text-underline-offset: 3px;
}
#footer-brand:hover { color: var(--accent); text-decoration-color: currentColor; }

#footer-brand strong {
  font-weight: 900;
}

.about-btn {
  margin-left: auto;
  /* Just the ? circle, against the footer's right edge. The padding is a bigger tap area;
     the negative margin keeps the circle itself lined up with the edge. */
  margin-right: -4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 4px;
  background: none;
  color: var(--text-muted);
  border: none;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.about-icon { transition: background 0.15s; }
.about-btn:hover .about-icon, .about-btn[aria-expanded="true"] .about-icon { background: #5f6368; }

.about-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #9aa0a6;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

#about-pop {
  position: fixed;
  z-index: 200;
  width: 280px;
  padding: 0.75rem 0.9rem;
  background: #3c4043;
  color: #f1f3f4;
  border-radius: 6px;
  font-size: 0.82rem;
  line-height: 1.45;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

#about-pop a { color: #8ab4f8; }

#dev-replay-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0.2rem 0.5rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 1.08rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.15s;
}

#dev-replay-btn:hover { opacity: 1; }

/* ── End screen ──────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Mirrors the landing page: title card left, result where the checkbox was */
#end-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 75px;
  animation: fadeIn 0.4s ease-out both;
  position: relative;
  z-index: 60;
}

#end-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 3px 12px rgba(0,0,0,0.09);
  width: var(--widget-w);
  max-width: calc(100vw - 2rem);
  overflow: hidden;
}

#end-card { display: flex; flex-direction: column; }

#end-header {
  background: var(--blue-header);
  color: #fff;
  padding: 1rem 1.25rem 1.15rem;
}

/* Same treatment as the "I'm a Robot" title on the title card */
#end-title {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.7rem;
}

#verdict-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
#end-sub { font-size: 0.82rem; opacity: 0.85; }


#end-body { padding: 1rem 1.25rem 1.25rem; }

/* 6/6: robot heads burst out of the verdict box */
.confetti { position: fixed; z-index: 250; pointer-events: none; }
.confetti span {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  animation: burst 1.4s cubic-bezier(0.15, 0.7, 0.3, 1) forwards;
}
.confetti svg { width: 100%; height: 100%; display: block; }
@keyframes burst {
  0%   { transform: translate(0, 0) scale(0.3) rotate(0); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translate(var(--dx), calc(var(--dy) + 40px)) scale(1) rotate(var(--rot)); opacity: 0; }
}

/* Tally on the right of the verdict header */
#end-score { margin-left: auto; font-size: 1.45rem; font-weight: 700; color: #fff; opacity: 0.9; white-space: nowrap; }

#end-footer .about-btn { margin-right: -4px; }

#end-footer {
  flex-wrap: wrap;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface-hi);
}

/* ── Verdict row: [checkbox] [label] ─────────────── */

#verdict-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

#verdict-cb {
  width: 40px;
  height: 40px;
  border: 2px solid #fff;
  border-radius: 3px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  transition: background 0.25s ease, border-color 0.25s ease;
}

#verdict-spinner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2.5px solid #e0e0e0;
  border-top-color: #4285f4;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  opacity: 0;
  transition: opacity 0.12s ease;
}

#verdict-cb.loading #verdict-spinner { opacity: 1; }

/* A white checkbox on the blue header; the verdict appears inside as a robot, a sad human,
   or half of each */
#verdict-cb.robot, #verdict-cb.human, #verdict-cb.inconclusive { background: #fff; border-color: #fff; }
#verdict-icon { display: none; width: 30px; height: 30px; }
#verdict-icon svg { width: 100%; height: 100%; display: block; }
#verdict-cb.robot #verdict-icon, #verdict-cb.human #verdict-icon, #verdict-cb.inconclusive #verdict-icon {
  display: block;
  animation: badgePop 0.3s ease-out;
}
#verdict-cb.robot #verdict-icon        { color: #34a853; }
#verdict-cb.human #verdict-icon        { color: #ea4335; }
#verdict-cb.inconclusive #verdict-icon { color: #f9ab00; }

/* Checkmark */
/* Verdict text: white on the blue header, same face as the title */
#verdict-label {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
  text-align: left;
}

/* ── End reveal (shown after verdict animation) ──── */

#end-reveal {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.9rem;
  width: 100%;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#end-reveal.visible { opacity: 1; }

/* ── Emoji / share ───────────────────────────────── */

#copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 42px;
  padding: 0 1rem;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: opacity 0.15s, box-shadow 0.15s;
}

#copy-btn:hover  { opacity: 0.9; box-shadow: 0 1px 4px rgba(26,115,232,0.4); }
#copy-btn { transition: background 0.2s, opacity 0.15s, box-shadow 0.15s; }
#copy-btn.copied { background: var(--green-border); }
#copy-btn:active { opacity: 1; }

/* ── Today's players: the crowd between human and robot ── */
#crowd-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}
#crowd-title { font-size: 0.95rem; font-weight: 700; color: var(--text); }
#crowd-count { font-size: 0.78rem; color: var(--text-muted); }

#crowd-chart { display: block; width: 100%; height: auto; overflow: visible; }
#crowd-chart .bar { fill: #c7cfdc; }
#crowd-chart .bar.you.robot        { fill: #34a853; }
#crowd-chart .bar.you.inconclusive { fill: #f9ab00; }
#crowd-chart .bar.you.human        { fill: #ea4335; }
#crowd-chart .count { font: 500 9.5px Roboto, sans-serif; fill: #80868b; text-anchor: middle; }
#crowd-chart .count.you { font-weight: 700; fill: var(--text); }
#crowd-chart .tick { font: 700 10px Roboto, sans-serif; fill: #9aa0a6; text-anchor: middle; }
#crowd-chart .tick.you { fill: var(--text); }
#crowd-chart .you-label { font: 700 9.5px Roboto, sans-serif; fill: var(--text); text-anchor: middle; }

#crowd-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 8px; /* clear of the "you" under an end bar */
}
.crowd-end {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 700;
}
.crowd-end svg { width: 20px; height: 20px; }
.crowd-end.human { color: #d93025; }
.crowd-end.robot { color: var(--green); }

#crowd-caption {
  margin-top: 0.35rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text);
}
#crowd-caption strong { font-size: 1.05rem; }

#countdown-container {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#countdown {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

#dev-newgame-btn {
  padding: 0.3rem 0.7rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
}

#dev-newgame-btn:hover { opacity: 1; }

/* ── Intro overlay ───────────────────────────────── */

#intro-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Tallest viewport (phone URL bar hidden), like the backdrop: the bar coming and going
     doesn't re-centre the cards */
  height: 100vh;
  height: 100lvh;
  z-index: 50;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 75px;
  pointer-events: none;
}


@keyframes introPulse {
  0%, 100% { box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 3px 12px rgba(0,0,0,0.09); }
  50%       { box-shadow: 0 0 0 4px rgba(66,133,244,0.25), 0 1px 3px rgba(0,0,0,0.08), 0 3px 12px rgba(0,0,0,0.09); }
}

#intro-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  /* Everything inside is sized as N × --z rather than using CSS zoom: zoom rounds child
     positions to whole pixels, which made the logo's eyes jump instead of glide */
  --z: 1.215;
  width: calc(var(--z) * clamp(260px, 28vw, 340px));
  height: calc(var(--z) * clamp(64px, 8vh, 82px));
  display: flex;
  align-items: center;
  padding: 0 calc(var(--z) * clamp(10px, 1.5vw, 16px));
  gap: calc(var(--z) * clamp(10px, 1.5vw, 16px));
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 3px 12px rgba(0,0,0,0.09);
  opacity: 0;
  transform: scale(0.94);
  transition: opacity 0.22s ease, transform 0.22s ease;
  cursor: pointer;
  pointer-events: auto;
}

#intro-box.pulse {
  animation: introPulse 1.8s ease-in-out infinite;
}

#intro-box.clicked {
  animation: introPulse 0.3s ease-out 1;
}

#intro-box.visible {
  opacity: 1;
  transform: scale(1);
}

#intro-cb-wrap { flex-shrink: 0; }

#intro-cb {
  width: calc(var(--z) * 28px);
  height: calc(var(--z) * 28px);
  border: calc(var(--z) * 2px) solid #c1c1c1;
  border-radius: 2px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
}

#intro-spinner {
  position: absolute;
  width: calc(var(--z) * 18px);
  height: calc(var(--z) * 18px);
  border: calc(var(--z) * 2.5px) solid #e0e0e0;
  border-top-color: #4285f4;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  opacity: 0;
  transition: opacity 0.12s ease;
}

#intro-cb.loading #intro-spinner { opacity: 1; }

#intro-qmark {
  position: absolute;
  color: white;
  font-size: calc(var(--z) * 15px);
  font-weight: 700;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.18s ease 0.05s;
  user-select: none;
}

#intro-cb.checked {
  background: #9aa0a6;
  border-color: #9aa0a6;
}

#intro-cb.checked #intro-qmark { opacity: 1; }

#intro-context {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 3px 12px rgba(0,0,0,0.09);
  overflow: hidden;
  text-align: right;
  width: clamp(260px, 28vw, 340px);
  zoom: 1.215;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

@keyframes fadeUpOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-40px); }
}

#intro-context.hide {
  animation: fadeUpOut 0.45s ease forwards;
  pointer-events: none;
}

#intro-context-header {
  background: var(--blue-header);
  padding: 1rem 1.25rem 1.1rem;
  color: white;
}

#intro-context-body {
  padding: 1rem 1.25rem 1.1rem;
}

#intro-title {
  font-size: 2.55rem;
  font-weight: 700;
  line-height: 1.3;
}

#intro-byline {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  font-weight: 400;
  opacity: 0.8;
  color: white;
}

#intro-byline a {
  color: inherit;
  text-decoration: underline dotted;
  pointer-events: auto;
}

#intro-desc {
  margin-top: 0;
  font-size: 1.014rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* Footer strip of the title card: challenge + time left | streak + last 7 days */
#intro-context-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface-hi);
}

#intro-challenge { display: flex; align-items: center; gap: 0.55rem; }

#intro-challenge-no {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

#intro-when { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; }
#intro-date { font-size: 0.85rem; font-weight: 700; color: var(--text); }
#intro-expires { font-size: 0.75rem; color: var(--text-muted); }

#intro-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  font-size: calc(var(--z) * 14px);
  /* font-weight: 700; */
  /* font-style: italic; */
  color: #202124;
  letter-spacing: 0.01em;
}

#intro-brand-area {
  flex-shrink: 0;
  width: calc(var(--z) * 84px);
  margin-right: calc(-1 * var(--z) * clamp(10px, 1.5vw, 16px)); /* use the box's right padding too */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0 4px;
  border-left: 1px solid var(--border);
}

#intro-logo {
  width: calc(var(--z) * 24px);
  height: calc(var(--z) * 24px);
  color: #4285f4;
  display: block;
  margin-bottom: 1px;
}

#intro-recaptcha-name {
  font-size: calc(var(--z) * 10px);
  font-weight: 500;
  color: #5f6368;
  letter-spacing: 0.04em;
}

#intro-recaptcha-sub {
  font-size: calc(var(--z) * 8px);
  color: #9aa0a6;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* The joke, in the checkbox's own small print */
#intro-label small {
  margin-top: 1px;
  font-size: calc(var(--z) * 10px);
  font-style: italic;
  color: #80868b;
}

/* roBOTCHA's robot: blinks, and its antenna light glows */
@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95%           { transform: scaleY(0.1); }
}
@keyframes bulb {
  0%, 100% { fill: #4285f4; }
  50%      { fill: #ea4335; }
}
#intro-logo-wrap { position: relative; display: block; width: calc(var(--z) * 24px); height: calc(var(--z) * 24px); margin-bottom: 1px; line-height: 0; }
#intro-logo-wrap #intro-logo { margin: 0; }
.logo-eye {
  position: absolute;
  top: 47.9%;                      /* eye centre, 11.5 of 24 */
  width: 15.8%;                    /* 3.8 of 24 */
  aspect-ratio: 1;
  margin: -7.9% 0 0 -7.9%;
  will-change: transform;
}
.logo-eye i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  animation: blink 3.6s infinite;
}
#intro-logo .bulb { animation: bulb 1.6s ease-in-out infinite; }

/* Title card: the six robots you're about to name + live player count */
#intro-heads {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 0.6rem;
}
#intro-heads .dot { width: 24px; height: 24px; color: #c6cad1; }
#intro-heads .dot.correct { color: var(--green-border); }
#intro-heads .dot.wrong   { color: var(--red-border); }
#intro-players {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
#intro-players strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* Returning players: streak + last 7 challenges, under the strip */
#intro-history {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.1;
}
#intro-history[hidden] { display: none; }

#intro-streak strong { color: var(--text); font-size: 0.85rem; }

/* The title card sits in a pointer-transparent overlay: let the squares be hovered */
#intro-week .wk { pointer-events: auto; }

/* Small dark tooltip */
#tip {
  position: fixed;
  z-index: 200;
  padding: 4px 9px;
  border-radius: 4px;
  background: #3c4043;
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

#intro-week { display: flex; gap: 4px; }

.wk {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--border);
}

.wk { border: 1.5px solid transparent; }
.wk.robot        { background: #e6f4ea; border-color: #34a853; }
.wk.inconclusive { background: #fef7e0; border-color: #f9ab00; }
.wk.human        { background: #fce8e6; border-color: #ea4335; }
.wk.missed       { background: transparent; border: 1.5px solid var(--border); }
.wk.today        { background: transparent; border: 1.5px dashed var(--accent); }
.wk.none         { background: transparent; border: 1.5px dotted #c9cdd3; }

/* Privacy · Terms: hover shows a binary message, readable by robots only */
.robo-link { position: relative; cursor: help; }
.robo-link:hover { color: var(--text-muted); text-decoration: underline; }
#robo-tip {
  position: fixed;
  z-index: 200;
  padding: 6px 9px;
  background: #3c4043;
  color: #e8eaed;
  border-radius: 4px;
  font: 11px/1.5 ui-monospace, 'Roboto Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.03em;
  white-space: pre;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  user-select: text;
  cursor: text;
}

/* ── Intro error state: reCAPTCHA's red "please verify" ─ */

#intro-box-wrap {
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

#intro-error {
  zoom: 1.215;
  margin-top: 6px;
  padding-left: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--accent);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Backdrop variant: the error line needs a surface to sit on over the tiles */
#intro-overlay #intro-error {
  align-self: flex-start;
  margin-left: 4px;
  background: #fff;
  border-radius: 999px;
  padding: 4px 12px 4px 9px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(26,115,232,0.25);
}

#intro-box-wrap.error #intro-error {
  opacity: 1;
  transform: none;
}



/* ── Backdrop: moving grid + scrolling robot tiles ── */

#backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  /* The largest viewport height (phone URL bar hidden), not the current one: the bar coming
     and going then doesn't move or rebuild the backdrop */
  height: 100vh;
  height: 100lvh;
  z-index: 0;
  background-color: #edf2fb; /* same as the page: tiles multiply onto it */
  overflow: hidden;
  pointer-events: none;
}

/* Grid lines: tilted and scrolling up like the tiles, at half their speed.
   Oversized square, so its edges never come into view; one 36px step loops cleanly. */
@keyframes gridDrift {
  from { transform: translate(-50%, -50%) rotate(-15deg) translateY(0); }
  to   { transform: translate(-50%, -50%) rotate(-15deg) translateY(-36px); }
}

#grid-layer {
  display: none; /* grid switched off; kept in case it comes back */
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130vmax;
  height: 130vmax;
  background-image:
    linear-gradient(90deg, rgba(138,172,240,0.22) 1.5px, transparent 1.5px),
    linear-gradient(0deg,  rgba(138,172,240,0.22) 1.5px, transparent 1.5px);
  background-size: 36px 36px;
  animation: gridDrift 10s linear infinite;
}

#tile-layer {
  position: absolute;
  inset: 0;
}

#backdrop-plane {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-15deg);
  /* Moved by game.js (bdTick), on its own compositor layer */
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  #grid-layer { animation-play-state: paused; }
}

.bd-tile {
  position: absolute;
  width: calc(var(--pitch) - 20px);
  height: calc(var(--pitch) - 20px);
  margin: 10px;
  background-color: #fff;
  background-image: var(--sprite);
  border-radius: 4px;
  border: 1px solid rgba(138,172,240,0.35);
  /* The robots sit on white; multiply makes the white see-through so only the robot shows */
  mix-blend-mode: multiply;
  /* --base: intro / play strength (set on #backdrop); --edge: distance fade set by game.js */
  opacity: calc(var(--base) * var(--edge, 1));
  transition: opacity 0.35s linear;
}

/* Caption: the robot's real title (BD_LABELS in game.js) */
.bd-tile[data-word]::after {
  content: attr(data-word);
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  padding: 4px 10px 5px;
  border-radius: 4px;
  background: rgba(32,33,36,0.82);
  color: #fff;
  font: 500 15px/1.3 Roboto, sans-serif;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 599px) { .bd-tile[data-word]::after { font-size: 12px; } }

#backdrop                { --base: 0; }
#backdrop.ready          { --base: 0.62; }
#backdrop.ready.dim      { --base: 0.17; }
#backdrop.snap .bd-tile  { transition: none; }
/* The grid dims in the same proportion as the tiles (0.17 / 0.62) */
#grid-layer { transition: opacity 0.35s ease; }
#backdrop.dim #grid-layer { opacity: 0.27; }

#app { position: relative; z-index: 1; }

.noscript {
  position: relative;
  z-index: 2;
  max-width: 420px;
  margin: 3rem auto;
  padding: 1rem 1.25rem;
  background: #fff;
  border-radius: 8px;
  font-size: 0.95rem;
  text-align: center;
}

/* Pop-in transitions driven by JS (position-matched to intro box) */

/* ── Utility ─────────────────────────────────────── */

[hidden] {
  display: none !important;
}

/* ── Mobile ──────────────────────────────────────── */

@media (max-width: 900px) {
  #img-viewer { display: none; }

  #intro-overlay {
    flex-direction: column;
    gap: 2.25rem;
  }

  #end-screen {
    flex-direction: column;
    gap: 1.25rem;
  }
  #end-screen #intro-context { zoom: 1; width: calc(100vw - 1.5rem); max-width: 420px; }


  #intro-context { text-align: left; }
  #intro-heads { justify-content: flex-start; }
  #intro-context-header { padding: 0.85rem 1rem 0.95rem; }
  #intro-context-body { padding: 0.85rem 1rem 0.95rem; }
  #intro-context-strip { padding: 0.55rem 1rem; }

  #intro-title { font-size: 2.167rem; }
  #intro-desc  { font-size: 0.862rem; }

  #app { padding: 1rem 0.75rem; }

  #captcha-widget,
  #end-card {
    width: calc(100vw - 1.5rem);
    max-width: 420px;
  }

  .option-img-wrap {
    min-height: 60px;
  }

  /* No preview panel here: the game card gets the full screen height for bigger images */
  #app { padding: 0.75rem 0.6rem; }
  #captcha-widget { height: calc(100svh - 1.5rem); max-height: none; width: calc(100vw - 1.2rem); max-width: 520px; }
  .option-zoom { display: flex; }
  /* Images edge to edge: no white frame, more picture */
  .option-pic, .img-overlay { inset: 0; border-radius: 0; }

  /* Taps shouldn't select text or images; keep it for things worth copying */
  body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
  img { -webkit-user-drag: none; -webkit-touch-callout: none; }
  #question-title, #footer-brand, #crowd, #end-sub, #end-score, #intro-players, #robo-tip {
    -webkit-user-select: text; user-select: text;
  }

  /* Title card strip: streak drops to its own line instead of squeezing in beside the date */
  #intro-context-strip { flex-wrap: wrap; row-gap: 0.5rem; }
  #intro-history { align-items: flex-start; gap: 6px; width: 100%; }
  #intro-week { gap: 5px; }
  #intro-week .wk { width: 18px; height: 18px; border-radius: 4px; }
  /* Result screen: streak beside the date (one row), to save height */
  #end-screen #intro-context-strip { flex-wrap: nowrap; }
  #end-screen #intro-history { width: auto; align-items: flex-end; gap: 5px; }
  #end-screen #intro-week { gap: 4px; }
  #end-screen #intro-week .wk { width: 15px; height: 15px; border-radius: 3px; }

  /* Result card sits under the title card: lighter heading, smaller type */
  #end-card { width: calc(100vw - 1.2rem); max-width: 520px; }
  #end-header { background: none; color: var(--text); padding: 0.9rem 1rem 0.2rem; }
  #end-title { display: none; } /* saves height: the verdict says what this is */
  #verdict-label { font-size: 1.05rem; color: var(--text); }
  #end-sub { color: var(--text-muted); opacity: 1; }
  #end-score { color: var(--text); font-size: 1.2rem; }
  #verdict-cb { border-color: var(--border); }
  #verdict-cb.robot, #verdict-cb.human, #verdict-cb.inconclusive { border-color: var(--border); }
  #end-body { padding: 0.75rem 1rem 1rem; }

  .option-badge { top: 10px; left: 10px; }
}
