/* Fauxdle. The page is a green screen; the clip is the only thing keyed in. */

@font-face {
  font-family: "Archivo";
  src: url("/assets/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  --key: #00b140;       /* chroma-key green: the page field */
  --key-deep: #008f34;  /* hover/pressed on the field */
  --ink: #000;
  --paper: #fff;
  --fringe: #ff1f8f;    /* AI: green's complement, the colour keying leaves on edges */
  --mist: #e9f9ee;      /* quiet surface inside dialogs */

  --gutter: 16px;
  --chrome-h: 236px;    /* header + progress + hook + buttons, used to size the monitor on phones */
  --monitor-h: min(calc(100dvh - var(--chrome-h)), calc((100vw - 2 * var(--gutter)) * 16 / 9), 760px);
  --monitor-w: calc(var(--monitor-h) * 9 / 16);
}

* { box-sizing: border-box; }

html {
  background: var(--key);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Archivo", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Header ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 1040px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) var(--gutter) 8px;
}

.wordmark {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  font-stretch: 125%;
  letter-spacing: -0.035em;
  line-height: 1;
}
.wordmark a { text-decoration: none; }

.dayno {
  margin: 0;
  padding-top: 4px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tools { margin-left: auto; display: flex; gap: 6px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}
.icon-btn:hover { background: var(--key-deep); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Play view ---------- */

.play {
  display: grid;
  justify-items: center;
  gap: 12px;
  max-width: 1040px;
  margin: 0 auto;
  padding: 2px var(--gutter) calc(16px + env(safe-area-inset-bottom));
}

.stage { display: grid; justify-items: center; gap: 10px; }

.progress { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.progress li {
  display: grid;
  place-items: center;
  width: 30px;
  height: 20px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}
.progress li.now { background: var(--ink); }
.progress li.hit { background: var(--paper); }
.progress li.miss { background: var(--ink); color: var(--fringe); }

.monitor {
  position: relative;
  width: var(--monitor-w);
  height: var(--monitor-h);
  border-radius: 22px;
  background: var(--ink);
  overflow: hidden;
  isolation: isolate;
}
.monitor.wide {
  width: min(100vw - 2 * var(--gutter), 640px);
  height: auto;
  aspect-ratio: 16 / 9;
}

.screen { position: absolute; inset: 0; }
.screen > iframe,
.screen > video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--ink);
}
.screen > .standby { visibility: hidden; }

.screen-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 24px;
  color: var(--paper);
  text-align: center;
  font-weight: 600;
  z-index: -1;
}

/* The stamp: the one loud moment. */
.stamp {
  position: absolute;
  left: 50%;
  top: 24%;
  z-index: 2;
  padding: 0.02em 0.28em 0.06em;
  border: 0.07em solid var(--ink);
  border-radius: 0.14em;
  color: var(--ink);
  font-size: clamp(64px, calc(var(--monitor-w) * 0.3), 120px);
  font-weight: 900;
  font-stretch: 125%;
  line-height: 1;
  letter-spacing: -0.02em;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(-9deg);
  /* Worn-ink texture; inlined so the stamp never renders blank while it loads. Source: assets/ink.svg */
  --ink-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='worn' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.05 0.08' numOctaves='4' seed='4' stitchTiles='stitch'/%3E%3CfeComponentTransfer%3E%3CfeFuncR type='discrete' tableValues='0'/%3E%3CfeFuncG type='discrete' tableValues='0'/%3E%3CfeFuncB type='discrete' tableValues='0'/%3E%3CfeFuncA type='discrete' tableValues='1 1 1 1 1 1 1 1 1 1 1 1 1 0.55 0.1 0 0 0.5 1 1'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='180' height='180' filter='url%28%23worn%29'/%3E%3C/svg%3E");
  -webkit-mask: var(--ink-mask) center / 180px 180px;
  mask: var(--ink-mask) center / 180px 180px;
}
.stamp.ai { background: var(--fringe); }
.stamp.real { background: var(--paper); font-size: clamp(48px, calc(var(--monitor-w) * 0.21), 92px); }
.monitor.wide .stamp { font-size: 96px; top: 50%; }

.stamp.slam { animation: slam 260ms cubic-bezier(0.2, 0.9, 0.3, 1.25) both; }
.monitor.bump { animation: bump 180ms 170ms ease-out; }

@keyframes slam {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-16deg) scale(2.3); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(-9deg) scale(1); }
}
@keyframes bump {
  0%, 100% { transform: none; }
  40% { transform: translateY(3px) scale(0.992); }
}

.panel {
  display: grid;
  gap: 12px;
  width: max(var(--monitor-w), min(100%, 320px));
}

.hook {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
}

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.choice {
  position: relative;
  height: 64px;
  border: 3px solid var(--ink);
  border-radius: 16px;
  font-size: 26px;
  font-weight: 900;
  font-stretch: 125%;
  letter-spacing: -0.02em;
  cursor: pointer;
  transition: transform 80ms ease-out;
}
.choice.real { background: var(--paper); }
.choice.ai { background: var(--fringe); }
.choice:active { transform: translateY(2px); }
.choice:disabled { cursor: default; opacity: 0.45; }
.choice kbd {
  position: absolute;
  right: 12px;
  bottom: 6px;
  font: 700 12px/1 "Archivo", sans-serif;
  opacity: 0.55;
}
@media not (hover: hover) { .choice kbd { display: none; } }

/* Reveal: bottom sheet on phones, inline on wide screens. */
.reveal {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  gap: 10px;
  max-height: 56dvh;
  overflow-y: auto;
  padding: 20px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--ink);
  color: var(--paper);
  animation: rise 220ms ease-out;
}
.reveal > * { width: 100%; max-width: 520px; margin-inline: auto; }

@keyframes rise { from { transform: translateY(40%); opacity: 0; } }

.verdict {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  font-stretch: 112%;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.reveal p { margin: 0; }
.reveal-text { font-size: 16px; }
.crowd { font-weight: 700; color: var(--key); }
.credit { font-size: 14px; opacity: 0.8; }

.next {
  height: 56px;
  margin-top: 4px;
  border: 0;
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-size: 19px;
  font-weight: 850;
  font-stretch: 112%;
  cursor: pointer;
}
.next:focus-visible { outline-color: var(--paper); }

@media (min-width: 900px) {
  :root {
    --monitor-h: min(calc(100dvh - 130px), 760px);
  }
  .play {
    grid-template-columns: auto 380px;
    align-items: center;
    justify-content: center;
    column-gap: 48px;
    padding-top: 12px;
  }
  .panel { width: 380px; }
  .hook { text-align: left; font-size: 22px; }
  .reveal {
    position: static;
    max-height: none;
    overflow: visible;
    border-radius: 20px;
    padding: 22px;
  }
  .reveal > * { max-width: none; }
}

/* ---------- Results view ---------- */

.done {
  display: grid;
  gap: 18px;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px var(--gutter) calc(40px + env(safe-area-inset-bottom));
}

.score-head { display: grid; justify-items: center; gap: 4px; text-align: center; }
.score-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.score {
  margin: 0;
  font-size: clamp(104px, 34vw, 168px);
  font-weight: 900;
  font-stretch: 125%;
  line-height: 0.9;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}
.score small { font-size: 0.42em; letter-spacing: -0.02em; }
.rank { margin: 0; font-size: 24px; font-weight: 800; font-stretch: 112%; }

.done .progress { justify-content: center; }
.done .progress li { width: 44px; height: 30px; font-size: 16px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: grid;
  place-items: center;
  min-height: 52px;
  padding: 0 16px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: transparent;
  font-size: 17px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--key-deep); }
.btn.primary {
  grid-column: 1 / -1;
  min-height: 60px;
  background: var(--ink);
  color: var(--paper);
  font-size: 20px;
  font-stretch: 112%;
}
.btn.primary:hover { background: #222; }

.meta-line { margin: 0; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }

.recap { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.recap li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--paper);
}
.recap .tag {
  grid-row: span 2;
  align-self: start;
  min-width: 64px;
  padding: 4px 8px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-weight: 900;
  font-stretch: 125%;
  text-align: center;
}
.recap .tag.ai { background: var(--fringe); }
.recap .tag.real { background: var(--paper); }
.recap .title { margin: 0; font-weight: 700; }
.recap .sub { margin: 0; font-size: 14px; }

.empty { display: grid; gap: 16px; max-width: 480px; margin: 12vh auto 0; padding: 0 var(--gutter); text-align: center; }
.empty h2 { margin: 0; font-size: 32px; font-weight: 900; font-stretch: 112%; line-height: 1.1; }
.empty p { margin: 0; }

.foot {
  max-width: 1040px;
  margin: 0 auto;
  padding: 8px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  font-size: 14px;
  text-align: center;
}
.foot a { margin: 0 8px; }
body.playing .foot { display: none; }

/* ---------- Dialogs ---------- */

dialog {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 24px;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: rgb(0 40 14 / 0.6); }
dialog h2 { margin: 0 44px 12px 0; font-size: 28px; font-weight: 900; font-stretch: 118%; line-height: 1.05; letter-spacing: -0.02em; }
dialog h3 { margin: 22px 0 8px; font-size: 17px; font-weight: 800; }
dialog p { margin: 0 0 10px; }
dialog .close { position: absolute; top: 16px; right: 16px; }
dialog .btn.primary { width: 100%; margin-top: 8px; }
.fine { font-size: 14px; opacity: 0.75; }

.help-steps { display: grid; gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
.help-steps li { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; }
.help-steps b {
  display: grid; place-items: center; height: 34px;
  border: 2px solid var(--ink); border-radius: 8px;
  font-weight: 900; font-stretch: 125%;
}
.help-steps b.ai { background: var(--fringe); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.tiles div { display: grid; gap: 2px; padding: 10px 4px; border-radius: 12px; background: var(--mist); text-align: center; }
.tiles dt { order: 2; font-size: 12px; font-weight: 600; line-height: 1.2; }
.tiles dd { order: 1; margin: 0; font-size: 26px; font-weight: 900; font-stretch: 112%; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* Score distribution: one series, so ink bars; today's score is the highlighted bar. */
.dist { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.dist li { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dist .track { display: flex; align-items: center; gap: 6px; }
.dist .fill { height: 18px; border-radius: 0 4px 4px 0; background: var(--ink); }
.dist .fill:not(.zero) { min-width: 4px; }
.dist li.mine .fill { background: var(--fringe); }

.bias { display: grid; gap: 6px; }
.bias-bar { position: relative; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--paper), var(--mist)); border: 2px solid var(--ink); }
.bias-bar i { position: absolute; top: 50%; width: 18px; height: 18px; border: 3px solid var(--ink); border-radius: 50%; background: var(--fringe); transform: translate(-50%, -50%); }
.bias-ends { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; }

.archive-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.archive-list a {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.archive-list a:hover { background: var(--mist); }
.archive-list .n { font-weight: 900; font-stretch: 112%; }
.archive-list .s { font-weight: 800; }
.archive-list .s.todo { padding: 2px 10px; border-radius: 8px; background: var(--ink); color: var(--paper); font-size: 14px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  top: calc(14px + env(safe-area-inset-top));
  z-index: 50;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  transform: translate(-50%, calc(-100% - 40px));
  visibility: hidden;
  transition: transform 200ms ease-out, visibility 0s 200ms;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform 200ms ease-out; }

/* ---------- Static pages ---------- */

.page { max-width: 680px; margin: 0 auto; padding: 8px var(--gutter) 64px; }
.page h2 { margin: 36px 0 10px; font-size: 26px; font-weight: 900; font-stretch: 112%; line-height: 1.1; letter-spacing: -0.02em; }
.page h1 { margin: 24px 0 12px; font-size: clamp(36px, 8vw, 56px); font-weight: 900; font-stretch: 125%; line-height: 1; letter-spacing: -0.04em; }
.page p, .page li { max-width: 68ch; }
.page .card { padding: 20px; border-radius: 18px; background: var(--paper); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

/* ---------- Contact form (about page) ---------- */

.contact { display: grid; gap: 8px; }
.contact label { font-weight: 700; }
.contact input, .contact select, .contact textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  font: inherit;
}
.contact textarea { resize: vertical; }
.contact .check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.contact .check input { width: auto; }
.contact .trap { position: absolute; left: -9999px; width: 1px; height: 1px; }
.contact .btn.primary { margin-top: 8px; }
.form-status { margin: 0; font-weight: 700; min-height: 1.4em; }
