:root {
  --bg: #14152a;
  --surface: #1f2140;
  --surface-2: #2b2e57;
  --ink: #f6f1e4;
  --muted: #b7b4c8;
  --accent: #ffcf5c;
  --accent-ink: #1b1b2f;
  --line: #07070f;
  --focus: #7fe3d4;
  --game-bg: var(--surface);
  --game-panel: var(--surface-2);
  --game-accent: var(--accent);
  --game-ink: var(--ink);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --page-max: 46rem; /* the widest the header, the page and the footer get; all three share it */
}
/* The home page has room for two games side by side, a result page for a picture beside its text. */
.page-home { --page-max: 64rem; }
.page-result { --page-max: 58rem; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  /* Stay clear of a phone's notch and home bar where the page reaches under them. */
  padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  overflow-wrap: break-word;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); }
[hidden] { display: none !important; }
a:focus-visible, button:focus-visible, input:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
h1, h2 { font-family: var(--mono); line-height: 1.2; margin: 0 0 0.6rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -999px; top: 0; padding: 0.5rem 1rem; background: var(--accent); color: var(--accent-ink); z-index: 10; }
.skip:focus { left: 0; }

.site-header, .site-footer, main { width: min(100% - 2rem, var(--page-max)); margin-inline: auto; }
/* On a very narrow screen the header may wrap onto a second line. Every link in the header
   and the footer is at least 44px tall, so that a finger can hit it. */
.site-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 0.75rem; padding: 0.25rem 0; }
.site-header nav, .site-footer nav { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.brand, .site-header nav a, .site-footer nav a { display: inline-flex; align-items: center; min-height: 44px; }
.site-header nav a, .site-footer nav a { color: var(--muted); }
.brand { font: 700 0.85rem/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; color: var(--ink); }
.site-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; padding: 2.25rem 0 2.5rem; color: var(--muted); font-size: 0.9rem; }
.site-footer p { margin: 0; }

.kicker, .meta, .progress, .or {
  font: 700 0.78rem/1.3 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--game-accent);
}
.kicker a { color: inherit; }
.meta { color: var(--muted); }

/* Shared look for the game, result and home cards: flat colour, hard edge, hard shadow. */
.panel, .game-card {
  background: var(--game-bg);
  color: var(--game-ink);
  border: 3px solid var(--line);
  box-shadow: 8px 8px 0 var(--line);
}
.panel { padding: 1.1rem 1.1rem 1.2rem; }

.hero { padding: 1rem 0 0.5rem; }
.hero h1 { font-size: 1.9rem; }
.hero p { color: var(--muted); max-width: 36rem; }

/* A card is a column, so that in a row of cards every Play button sits at the bottom. */
.game-list { display: grid; gap: 1.6rem; margin: 1.5rem 0 2.5rem; }
.game-card { display: flex; flex-direction: column; }
.game-card-art { display: block; flex: none; border-bottom: 3px solid var(--line); }
.game-card-text { display: flex; flex: 1; flex-direction: column; align-items: flex-start; padding: 1rem 1.2rem 1.3rem; }
.game-card h2 a { color: inherit; text-decoration: none; }
.game-card .button { margin-top: auto; }
.how ol { padding-left: 1.3rem; }
.how li { margin-bottom: 0.4rem; }

.button {
  display: inline-block;
  padding: 0.85rem 1.3rem;
  border: 3px solid var(--line);
  border-radius: 0;
  background: var(--game-panel);
  color: var(--game-ink);
  font: 700 0.95rem/1.2 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--line);
}
.button-primary { background: var(--game-accent); color: var(--accent-ink); }
.text-button { min-height: 44px; background: none; border: 0; padding: 0.4rem 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; }
/* A tap acts at once: the browser does not wait to see whether a second tap makes it a zoom. */
.button, .choice, .text-button { touch-action: manipulation; }

/* The play screen. On a phone the spacing is kept tight, so that a round and its two
   choices take up as little of a short screen as they can. */
.game-head .kicker { margin-bottom: 0.5rem; }
.scenario { font-size: 1.05rem; }
.notice { padding: 0.8rem 1rem; border: 3px solid var(--line); background: var(--game-accent); color: var(--accent-ink); font-weight: 600; }
.notice-quiet { background: var(--game-panel); color: var(--game-ink); font-weight: 400; }
.progress { margin: 0.9rem 0 0.4rem; }
.progress-track { height: 10px; border: 3px solid var(--line); background: var(--game-panel); }
.progress-track span { display: block; height: 100%; width: 0; background: var(--game-accent); }
.round h2 { margin: 0.9rem 0 0; font-size: 1.35rem; }
.choices { display: grid; gap: 0.6rem; margin: 1rem 0 0.8rem; }
.choice {
  width: 100%;
  min-height: 4.5rem;
  padding: 1rem 1.1rem;
  border: 3px solid var(--line);
  border-radius: 0;
  background: var(--game-panel);
  color: var(--game-ink);
  font: 600 1.08rem/1.35 var(--sans);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 0 var(--line);
}
.or { text-align: center; color: var(--muted); }
.tally { padding: 2.5rem 0; font: 700 1.1rem/1.3 var(--mono); text-align: center; }
.disclaimer { margin: 1.4rem 0 0; color: var(--muted); font-size: 0.85rem; }

.tagline { font-size: 1.15rem; font-weight: 600; }

/* How two players compare: both results, the verdict, the rounds that matched. */
.duo { margin: 0 0 1.4rem; padding: 1rem 1rem 1.1rem; border: 3px solid var(--line); background: var(--game-panel); }
.duo p { margin: 0; }
.duo-pair { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.7rem; margin-top: 0.5rem; }
.duo-who { display: flex; flex-direction: column; }
.duo-who strong { font: 700 1.1rem/1.25 var(--mono); }
.duo-role { font-size: 0.8rem; color: var(--muted); }
.duo-x { font: 700 1.3rem/1 var(--mono); color: var(--game-accent); }
.duo .duo-verdict { margin-top: 0.9rem; font-size: 1.08rem; font-weight: 600; }
.duo .duo-match { margin-top: 0.9rem; font-size: 0.95rem; }
/* Eight squares, one per round. They shrink with the screen, so that all eight stay inside
   the box on the narrowest phone. */
.match-dots { display: flex; align-items: flex-start; gap: clamp(0.25rem, 1.2vw, 0.45rem); list-style: none; margin: 0.5rem 0 0; padding: 0; }
.match-dots li { width: clamp(1.05rem, 5vw, 1.4rem); aspect-ratio: 1; height: auto; border: 3px solid var(--line); }
@supports not (aspect-ratio: 1) {
  .match-dots li { height: clamp(1.05rem, 5vw, 1.4rem); }
}
.match-dots .hit { background: var(--game-accent); }
.duo-split { margin-top: 1rem; padding-top: 0.9rem; border-top: 3px solid var(--line); }
.duo .split-prompt { margin: 0.3rem 0 0.5rem; font-weight: 600; }
.duo .split-answer { font-size: 0.95rem; }

/* The tall picture, centred where the page is wider than the picture. The browser scales
   it in its usual way: it is drawn larger than it is shown. */
.card-figure { width: min(100%, 22.5rem); margin: 0 auto 1.2rem; }
.card-figure img { width: 100%; border: 3px solid var(--line); }
.card-figure figcaption { margin-top: 0.4rem; color: var(--muted); font-size: 0.85rem; }
.result-body > :last-child { margin-bottom: 0; }
.traits { display: grid; gap: 0.7rem; margin: 1.2rem 0 0; }
.traits div { padding: 0.7rem 0.9rem; border: 3px solid var(--line); background: var(--game-panel); }
.traits dt { font: 700 0.78rem/1.3 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--game-accent); }
.traits dd { margin: 0.2rem 0 0; }
.traits a { color: inherit; }
.actions { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: center; margin-top: 1.4rem; }
.actions .button { flex: 1 1 100%; } /* on a phone each button takes the whole row */
.actions .status, .actions .more, .actions .hint, .link-fallback { flex-basis: 100%; margin: 0; }
#your-actions { margin-bottom: 1.4rem; }
.link-fallback label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; color: var(--muted); }
/* 16px: an iPhone zooms the page in when a field with smaller text is tapped. */
.link-fallback input { width: 100%; padding: 0.7rem; border: 3px solid var(--line); border-radius: 0; background: var(--ink); color: var(--accent-ink); font: 1rem var(--mono); }

.prose { padding: 1rem 0; }
.prose h2 { margin-top: 1.8rem; }
.prose ul { padding-left: 1.3rem; }

/* Reserved ad space, switched off in V1. When ads are switched on it stays at
   least 150px away from anything a player taps. */
.ad-slot { margin-top: 150px; min-height: 250px; }

/* Wide phones held sideways, tablets and up: roomier spacing, the two choices side by side. */
@media (min-width: 40rem) {
  h1 { font-size: 2.1rem; }
  .site-header { padding: 0.5rem 0; }
  .brand { font-size: 1rem; }
  .hero h1 { font-size: 2.4rem; }
  .panel { padding: 2rem; }
  .game-head .kicker { margin-bottom: 1rem; }
  .progress { margin-top: 1.2rem; }
  .round h2 { margin-top: 1.2rem; }
  .choices { grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 0.8rem; margin: 1.2rem 0 1rem; }
  .choice { display: flex; align-items: center; min-height: 5.25rem; }
  .or { align-self: center; }
  .traits { grid-template-columns: 1fr 1fr; }
  .actions .button { flex: 0 1 auto; }
}

/* Tablets and up: the games two to a row. */
@media (min-width: 46rem) {
  .game-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* A tablet held sideways, and desktops: on a result page the picture stands on the left
   and everything about the result on the right. The last row before the note takes up
   the slack when the picture is the taller side, so the right side stays together. */
@media (min-width: 54rem) {
  .result {
    display: grid;
    grid-template-columns: minmax(17rem, 21rem) minmax(0, 1fr);
    grid-template-rows: repeat(8, auto) 1fr auto;
    grid-template-areas:
      "kicker  kicker"
      "name    name"
      "tagline tagline"
      "duo     duo"
      "picture yours"
      "picture body"
      "picture traits"
      "picture visitor"
      "picture ."
      "note    note";
    column-gap: 2rem;
  }
  .result > .kicker { grid-area: kicker; }
  .result > h1 { grid-area: name; }
  .result > .tagline { grid-area: tagline; }
  .result > .duo { grid-area: duo; }
  .result > .card-figure { grid-area: picture; align-self: start; width: auto; margin: 0; }
  .result > #your-actions { grid-area: yours; margin-top: 0; }
  .result > .result-body { grid-area: body; }
  .result > .traits { grid-area: traits; }
  .result > #visitor-actions { grid-area: visitor; }
  .result > .disclaimer { grid-area: note; }
  .result > .actions .button { flex: 1 1 auto; }
}

/* A mouse can rest on a button; a finger cannot, and on a touch screen a hover style
   would stay stuck after a tap. */
@media (hover: hover) and (pointer: fine) {
  .button:hover, .choice:hover { transform: translateY(-2px); }
  .button:hover { box-shadow: 0 7px 0 var(--line); }
  .choice:hover { box-shadow: 0 8px 0 var(--line); }
  .site-header nav a:hover, .site-footer nav a:hover, .text-button:hover { color: var(--ink); }
  .game-card h2 a:hover { text-decoration: underline; }
}
/* Pressed, by a mouse or a finger. It comes after the hover styles so that it wins over them. */
.button:active, .choice:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--line); }

@media (prefers-reduced-motion: no-preference) {
  .button, .choice { transition: transform 0.06s, box-shadow 0.06s; }
  .progress-track span { transition: width 0.15s; }
}
