@import url('https://fonts.googleapis.com/css2?family=Archivo:ital,wdth,wght@0,62..125,400..900&family=Azeret+Mono:wght@400..800&display=swap');

/* ============================================================ tokens */
:root {
  --ink:    #0D0E13;
  --ink-2:  #161822;
  --ink-3:  #212533;
  --line:   #313648;
  --paper:  #ECEDF2;
  --muted:  #878DA3;
  --amber:  #FFC53D;
  --amber-d:#8A6410;

  --a1: #E5484D;  /* triangle */
  --a2: #3E7BFA;  /* diamond  */
  --a3: #F2A33C;  /* circle   */
  --a4: #2FA36B;  /* square   */

  --display: 'Archivo', system-ui, sans-serif;
  --mono:    'Azeret Mono', ui-monospace, monospace;

  --r: 10px;
  --gap: 14px;
  --pad: clamp(16px, 3vw, 32px);
}

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

html, body { height: 100%; }

body {
  background: var(--ink);
  /* faint dot grid: gives the flat dark field some texture without decoration */
  background-image: radial-gradient(circle at 1px 1px, #FFFFFF0A 1px, transparent 0);
  background-size: 28px 28px;
  color: var(--paper);
  font-family: var(--display);
  font-variation-settings: 'wdth' 100;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-variation-settings: 'wdth' 125;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.hidden { display: none !important; }

/* ============================================================ chrome */
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--pad);
}

/*
 * The lockup: amber tile, ECI, Big Quiz.
 *
 * Two words at two weights rather than one shouty run, because they aren't the
 * same kind of word — ECI is who, Big Quiz is what. Setting the product name a
 * step down in weight and colour says that without needing a separator.
 *
 * The tile stays the only amber up here. The split-flap board is what this
 * design spends its boldness on, so the brand keeps quiet.
 */
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--paper);
}
.brand b {
  font-variation-settings: 'wdth' 125;
  font-weight: 900;
  font-size: 19px;
  letter-spacing: -0.03em;
}
.brand em {
  font-style: normal;
  font-variation-settings: 'wdth' 108;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--muted);
}
.brand i {
  align-self: center;
  position: relative;
  top: 1px;
  flex: none;
  width: 13px; height: 13px;
  border-radius: 3px;
  background: var(--amber);
  box-shadow: 0 0 0 3px #FFC53D22;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 7px #FFC53D00; } }

/* ============================================================ split-flap */
/* The signature device. Reused for the PIN, the countdown and the final
   score, so the whole product speaks with one voice. */
.flaps { display: flex; gap: 6px; }

.flap {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0.72em;
  padding: 0.12em 0.16em;
  border-radius: 6px;
  background: linear-gradient(180deg, var(--ink-3) 0%, var(--ink-3) 49.5%, #1A1D28 50.5%, #1A1D28 100%);
  box-shadow: inset 0 0 0 1px var(--line), 0 3px 0 #00000055;
  font-family: var(--mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
  animation: flap-in 0.42s cubic-bezier(.2, .9, .25, 1) backwards;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.flap::after {
  content: '';
  position: absolute;
  inset: 50% 6px auto 6px;
  height: 1px;
  background: #00000088;
}
@keyframes flap-in {
  from { transform: rotateX(-88deg); opacity: 0; }
  to   { transform: rotateX(0);      opacity: 1; }
}

.flaps--pin { font-size: clamp(38px, 8vw, 86px); }
.flaps--pin .flap { min-width: 0.66em; }

@media (prefers-reduced-motion: reduce) {
  .flap, .brand i { animation: none; }
}

/* ============================================================ panels */
.panel {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* ============================================================ controls */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-3);
  color: var(--paper);
  font-family: var(--display);
  font-variation-settings: 'wdth' 110;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: #2A2E3E; border-color: #464C63; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

.btn--go {
  background: var(--amber);
  border-color: var(--amber);
  color: #1A1200;
  box-shadow: 0 3px 0 var(--amber-d);
}
.btn--go:hover { background: #FFD35F; border-color: #FFD35F; }
.btn--go:active { box-shadow: 0 1px 0 var(--amber-d); }

.btn--big { padding: 18px 30px; font-size: 18px; width: 100%; }
.btn--ghost { background: transparent; }

.field { display: block; margin-bottom: 12px; }
.field > span {
  display: block;
  margin-bottom: 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--display);
  font-size: 16px; /* 16px stops iOS zooming on focus */
  font-weight: 600;
}
.input:focus { outline: 3px solid var(--amber); outline-offset: 1px; border-color: transparent; }
.input::placeholder { color: #575C71; }

.input--pin {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .28em;
  text-align: center;
  padding: 16px 10px 16px 22px;
}

.note {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

code {
  font-family: var(--mono);
  font-size: .88em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--ink-3);
  color: var(--paper);
  word-break: break-word;
}

.err {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #E5484D55;
  border-left: 3px solid var(--a1);
  border-radius: 6px;
  background: #E5484D14;
  color: #FFB3B5;
  font-size: 13.5px;
  line-height: 1.45;
}

/* ============================================================ answers */
.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
}
/* Three answers would otherwise leave a hole in the bottom-right. */
.answers--3 .ans:nth-child(3) { grid-column: span 2; }

.ans {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 92px;
  padding: 16px 18px;
  border: 0;
  border-radius: var(--r);
  color: #fff;
  font-family: var(--display);
  font-variation-settings: 'wdth' 110;
  font-weight: 700;
  font-size: clamp(15px, 1.5vw, 22px);
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: transform .1s ease, filter .15s ease, opacity .2s ease;
}
.ans:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.ans:active { transform: scale(.985); }
.ans svg { flex: none; width: 30px; height: 30px; fill: #FFFFFFE6; }

.ans[data-c="0"] { background: var(--a1); box-shadow: 0 4px 0 #9E1F23; }
.ans[data-c="1"] { background: var(--a2); box-shadow: 0 4px 0 #1E4CB0; }
.ans[data-c="2"] { background: var(--a3); box-shadow: 0 4px 0 #A9670F; }
.ans[data-c="3"] { background: var(--a4); box-shadow: 0 4px 0 #146B43; }

/* Reveal states. Shape + colour + a mark, so colourblind players are fine. */
.ans.is-dim   { opacity: .28; filter: grayscale(.7); }
.ans.is-right { outline: 4px solid #fff; outline-offset: -4px; }
.ans.is-mine::before {
  content: 'YOUR PICK';
  position: absolute;
  top: 8px; right: 10px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  opacity: .85;
}

.ans .tally {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ============================================================ backdrop */
/*
 * A question's background photo.
 *
 * The treatment is the whole job. This screen is read from the back of a room,
 * and an untreated photo behind it wrecks contrast and fights a palette built
 * from ink and amber. So the image gets pushed down until it reads as texture
 * rather than picture: desaturated most of the way to grey, halved in
 * brightness, blurred just past the point of legible detail, and held at about
 * a third opacity over the ink. Scaled up 6% so the blur has no visible edge
 * against the viewport.
 *
 * Worst case is a photo that's pure white: 0.34 opacity at 0.5 brightness over
 * #0D0E13 lands near #2E2F33, which still holds about 9:1 against the paper
 * text on top. Anything darker only helps.
 */
.stage-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity .7s ease;
  pointer-events: none;
}
.stage-bg.is-on { opacity: 1; }

.stage-bg > i {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: saturate(.3) brightness(.5) blur(3px);
  transform: scale(1.06);
  opacity: .34;
}

/*
 * Generated boards get a lighter touch than photos. A photo is an unknown —
 * it could be a white studio shot — so it gets desaturated and halved in
 * brightness on the way in. A generated board isn't unknown: it's drawn from
 * this palette, on ink, with its lit tiles already held at 45%. Crushing it
 * again would leave nothing to see. So it keeps its colour and just loses its
 * edges.
 */
.stage-bg.is-generated > i {
  filter: blur(2px);
  transform: scale(1.03);
  opacity: .5;
}

/* Vignette plus a top-and-bottom scrim: the corners are where the progress
   counter and the controls sit, and they need a floor regardless of the photo. */
.stage-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 70% at 50% 45%, transparent 0%, #0D0E13 88%),
    linear-gradient(180deg, #0D0E13E6 0%, #0D0E1359 38%, #0D0E13F2 100%);
}

/* Attribution. Openverse serves CC-licensed work and credit is a licence
   condition, not a courtesy — so it renders whether or not anyone reads it. */
.stage-credit {
  position: fixed;
  left: 50%;
  bottom: 7px;
  transform: translateX(-50%);
  z-index: 2;
  max-width: 90vw;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: #676D82;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .stage-bg { transition: none; }
}

/* ============================================================ host stage */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  gap: var(--gap);
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.stage-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(16px, 3vh, 34px);
}

.q-text {
  font-size: clamp(28px, 4.6vw, 62px);
  text-align: center;
  text-wrap: balance;
  max-width: 20ch;
  margin: 0 auto;
  /* Invisible against plain ink, load-bearing once a photo is behind it. */
  text-shadow: 0 2px 26px #0D0E13, 0 1px 4px #0D0E13;
}

/* Countdown: a segmented bar, mechanical rather than a smooth ring */
.timer {
  display: flex;
  align-items: center;
  gap: 16px;
}
.timer .bar {
  flex: 1;
  height: 14px;
  border-radius: 99px;
  background: repeating-linear-gradient(90deg, var(--ink-3) 0 12px, var(--ink) 12px 14px);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}
.timer .bar > i {
  display: block;
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(90deg, var(--amber) 0 12px, #00000033 12px 14px);
  transform-origin: left;
  transition: transform .25s linear;
}
.timer.is-low .bar > i {
  background: repeating-linear-gradient(90deg, var(--a1) 0 12px, #00000033 12px 14px);
}
.timer .secs { font-size: clamp(28px, 4vw, 46px); font-weight: 800; }

.counter {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--ink-2);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

/* lobby player chips */
.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-content: flex-start;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--ink-2);
  font-weight: 700;
  font-size: 15px;
  animation: pop .3s cubic-bezier(.2,.9,.3,1.4) backwards;
}
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.chip button {
  border: 0;
  background: none;
  color: #5C6178;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 2px;
}
.chip button:hover { color: var(--a1); }

.qr-card {
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--ink-2);
  text-align: center;
}
.qr-card .qr {
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  line-height: 0;
}
.qr-card .qr img, .qr-card .qr canvas { display: block; }

/* ============================================================ board */
.board { display: grid; gap: 8px; max-width: 720px; margin: 0 auto; width: 100%; }

.row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink-2);
  animation: slide-in .4s cubic-bezier(.2,.9,.3,1) backwards;
  animation-delay: calc(var(--i,0) * 60ms);
}
@keyframes slide-in { from { transform: translateY(10px); opacity: 0; } }
.row .pos { font-family: var(--mono); font-weight: 700; color: var(--muted); }
.row .who { font-weight: 700; font-size: 18px; }
.row .pts { font-family: var(--mono); font-weight: 700; font-size: 19px; font-variant-numeric: tabular-nums; }
.row.is-top {
  border-color: var(--amber);
  background: linear-gradient(90deg, #FFC53D18, var(--ink-2) 60%);
}
.row.is-top .pos, .row.is-top .pts { color: var(--amber); }
.row.is-me { border-color: var(--paper); }

/* ============================================================ phone */
.phone {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.phone-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--ink-2);
}
.phone-top .who { font-weight: 800; font-size: 15px; }
.phone-top .pts { font-family: var(--mono); font-weight: 700; font-size: 15px; }

.phone-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
}

.phone-q {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
  color: #C3C8DA;
}

.phone .answers { flex: 1; }
.phone .ans { min-height: 0; justify-content: center; text-align: center; flex-direction: column; gap: 8px; }
.phone .ans svg { width: 34px; height: 34px; }
.phone .ans .label { font-size: 15px; }

/* full-bleed verdict screen */
.verdict {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 30px 20px;
  text-align: center;
  border-radius: var(--r);
  animation: pop .35s cubic-bezier(.2,.9,.3,1.3) backwards;
}
.verdict--right { background: linear-gradient(180deg, #2FA36B, #1D7049); }
.verdict--wrong { background: linear-gradient(180deg, #E5484D, #98282C); }
.verdict--idle  { background: var(--ink-2); border: 1px solid var(--line); }
.verdict h2 { font-size: 34px; }
.verdict .gain { font-family: var(--mono); font-size: 40px; font-weight: 800; }
.verdict .sub { font-size: 14px; opacity: .85; font-weight: 600; }

.waiting-dots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ============================================================ builder */
.qcard {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--ink-2);
  padding: 18px;
  margin-bottom: 14px;
}
.qcard-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.qcard-head .num {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  flex: none;
  border-radius: 6px;
  background: var(--ink-3);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
}
.qcard-head .spacer { flex: 1; }

.opt-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.opt-row .swatch {
  width: 30px; height: 30px;
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.opt-row .swatch svg { width: 16px; height: 16px; fill: #FFFFFFE6; }
.opt-row[data-c="0"] .swatch { background: var(--a1); }
.opt-row[data-c="1"] .swatch { background: var(--a2); }
.opt-row[data-c="2"] .swatch { background: var(--a3); }
.opt-row[data-c="3"] .swatch { background: var(--a4); }

.tick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tick input { accent-color: var(--a4); width: 15px; height: 15px; }
.tick:has(input:checked) { border-color: var(--a4); background: #2FA36B22; color: #8BE0B5; }

.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline .field { margin-bottom: 0; }
.w-sm { width: 130px; }

.toolbar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 14px 0;
  background: linear-gradient(transparent, var(--ink) 30%);
}


/* ============================================================ image picker */
.imgbox {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  margin: 14px 0;
}
@media (max-width: 720px) { .imgbox { grid-template-columns: 1fr; } }

/*
 * The leak check.
 *
 * This is the feature, not the decoration. An image can only be judged against
 * the question it sits behind, at the size and treatment the room will see —
 * a bright thumbnail in a grid tells you nothing about whether Saturn is
 * recognisable through a blur at 34% over ink. So the preview renders the real
 * thing: same filter, same scrim, same text on top.
 */
.shot {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  overflow: hidden;
  text-align: center;
}
.shot > i {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  /* Blur is in pixels, so at a fifth of the host screen's width it has to come
     down proportionally or the preview would read as far mushier than reality. */
  filter: saturate(.3) brightness(.5) blur(1px);
  transform: scale(1.06);
  opacity: .34;
}
/* Mirrors .stage-bg.is-generated — the preview is only honest if it applies the
   same treatment the room gets. */
.shot[data-gen] > i {
  filter: blur(.5px);
  transform: scale(1.03);
  opacity: .5;
}
.shot::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 70% at 50% 45%, transparent 0%, #0D0E13 88%),
    linear-gradient(180deg, #0D0E13E6 0%, #0D0E1359 38%, #0D0E13F2 100%);
}
.shot span {
  position: relative;
  z-index: 1;
  font-variation-settings: 'wdth' 125;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.15;
  text-wrap: balance;
  text-shadow: 0 2px 12px #0D0E13;
}
.shot[data-empty] span { color: #5C6178; font-weight: 600; font-size: 11px; }
.shot[data-empty]::after { background: none; }

.imggrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 6px;
  margin-top: 10px;
  max-height: 176px;
  overflow-y: auto;
}
.imggrid button {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--ink-3);
  overflow: hidden;
  cursor: pointer;
}
.imggrid button:hover { border-color: var(--amber); }
.imggrid button:focus-visible { outline: 3px solid var(--amber); outline-offset: 1px; }
.imggrid img { display: block; width: 100%; height: 100%; object-fit: cover; }

.imgnote { font-size: 11.5px; margin-top: 8px; }
