/* The stylesheet for all pages of ahhhh.app: the colours, the parts that all
   pages share, then each kind of page. It works in Safari 16.4, Chrome 111
   and Firefox 114, and later. Newer features here only add to the page. */

/* Press Start 2P, the font of the wordmark (SIL Open Font License,
   fonts/OFL.txt). Text in this font waits for it, and does not show in Arial
   first. An Arial with the same metrics is used only if the font does not
   load. */
@font-face {
  font-family: pixel;
  src: url("/fonts/PressStart2P-Regular.woff2") format("woff2");
  font-display: block;
}

@font-face {
  font-family: "pixel Fallback";
  src: local(Arial);
  ascent-override: 45.63%;
  descent-override: 0%;
  line-gap-override: 0%;
  size-adjust: 219.15%;
}

/* The colours. The light colours are here. The dark colours are below, for a
   reader who chose dark, and for a system in dark mode if the reader did not
   choose light (the head of each page sets data-theme before the first
   paint). Safari before 17.5 has no light-dark(), so the dark colours are
   written two times. */
:root {
  color-scheme: light dark;

  --paper: #ffffff;
  --surface: #f2f2f2;
  --ink: #161616;
  --muted: #656565;
  /* Lighter than muted, for the text at the bottom of a page. It keeps the
     contrast that small text needs on the paper (4.5:1). */
  --faint: #767676;
  --rule: #dddddd;
  --cell: #ffffff;
  --block: #161616;
  --grid-rule: #737373;
  --key: #ffffff;
  --key-pressed: #d4d4d4;

  /* Hot pink shows where the reader is in the crossword. */
  --pink: #ff69b4;
  /* The focus ring. On white, hot pink is too light for a ring (a ring needs
     3:1), so light mode uses a deeper pink. Dark mode uses the hot pink. */
  --focus: #d6247f;
  --word: #ffe0ef;
  --selection-ink: #161616;
  --charcoal: #2b2b2b;
  /* A full board with wrong letters on it. */
  --red: #e63946;
  /* The marks of HUNCH!, in the usual green, yellow and grey, so that readers
     know them immediately: the correct letter in the correct square; in the
     answer, in a different square; not in the answer. */
  --correct: #6aaa64;
  --present: #c9b458;
  --absent: #787c7e;
  --mark-ink: #ffffff;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-pixel: pixel, "pixel Fallback";

  /* The centred column of the archive. A crossword on a computer aligns with
     it, so the margins stay the same from page to page. */
  --column: min(100% - 40px, 1160px);

  /* The finish card. */
  --completion-card: var(--paper);
  --completion-photo-edge: #ffffff;
  --completion-photo-shadow: #0000000f;

  /* HUNCH!, and its badge. */
  --hunch-mark: var(--absent);
  --hunch-absent-ink: var(--mark-ink);
  --badge-tip: var(--paper);

  /* The settings page. */
  --settings-segments: #e2e2e2;
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #101010;
  --surface: #1c1c1c;
  --ink: #f5f5f5;
  --muted: #aaaaaa;
  --faint: #808080;
  --rule: #363636;
  --cell: #282828;
  --block: #080808;
  --grid-rule: #666666;
  --key: #353535;
  --key-pressed: #5a5a5a;
  --focus: var(--pink);
  --word: #4a2238;
  --correct: #538d4e;
  --present: #b59f3b;
  --absent: #3a3a3c;

  --completion-card: var(--surface);
  --completion-photo-edge: #4a4149;
  --completion-photo-shadow: #00000066;

  --hunch-mark: #121212;
  --hunch-absent-ink: #6c6c6c;
  --badge-tip: var(--surface);

  --settings-segments: #101010;
}

/* A system in dark mode, if the reader did not choose light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101010;
    --surface: #1c1c1c;
    --ink: #f5f5f5;
    --muted: #aaaaaa;
    --faint: #808080;
    --rule: #363636;
    --cell: #282828;
    --block: #080808;
    --grid-rule: #666666;
    --key: #353535;
    --key-pressed: #5a5a5a;
    --focus: var(--pink);
    --word: #4a2238;
    --correct: #538d4e;
    --present: #b59f3b;
    --absent: #3a3a3c;

    --completion-card: var(--surface);
    --completion-photo-edge: #4a4149;
    --completion-photo-shadow: #00000066;

    --hunch-mark: #121212;
    --hunch-absent-ink: #6c6c6c;
    --badge-tip: var(--surface);

    --settings-segments: #101010;
  }
}

/* The parts that all pages share. A tap on a touch screen shows no flash. */

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

html {
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* The crossword page fits the window, so the document never scrolls or
   bounces. */
html.play {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
}

/* Buttons start with no style, and each button sets its own style. */
button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* A pink ring shows the focus. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* In a list or a grid, the ring is inside the element. */
.archive-years a:focus-visible,
.board-cell:focus-visible,
.clues-clue:focus-visible,
.hunch-close:focus-visible,
.completion-close:focus-visible {
  outline-offset: -2px;
}

/* On a pink button, the focus ring is ink. */
.completion-share:focus-visible,
.settings-primary:focus-visible {
  outline-color: var(--ink);
}

/* All pages print with the margins of the crossword page. */
@page {
  margin: 12mm;
}

/* With reduced motion, nothing moves or eases. But the HUNCH! board fades
   from one side to the other (below), and the return ring fades as usual. */
@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after,
  ::backdrop {
    animation: none !important;
    transition: none !important;
  }

  .tiles > li[data-returned] .tiles-tile {
    animation: tiles-returned 2.4s ease-out both !important;
  }
}

/* The archive pages: a centred column under a masthead. */

.archive-column {
  width: var(--column);
  margin-inline: auto;
}

/* 7px of space above the masthead, the same as on the crossword page. */
.archive-header {
  padding-top: 7px;
}

.archive-masthead {
  display: grid;
  grid-template: "wordmark years controls" / 1fr auto auto;
  align-items: center;
  gap: 8px 16px;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--rule);
}

/* Press Start 2P draws its capitals on the top seven rows of an eight-row
   em. Without the empty bottom row, the letters are centred on the controls,
   as in the masthead of the crossword page. */
.archive-wordmark {
  grid-area: wordmark;
  justify-self: start;
  margin-bottom: -0.125em;
}

/* The gear, at the top right. */
.archive-controls {
  grid-area: controls;
}

.archive-years {
  grid-area: years;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 36px;
}

.archive-years a {
  padding: 8px 6px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 20px;
  text-decoration: none;
}

.archive-years a:hover,
.archive-years a[aria-current] {
  color: var(--ink);
}

/* Pink shows the current page. All underlines use the longhand properties:
   Safari before 26.2 does not accept a thickness in the text-decoration
   shorthand, and with a var() in it, Safari shows no underline. */
.archive-years a[aria-current] {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--pink);
  text-underline-offset: 7px;
}

/* On a phone, the years have their own row, so all years fit. */
@media (width <= 639px) {
  .archive-masthead {
    grid-template: "wordmark controls" "years years" / 1fr auto;
  }

  .archive-years {
    margin-left: -6px;
  }
}

.archive-main {
  padding: 28px 0 72px;
}

.archive-back {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
}

.archive-back:hover {
  color: var(--ink);
}

.archive-title,
.legal h1 {
  margin: 0 0 24px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 36px;
}

.archive-month + .archive-month {
  margin-top: 44px;
}

.archive-heading {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 650;
  line-height: 26px;
}

/* The wordmark, AHHHH! in pixels. */
.wordmark {
  font-family: var(--font-pixel), monospace;
  font-size: clamp(22px, 6vw, 34px);
  line-height: 1;
  letter-spacing: 1px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}

/* The 44-point square controls: in the mastheads, the back arrow, the ring,
   the H of HUNCH!, the gear and, on a computer, the print button; and the
   arrows of the crossword keyboard. The controls with a line icon are on a
   rounded square in the surface colour. */
.icon-button,
.play-back,
.play-ring,
.badge,
.keyboard-step {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.icon-button,
.play-back,
.badge {
  background: var(--surface);
  color: var(--ink);
}

/* Pressed, like a key. */
.icon-button:active,
.play-back:active,
.badge:active,
.keyboard-step:active,
.settings-secondary:active {
  background: var(--key-pressed);
}

/* The current page: the page that the control goes to. */
.icon-button[aria-current] {
  box-shadow: inset 0 0 0 2px var(--pink);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The progress ring: an arc for the filled squares, a check mark when
   solved, and a red number when a full board has wrong letters. */
.ring {
  flex: none;
  color: var(--ink);
}

.ring[data-solved] {
  color: var(--pink);
}

.ring[data-wrong] {
  color: var(--red);
}

.ring-track,
.ring-arc {
  fill: none;
  stroke-width: 2;
}

.ring-track {
  stroke: var(--rule);
}

.ring-arc {
  stroke: currentColor;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: center;
}

.ring-check {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ring-count {
  fill: currentColor;
  font: 700 10px/1 var(--font-sans);
  text-anchor: middle;
  dominant-baseline: central;
}

/* The sections, topic pills, text and footer of the archive. */

.sections-section {
  margin-top: 48px;
}

.sections-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sections-topic {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
}

.sections-topic:hover {
  background: var(--word);
}

.sections-count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.sections-prose {
  max-width: 68ch;
  font-size: 17px;
  line-height: 1.6;
}

.sections-prose h2 {
  margin: 40px 0 10px;
  font-size: 20px;
  font-weight: 650;
  line-height: 26px;
}

.sections-prose p,
.sections-prose ul {
  margin: 0 0 14px;
}

.sections-prose ul {
  padding-left: 1.2em;
}

.sections-prose li + li {
  margin-top: 6px;
}

/* A link, and a button on the page that looks like a link. */
.sections-prose a,
.legal button,
.settings-page a,
.hero-bring a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1.5px;
  text-decoration-color: var(--pink);
  text-underline-offset: 4px;
}

.sections-prose kbd {
  padding: 1px 6px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  font: 500 14px/1.4 var(--font-sans);
}

/* The footer: small and light, with no line above it. The links are there
   for readers who look for them. */
.sections-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  padding: 0 0 32px;
  color: var(--faint);
  font-size: 12px;
  line-height: 16px;
}

.sections-footer-line {
  margin: 0;
}

.sections-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.sections-footer-links a {
  color: inherit;
  text-decoration: none;
}

.sections-footer-links a:hover {
  color: var(--muted);
}

/* A small grid, on the home page and on the archive tiles: its frame as on
   the board, and its inner lines lighter, so that the block pattern shows
   first. */
.cover-board,
.tiles-grid {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--grid-rule);
  background: var(--cell);
}

.cover-rules,
.tiles-rules {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.cover-blocks,
.tiles-blocks {
  fill: var(--block);
}

/* The letters typed in this browser, in the font of the board and the grey of
   the titles, so that the page stays quiet. */
.cover-letters,
.tiles-letters {
  fill: var(--muted);
  font: 500 0.62px ui-rounded, var(--font-sans);
  text-anchor: middle;
}

/* The home page. It has no masthead: the name and what Ahhhh! is, then this
   week's crossword, then the earlier crosswords as a table, then the topics.
   On a computer, one vertical line runs down the page, where the narrow
   column starts: the intro, the grid and the themes of the table all start
   on it. The only pink is on the grid, where one clue's word is lit as the
   board lights the reader's word. */

.home ::selection {
  background: var(--word);
  color: var(--ink);
}

.home-intro,
.home .hero,
.home-row {
  display: grid;
  gap: 24px 64px;
}

@media (width >= 860px) {
  .home-intro,
  .home .hero,
  .home-row {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  }
}

/* A small label over a part of the page, like the department heads of a
   magazine. */
.home-label {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* The links of the page underline under the pointer, in a hairline. */
.hero-name a:hover,
.home-figure:hover .home-clue-text,
.home-row:hover .home-row-title,
.home-more a:hover,
.home-topics a:hover {
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

/* The name, then the headline across the page, and the intro under it on
   the vertical line. */
.home-intro {
  padding-top: clamp(64px, 10vh, 128px);
}

.home-title {
  grid-column: 1 / -1;
  max-width: 9.5em;
  margin: 0;
  font-size: clamp(44px, 8vw, 108px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.035em;
}

/* AHHHH! in the pixel font of the wordmark, on its own line. Press Start 2P
   draws its capitals 7/8 of the em tall, and the capitals of the sans are
   about 0.72 em, so 0.82 em makes them the same height. */
.home-name {
  display: block;
  margin-bottom: 0.22em;
  font-family: var(--font-pixel), monospace;
  font-size: 0.82em;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-lede {
  max-width: 30em;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.6;
  text-wrap: pretty;
}

/* In a Home Screen app with nothing saved yet: the link to bring the progress
   from Safari, under the intro. */
.hero-bring {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

@media (width >= 860px) {
  .hero-lede,
  .hero-bring {
    grid-column: 2;
  }

  .hero-lede {
    margin-top: 28px;
  }
}

/* This week, under one hairline: its name and Play in the wide column, and
   its grid and one clue on the vertical line. On a phone, the grid and the
   clue come between the name and Play. */
.home .hero {
  grid-template-areas: "text" "figure" "play";
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
}

@media (width >= 860px) {
  .home .hero {
    grid-template-areas: "text figure" "play figure";
    grid-template-rows: auto 1fr;
  }
}

.home-latest-text {
  grid-area: text;
}

.home-latest-text .home-label {
  margin-bottom: 12px;
}

.hero-name {
  margin: 0;
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero-name a {
  color: inherit;
  text-decoration: none;
}

.home-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.hero-actions {
  grid-area: play;
  align-self: start;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Play, or Carry on: the one solid thing on the page, in the ink of the
   blocks. */
.hero-play {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
}

.hero-play span {
  transition: translate 0.15s ease;
}

.hero-play:hover span {
  translate: 3px 0;
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* The grid, drawn small, and the clue beside it: one link into the crossword. */
.home-figure {
  grid-area: figure;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  color: inherit;
  text-decoration: none;
}

.home-figure .cover-board {
  flex: none;
  width: 168px;
}

/* The clue's word, lit as the board lights the reader's word: the first
   square in the pink of the cursor, the others in the light tint. */
.home-cursor {
  fill: var(--pink);
}

.home-word {
  fill: var(--word);
}

.home-clue {
  display: grid;
  gap: 6px;
  max-width: 17em;
}

.home-clue-number {
  color: var(--muted);
  font-size: 14px;
}

.home-clue-text {
  font-size: 17px;
  line-height: 1.45;
  text-wrap: pretty;
}

.home-count {
  color: var(--faint);
  white-space: nowrap;
}

/* Once, as the page opens: the cursor lands on the first square, then the
   word lights up behind it, square by square. */
.home-cursor,
.home-word {
  animation: home-light 0.3s ease-out both;
  animation-delay: calc(400ms + var(--square) * 70ms);
}

@keyframes home-light {
  from {
    opacity: 0;
  }
}

@media (width <= 859px) {
  .home .hero {
    gap: 24px;
  }

  .home-figure {
    gap: 16px;
  }

  .home-figure .cover-board {
    width: 112px;
  }

  .home-clue-text {
    font-size: 16px;
  }
}

@media (width >= 860px) {
  .home .hero-actions {
    margin-top: 4px;
  }
}

/* The earlier crosswords, as a catalogue: the day and the title in the wide
   column; the theme and this browser's ring in the narrow one. The ring shows
   only what the reader did, so a crossword never opened shows nothing. */
.home-earlier {
  margin-top: 88px;
}

.home-rows {
  margin: 0;
  padding: 0;
  list-style: none;
  border-bottom: 1px solid var(--rule);
}

.home-rows li {
  border-top: 1px solid var(--rule);
}

.home-row {
  align-items: center;
  min-height: 50px;
  padding-block: 10px;
  color: inherit;
  text-decoration: none;
}

@media (width <= 859px) {
  .home-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
  }
}

.home-row-name {
  display: grid;
  grid-template-columns: 6.5em minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
}

.home-row-more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.home-row time {
  color: var(--faint);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.home-row-title {
  font-size: 16px;
}

.home-row-theme {
  display: none;
  color: var(--faint);
  font-size: 14px;
}

@media (width >= 860px) {
  .home-row-name {
    grid-template-columns: 8em minmax(0, 1fr);
  }

  .home-row-theme {
    display: block;
  }
}

.home-row .tiles-progress {
  display: flex;
  width: 26px;
}

.home-row .ring-track {
  stroke: none;
}

.home-row .tiles-time {
  display: none;
}

.home-more {
  margin: 20px 0 0;
  font-size: 15px;
}

.home-more a {
  color: var(--muted);
  text-decoration: none;
}

/* The topics, as the index at the back of a book. */
.home-topics {
  margin-top: 96px;
}

.home-topics ul {
  margin: 0;
  padding: 0;
  list-style: none;
  columns: 4 150px;
  column-gap: 32px;
}

.home-topics li {
  padding-block: 6px;
  font-size: 16px;
  line-height: 22px;
  break-inside: avoid;
}

.home-topics a {
  color: inherit;
  text-decoration: none;
}

.home-topics span {
  color: var(--faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* The footer: the years and Settings, which other pages have in their
   masthead, then the links of every footer. */
.home-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px 24px;
  margin-top: 96px;
  padding-bottom: 40px;
}

.home-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 13px;
}

.home-footer a {
  color: var(--faint);
  text-decoration: none;
}

.home-footer a:hover {
  color: var(--muted);
}

/* The tag of ahhhh.app: "Latest" in hot pink pixels on charcoal, or charcoal
   on pink for a special edition. */
.tiles-latest,
.tiles-special,
.play-special,
.not-found-clue b {
  padding: 3px 4px 2px 5px;
  background: var(--charcoal);
  color: var(--pink);
  font: 8px/1 var(--font-pixel), monospace;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.tiles-special,
.play-special {
  background: var(--pink);
  color: var(--charcoal);
}

/* Crosswords as tiles: two columns on the narrowest phone, and on wider
   screens as many 160px tiles as fit. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(160px, calc(50% - 10px)), 1fr));
  gap: 28px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tiles-tile {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* The crossword that the reader came back from, with a pink ring for a short
   time. */
.tiles > li[data-returned] .tiles-tile {
  border-radius: 4px;
  animation: tiles-returned 2.4s ease-out both;
}

@keyframes tiles-returned {
  0%,
  45% {
    outline: 3px solid var(--pink);
    outline-offset: 6px;
  }

  100% {
    outline: 3px solid transparent;
    outline-offset: 6px;
  }
}

/* Under the pointer, the grid of a tile turns pink, like the selected word in
   a crossword. */
.tiles-grid {
  transition: background-color 0.15s;
}

.tiles-tile:hover .tiles-grid {
  background: var(--word);
}

/* Letters typed in this browser fade in, because only the browser knows them
   and adds them after the page loads. */
.tiles-letters {
  animation: tiles-arrive 0.2s ease-out;
}

@keyframes tiles-arrive {
  from {
    opacity: 0;
  }
}

.tiles-caption {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.tiles-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tiles-label {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.tiles-date {
  font-size: 15px;
  font-style: italic;
  font-weight: 500;
  line-height: 20px;
}

/* The solve time is under the check mark, so that all rings in a row are
   level and the title keeps its width. */
.tiles-progress {
  position: relative;
  flex: none;
  display: flex;
}

.tiles-time {
  position: absolute;
  top: calc(100% + 3px);
  /* Aligned with the right edge of the ring, which is the right edge of the
     tile. */
  right: 0;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  line-height: 13px;
  white-space: nowrap;
}

.tiles-title {
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

/* The theme, in an even lighter grey. */
.tiles-theme {
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  line-height: 16px;
  opacity: 0.85;
}

/* The privacy policy and the EULA: text like the about page, with tables
   that scroll sideways on a phone, and the choice not to be counted. */
.legal {
  max-width: 76ch;
  overflow-wrap: break-word;
}

.legal h3 {
  margin: 32px 0 8px;
  font-size: 17px;
  font-weight: 650;
  line-height: 24px;
}

.legal hr {
  margin: 28px 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.legal ol {
  margin: 0 0 14px;
  padding-left: 1.4em;
}

.legal button:disabled {
  color: var(--muted);
  cursor: progress;
}

.legal-table {
  margin: 16px 0 24px;
  overflow-x: auto;
}

.legal table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.5;
}

.legal th,
.legal td {
  padding: 10px 12px 10px 0;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: top;
}

.legal th {
  border-bottom-color: var(--grid-rule);
  font-weight: 650;
}

.legal td p {
  margin: 0 0 10px;
}

.legal td p:last-child {
  margin-bottom: 0;
}

/* The 404 page: a clue, and its answer on a strip of the grid. */
.not-found-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 48px 20px;
  text-align: center;
}

.not-found-main {
  display: grid;
  justify-items: center;
  gap: 28px;
  width: min(100%, 360px);
}

.not-found-clue {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
}

/* The tag, one size larger: "404 Across". */
.not-found-clue b {
  margin-right: 6px;
  padding: 4px 5px 3px 6px;
  font-size: 10px;
  vertical-align: 1px;
}

.not-found-answer {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
  width: 100%;
  margin: 0;
  padding: 1px;
  background: var(--grid-rule);
}

.not-found-answer span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: var(--cell);
  font-size: 22px;
  font-weight: 600;
}

.not-found-note {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 22px;
  text-wrap: balance;
}

/* The masthead of the crossword page, the same as the archive's: one bar
   above a thin line. Its edges are the edges of the board (on a computer,
   the archive column, so nothing moves from page to page). On the left: the
   back arrow, the wordmark and the title. On the right: the time, the ring,
   the H of HUNCH! and the gear. */
.play-header {
  --edge: 12px;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  /* 7px of space above, the same as on the archive. */
  padding-top: 7px;
  min-width: 0;
}

@media (pointer: coarse) and (width >= 600px) and (height >= 616px) {
  .play-header {
    --edge: 24px;
  }
}

.play-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-inline: var(--edge);
  border-bottom: 1px solid var(--rule);
}

/* The padding of the archive masthead, around the same 44-point controls. */
@media not all and (pointer: coarse) {
  .play-bar {
    width: var(--column);
    margin-inline: auto;
    padding-block: 16px 14px;
  }
}

/* A short window keeps the compact bar. */
@media (height <= 479px) {
  .play-bar {
    padding-block: 0;
  }
}

.play-back {
  flex: none;
}

@media (hover: hover) {
  .play-back:hover {
    background: var(--rule);
  }
}

.play-back svg {
  width: 22px;
  height: 22px;
}

/* The wordmark, then the title above the date, in exactly the height of the
   wordmark: the capitals of the title start where the capitals of the
   wordmark start, and the date is on the bottom edge of the wordmark. */
.play-brand {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 14px;
  min-width: 0;
}

/* Press Start 2P draws its capitals on the top seven rows of an eight-row
   em. Without the bottom row, the box is exactly the letters. */
.play-wordmark {
  flex: none;
  line-height: 1;
  margin-bottom: -0.125em;
}

.play-titles {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

/* The box of each line goes from the top of its capitals to its baseline, so
   that the boxes align with the ink. Descenders go below the box, and are not
   cut. */
.play-title,
.play-date {
  margin: 0;
  white-space: nowrap;
  overflow: clip visible;
  text-overflow: ellipsis;
  text-box: trim-both cap alphabetic;
}

.play-title {
  font: 600 15px/1 var(--font-sans);
}

.play-date {
  color: var(--muted);
  font: italic 400 13px/1 var(--font-sans);
}

/* The kind of crossword, for example "Halloween crossword", comes before the
   date, in upright text. */
.play-kicker {
  font-style: normal;
}

.play-special {
  flex: none;
  align-self: center;
  white-space: nowrap;
}

.play-progress,
.play-score {
  flex: none;
  display: flex;
  align-items: center;
}

.play-time {
  font: 500 15px/1 var(--font-sans);
  font-variant-numeric: tabular-nums;
}

/* The ring, which is a button that shares the crossword when it is solved. */
button.play-ring:active {
  background: var(--surface);
}

/* The gear and the print button, where the archive masthead has its gear, so
   nothing moves from page to page. */
.play-settings,
.play-print {
  flex: none;
}

/* The print button is only for computers. The masthead of a phone has no
   space for it. */
@media (pointer: coarse), (width <= 599px) {
  .play-print {
    display: none;
  }
}

@media (width <= 719px) {
  .play-weekday {
    display: none;
  }
}

/* On a phone, the title is under the wordmark. The date is only in the page
   title and in the archive. */
@media (width <= 599px) {
  .play-brand {
    flex-direction: column;
    justify-content: center;
    gap: 7px;
  }

  .play-wordmark {
    align-self: flex-start;
  }

  .play-titles {
    justify-content: flex-start;
  }

  .play-title {
    font-size: 13px;
  }

  .play-date {
    display: none;
  }

  /* The time is under the ring, as on the archive tiles, so that the H of
     HUNCH! fits next to it. The ring stays on the middle line of the
     masthead, level with the H and the gear. */
  .play-score {
    position: relative;
  }

  /* Cut to its digits, the time is as near the ring as the thin line. */
  .play-time {
    position: absolute;
    top: calc(50% + 13px + 2.5px);
    left: 50%;
    color: var(--muted);
    font-size: 11px;
    text-box: trim-both cap alphabetic;
    translate: -50% 0;
  }

  /* When the crossword is solved, the ring shares it. The touch area of the
     ring also covers the time under it. */
  button.play-ring {
    position: relative;
  }

  button.play-ring::after {
    content: "";
    position: absolute;
    inset: 0 0 -8px;
  }
}

/* The narrowest phones have no space for the wordmark next to the clock: the
   wordmark is one size smaller, and the box of the ring is only as wide as
   the ring. */
@media (width <= 359px) {
  .play-bar {
    gap: 8px;
  }

  .play-brand .play-wordmark {
    font-size: 17px;
  }

  .play-ring {
    width: 32px;
  }
}

/* On paper: the wordmark, the title and the kind of crossword, above a thin
   line. */
@media print {
  .play-header {
    padding: 0;
  }

  .play-bar {
    width: auto;
    margin: 0 0 6mm;
    padding: 0 0 3mm;
    border-bottom: 0.5pt solid #000;
  }

  .play-back,
  .play-progress,
  .play-print,
  .play-settings,
  .play-special {
    display: none;
  }

  .play-brand {
    flex-direction: row;
    align-items: flex-end;
    gap: 5mm;
  }

  .play-wordmark {
    font-size: 16pt;
  }

  .play-titles {
    justify-content: flex-end;
    gap: 2mm;
  }

  .play-title,
  .play-date,
  .play-weekday {
    display: inline;
    color: #000;
  }

  .play-title {
    font-size: 13pt;
  }

  .play-date {
    display: block;
    font-size: 9pt;
  }
}

/* The settings page, under the masthead of the crossword page. Its edges are
   always the edges of the archive column, so that the bar aligns with the
   cards. */
.settings-header-bar {
  width: var(--column);
  margin-inline: auto;
  padding-block: 16px 14px;
}

@media (height <= 479px) {
  .settings-header-bar {
    padding-block: 0;
  }
}

/* One line with no date under it, level with the middle of the wordmark. */
.settings-header-titles {
  justify-content: center;
}

/* The page: the archive column, with a line length for reading. Each section
   is a card, in a colour a little different from the page. */
.settings-page {
  max-width: 640px;
  font-size: 16px;
  line-height: 1.55;
}

.settings-page p {
  margin: 0 0 12px;
}

.settings-page a:focus-visible {
  border-radius: 4px;
}

.settings-section {
  margin-top: 12px;
  padding: 20px 22px 10px;
  border-radius: 18px;
  background: var(--surface);
}

.settings-section:first-child {
  margin-top: 0;
}

.settings-heading {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 650;
  line-height: 26px;
}

.settings-note,
.settings-status {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

/* Space for one line, so that a message does not move the content below. */
.settings-status:empty::before {
  content: "\00a0";
}

.settings-tally {
  font-weight: 600;
}

/* The progress in a link, with a pink line at its left until the reader
   answers. */
.settings-offer {
  margin: 18px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--pink);
}

.settings-offer p {
  margin: 0;
  font-weight: 600;
}

.settings-offer .settings-buttons {
  margin-top: 12px;
}

.settings-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 10px;
}

.settings-primary,
.settings-secondary {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font: 600 15px/1 var(--font-sans);
}

/* The pink button, as on the finish card. */
.settings-primary {
  background: var(--pink);
  color: var(--selection-ink);
}

/* A key on the card, as on the crossword keyboard. */
.settings-secondary {
  background: var(--key);
}

/* On a phone, the cards are a little nearer to the edges, and their buttons
   stay side by side. */
@media (width <= 599px) {
  .settings-section {
    padding: 18px 16px 8px;
    border-radius: 16px;
  }

  .settings-primary,
  .settings-secondary {
    padding: 0 14px;
  }

  .settings-copy {
    width: 100%;
  }
}

.settings-primary:active,
.completion-share:active {
  opacity: 0.75;
}

.settings-label {
  display: block;
  margin: 0 0 8px;
  font-weight: 600;
}

/* The progress link of this browser: all of it, in a block a little darker
   than the card, like the track of the appearance choice. A long link scrolls
   in the block after about five lines. A tap or a long press selects all of
   it. */
.settings-link {
  margin: 18px 0 22px;
}

.settings-code {
  max-height: calc(5 * 1.5em + 24px);
  margin: 0 0 12px;
  padding: 12px 14px;
  overflow: auto;
  border-radius: 12px;
  background: var(--settings-segments);
  color: var(--ink);
  font: 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  -webkit-user-select: all;
  user-select: all;
}

/* Copy: the pink button, one size larger, with its icon. */
.settings-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  font-size: 16px;
}

.settings-copy svg {
  width: 20px;
  height: 20px;
}

/* Paste a progress link: a field a little darker than the card, with Paste
   next to it if a tap can read the clipboard. At 16px, Safari does not zoom
   in when the field gets the focus. */
.settings-paste {
  margin-bottom: 10px;
}

.settings-paste div {
  display: flex;
  gap: 10px;
}

.settings-paste input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--settings-segments);
  color: var(--ink);
  font: 16px/1.25 var(--font-sans);
}

/* Light, dark or the system setting: a track a little darker than the card,
   with the chosen item raised above it. */
.settings-segments {
  display: flex;
  max-width: 360px;
  gap: 2px;
  margin: 4px 0 12px;
  padding: 3px;
  border-radius: 12px;
  background: var(--settings-segments);
}

.settings-segment {
  position: relative;
  flex: 1;
  min-width: 0;
}

/* The radio button stays for the keyboard and for screen readers, but it is
   not visible. */
.settings-segment input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.settings-segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 9px;
  color: var(--muted);
  font: 600 15px/1 var(--font-sans);
}

/* The icons of the appearance choices, in thin lines. */
.settings-segment svg {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-segment input:checked + span {
  background: var(--key);
  color: var(--ink);
  box-shadow: 0 1px 3px #0000002e;
}

/* The narrowest phones show only the words. */
@media (width <= 359px) {
  .settings-segment svg {
    display: none;
  }
}

.settings-segment input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* The keys, and what each does. */
.settings-keys {
  display: grid;
  gap: 6px;
  margin: 0 0 12px;
}

.settings-keys div {
  display: grid;
  grid-template-columns: 132px 1fr;
  align-items: baseline;
  gap: 12px;
}

.settings-keys dt,
.settings-keys dd {
  margin: 0;
}

.settings-keys kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--key);
  font: 500 13px/1.5 var(--font-sans);
  white-space: nowrap;
}

.settings-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
}

/* The crossword page: the masthead above one play area the size of the
   window. The page never scrolls. Each clue list scrolls separately. */
.crossword-page {
  /* The masthead: 7px of space above a 56px bar. */
  --bar: 63px;
  display: grid;
  grid-template-rows: var(--bar) minmax(0, 1fr);
  height: 100dvh;
  /* Quick taps type and select, and never zoom. A pinch still zooms. */
  touch-action: manipulation;
}

/* On a computer, the masthead is the archive's masthead: a 75px bar. */
@media not all and (pointer: coarse) {
  .crossword-page {
    --bar: 82px;
  }
}

@media (height <= 479px) {
  .crossword-page {
    --bar: 55px;
  }
}

/* The layout calculation. Touch screens get the phone and tablet layouts.
   Desktop windows get their own layouts, from the shape of the window. All
   sizes are in container units of the play area, so the page as built is
   already final, and nothing is measured. */

.crossword-play {
  container: play / size;
  position: relative;
  min-width: 0;
}

.crossword-stage {
  /* One physical pixel. */
  --hair: 1px;
  /* --fit is the largest square that a layout allows. The board rounds down
     to whole physical pixels, and is centred on a whole pixel. */
  --side: var(--fit);
  --margin: calc((100cqw - var(--side)) / 2);
  display: grid;
  height: 100%;
  /* A long press on the board, clues or keys selects nothing. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

@media (resolution >= 2x) {
  .crossword-stage {
    --hair: 0.5px;
  }
}

@media (resolution >= 3x) {
  .crossword-stage {
    --hair: calc(1px / 3);
  }
}

/* The hundredth of a pixel stops a floating-point error from removing a
   whole pixel: 100cqw of a 460px column is 459.99999…px. */
@supports (width: round(down, 1px, 1px)) {
  .crossword-stage {
    --side: round(down, var(--fit) + 0.01px, var(--hair));
    --margin: round(down, (100cqw - var(--side)) / 2, var(--hair));
  }
}

.crossword-board {
  width: var(--side);
  height: var(--side);
}

.crossword-clues {
  container: clues / inline-size;
  position: relative;
  min-width: 0;
  min-height: 0;
}

.crossword-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  column-gap: var(--column-gap, 16px);
  height: 100%;
  padding-top: 4px;
}

.crossword-keyboard,
.crossword-float {
  display: none;
}

/* Phones and tablets. */
@media (pointer: coarse) {
  .crossword-play {
    width: min(100%, 1480px);
    justify-self: center;
  }

  .crossword-stage {
    --inset: 12px;
    --spacing: 20px;
    --top: 10px;
    --gap: 10px;
    --reserve: 246px;
    --beside: 260px;
    /* Portrait: the grid at the top, and the two clue columns below it, as wide
       as the grid. */
    --fit: min(
      100cqw - 2 * var(--inset),
      max(110px, 100cqh - var(--reserve) - var(--top) - var(--gap))
    );
    grid-template-columns: var(--margin) var(--side) minmax(0, 1fr);
    grid-template-rows: var(--side) minmax(0, 1fr);
    row-gap: var(--gap);
    padding-top: var(--top);
  }

  .crossword-board,
  .crossword-clues {
    grid-column: 2;
  }

  /* The keyboard replaces the clues and never resizes the grid. */
  .crossword-keyboard {
    display: block;
    grid-area: 2 / 1 / 3 / 4;
    place-self: end center;
    width: min(680px, 100% - 8px);
    height: min(300px, 100% - 4px);
    margin-bottom: 4px;
  }

  .crossword-stage[data-keyboard] .crossword-clues {
    display: none;
  }

  /* The floating button that shows the keyboard again. */
  .crossword-float {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: grid;
    place-items: center;
    width: 56px;
    height: 52px;
    border-radius: 16px;
    background: var(--ink);
    color: var(--paper);
    box-shadow: 0 4px 12px #00000029;
  }

  .crossword-float:active {
    opacity: 0.8;
  }

  .crossword-float svg {
    width: 30px;
    height: 30px;
    stroke-width: 1.7;
  }

  @container play (width >= 600px) and (height >= 560px) {
    .crossword-stage {
      --inset: 24px;
      --spacing: 24px;
      --top: 16px;
      --gap: 16px;
      --reserve: 320px;
      --beside: 300px;
    }
  }

  /* Landscape: the grid on the left, and the clues and the keyboard next to it. */
  @container play (width >= 560px) and (orientation: landscape) {
    .crossword-stage {
      --fit: min(
        100cqh - 2 * var(--inset),
        100cqw - 2 * var(--inset) - var(--spacing) - var(--beside)
      );
      grid-template-columns: var(--side) minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr) auto;
      column-gap: var(--spacing);
      row-gap: 0;
      padding: var(--inset);
    }

    .crossword-board {
      grid-area: 1 / 1 / 3 / 2;
    }

    .crossword-clues {
      grid-area: 1 / 2;
    }

    .crossword-keyboard {
      grid-area: 2 / 2;
      width: min(680px, 100%);
      height: min(300px, 100cqh - 2 * var(--inset));
    }
  }

  /* If the window is tall enough, the clues stay above the keyboard. */
  @container play (width >= 560px) and (orientation: landscape) and (height >= 560px) {
    .crossword-stage[data-keyboard] .crossword-clues {
      display: block;
    }

    .crossword-keyboard {
      margin-top: 10px;
    }
  }
}

/* Computers: the archive column, with the grid as tall as the window allows
   between a margin above and a margin below, and Across and Down next to it
   when they fit. */
@media not all and (pointer: coarse) {
  .crossword-play {
    width: var(--column);
    justify-self: center;
  }

  .crossword-stage {
    /* The space under the masthead, as on the archive, and less in a short
       window. */
    --top: clamp(16px, 6cqh, 32px);
    --gap: 32px;
    --column-gap: 24px;
    /* A clue column wide enough for most clues on one or two lines. */
    --clue: 260px;
    --min-clues: 160px;
    /* Stacked: the grid above Across | Down. */
    --fit: max(0px, min(100cqw, 100cqh - 2 * var(--top) - var(--gap) - var(--min-clues)));
    grid-template-rows: var(--side) minmax(0, 1fr);
    gap: var(--gap);
    padding-block: var(--top);
  }

  /* The capitals of the clue headings start level with the top edge of the
     grid. */
  .crossword-columns {
    padding-top: 0;
  }

  /* A hunch replaces the clues: its clue is level with the top of the board,
     and its keys are along the bottom of the board. */
  .crossword-stage[data-hunch] .crossword-clues {
    display: none;
  }

  .crossword-stage[data-hunch] .crossword-keyboard {
    display: block;
    align-self: start;
    height: min(100%, var(--side));
    min-height: 0;
  }

  /* Beside: in a landscape window, the clues are to the right of the grid,
     down to the margin below, with Across above Down until both fit side by
     side. */
  @container play (orientation: landscape) {
    .crossword-stage {
      --fit: max(0px, min(100cqh - 2 * var(--top), 100cqw - var(--gap) - var(--clue)));
      grid-template-columns: var(--side) minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr);
    }

    @container clues (width < 544px) {
      .crossword-columns {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: repeat(2, minmax(0, 1fr));
        row-gap: 24px;
      }
    }
  }

  /* Columns: a wide column always puts Across and Down side by side, next to a
     grid of 400px or more, which becomes narrower for them. */
  @container play (width >= 976px) {
    .crossword-stage {
      --fit: max(
        0px,
        min(100cqh - 2 * var(--top), 100cqw - var(--gap) - 2 * var(--clue) - var(--column-gap))
      );
      grid-template-columns: var(--side) minmax(0, 1fr);
      grid-template-rows: minmax(0, 1fr);
    }
  }
}

/* Only on paper: the address to solve it online. */
.crossword-printed {
  display: none;
}

/* Text only for screen readers: the selected clue, the status of a hunch, and
   the title of the finish card. */
.crossword-hidden,
.hunch-status,
.completion-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  margin: 0;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* The board. The squares fill it exactly. Each square draws the lines on its
   top and left edges as an inset shadow, and the last column and row close
   the frame. The squares get their size from the board as a container. */
.board {
  --square: calc(100cqw / 11);
  container-type: size;
  display: grid;
  grid-template: repeat(11, minmax(0, 1fr)) / repeat(11, minmax(0, 1fr));
}

.board > * {
  --rule-left: var(--hair);
  --rule-top: var(--hair);
  --rule-right: 0px;
  --rule-bottom: 0px;
  box-shadow:
    inset var(--rule-left) var(--rule-top) var(--grid-rule),
    inset calc(-1 * var(--rule-right)) calc(-1 * var(--rule-bottom)) var(--grid-rule);
}

.board > :nth-child(11n) {
  --rule-right: var(--hair);
}

.board > :nth-child(n + 111) {
  --rule-bottom: var(--hair);
}

/* A line shows only next to an open square, so adjacent blocks join. */
.board-block {
  background: var(--block);
}

.board-block[data-left] {
  --rule-left: 0px;
}

.board-block[data-up] {
  --rule-top: 0px;
}

.board-cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  margin: 0;
  border-radius: 0;
  background: var(--cell);
}

.board-cell[data-state="word"] {
  background: var(--word);
}

.board-cell[data-state="current"] {
  background: var(--pink);
  color: var(--selection-ink);
}

/* When there is a cursor, the pink square shows the focus. */
.board-cell[data-state="current"]:focus {
  outline: none;
}

.board-number {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: clamp(7px, var(--square) * 0.23, 15px);
  font-weight: 500;
  line-height: 1;
}

.board-letter {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 500 min(44px, var(--square) * 0.65) / 1 ui-rounded, var(--font-sans);
  transform: translateY(8%);
}

.board-arrow {
  position: absolute;
  top: 3px;
  right: 3px;
  width: max(6px, var(--square) * 0.2);
  height: max(6px, var(--square) * 0.2);
  stroke-width: 3;
}

/* The letters that a hunch found appear in the grid one by one while the
   board turns back, as if typed. */
.board-cell[data-landed] .board-letter {
  animation: board-land 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) both;
  animation-delay: calc(var(--order) * 70ms);
}

@keyframes board-land {
  from {
    opacity: 0;
    transform: translateY(8%) scale(0.4);
  }
}

/* The clues: compact columns, each with a heading above a thin line, then
   numbered clues that scroll separately. */
.clues-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

/* The heading starts where the numbers of the clues start. Its thin line is
   as wide as the column, as is the highlight of a clue. */
.clues-heading {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 0 0 6px 4px;
  border-bottom: var(--hair, 1px) solid var(--rule);
  font: 600 15px/1.25 var(--font-sans);
}

.clues-heading svg {
  width: 12px;
  height: 12px;
  color: var(--muted);
  stroke-width: 2.4;
}

.clues-list {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 6px 0 0;
  /* Space for the highlight of the selected clue, which goes 4px past the text. */
  padding: 0 4px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-width: thin;
}

.clues-list li + li {
  margin-top: 1px;
}

.clues-clue {
  display: block;
  width: calc(100% + 8px);
  margin-inline: -4px;
  padding: 5px 4px;
  border-radius: 8px;
  font: 400 15px/1.25 var(--font-sans);
  text-align: left;
}

.clues-clue b {
  font-weight: 700;
}

.clues-clue[aria-current] {
  background: var(--word);
}

.clues-clue:not([aria-current]):active {
  background: var(--surface);
}

@media (hover: hover) {
  .clues-clue:not([aria-current]):hover {
    background: var(--surface);
  }
}

/* The last clue can scroll above the floating keyboard button. */
@media (pointer: coarse) {
  .clues-list {
    padding-bottom: 72px;
  }
}

@media not all and (pointer: coarse) {
  /* Space for a scroll bar next to the clues. A list that continues below its
     bottom edge fades out there, and does not cut a clue in half. Its last
     clue can scroll above the fade. */
  .clues-list {
    padding-right: 20px;
    padding-bottom: 36px;
    -webkit-mask-image: linear-gradient(#000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(#000 calc(100% - 24px), transparent);
  }

  /* The box of the heading is only its capitals, so Across and Down start
     level with the top of the grid next to them, and the thin line stays at
     the same distance under the baseline. The arrow is not taller than the
     capitals. */
  .clues-heading {
    padding-bottom: 10px;
  }

  .clues-heading span {
    text-box: trim-both cap alphabetic;
  }

  .clues-heading svg {
    margin-block: -1px;
  }
}

/* The keyboards: the crossword keyboard, and the HUNCH! deck in its place.
   Each is a clue above three rows of keys that get their size from the deck,
   so on a touch screen the keys do not move when the board turns. */
.keyboard,
.hunch-deck {
  /* Ten keys and nine 4px gaps fill a row. Three rows fill the space under the
     clue. */
  --key-width: calc((100cqw - 52px) / 10);
  --key-height: clamp(32px, (100cqh - 108px) / 3, 54px);
  container-type: size;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  padding: 8px;
  border-radius: 16px;
  background: var(--surface);
}

.keyboard-banner {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-height: 0;
}

/* A long clue scrolls. A short clue is in the middle. */
.keyboard-clue {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
}

.keyboard-clue p {
  margin: auto 0;
  font: 500 15px/1.25 var(--font-sans);
  text-wrap: balance;
}

/* The number of the clue in pixel letters, after a pink square. */
.keyboard-label,
.hunch-label {
  font: 400 8px/1 var(--font-pixel), monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.keyboard-label {
  display: block;
  margin-bottom: 6px;
}

.keyboard-label::before,
.hunch-label::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  background: var(--pink);
}

.keyboard-keys,
.hunch-keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keyboard-row,
.hunch-key-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.keyboard-step:disabled {
  opacity: 0.4;
}

.keyboard-step svg {
  width: 24px;
  height: 24px;
}

/* A key: a short line along its bottom edge. Enter, Delete and the key that
   shows the clues are one and a half keys wide. */
.keyboard-key,
.keyboard-utility,
.hunch-key,
.hunch-enter,
.hunch-erase {
  --mark: var(--key);
  display: grid;
  place-items: center;
  width: var(--key-width);
  height: var(--key-height);
  border-radius: 8px;
  background: linear-gradient(var(--rule), var(--rule)) bottom / calc(100% - 14px) 1px no-repeat
    var(--mark);
  font: 500 min(22px, var(--key-height) * 0.43) / 1 var(--font-sans);
}

.keyboard-utility,
.hunch-enter,
.hunch-erase {
  --mark: var(--rule);
  width: calc(var(--key-width) * 1.5 + 2px);
}

.keyboard-key:active,
.keyboard-utility:active {
  background-color: var(--key-pressed);
}

.keyboard-utility svg,
.hunch-enter svg,
.hunch-erase svg {
  width: min(26px, var(--key-height) * 0.55);
  height: min(26px, var(--key-height) * 0.55);
  stroke-width: 1.7;
}

/* HUNCH!: the board turned, with a hunch on its back, and its deck in place
   of the keys or clues of the crossword. Squares and keys get the usual
   green, yellow and grey. Pink still shows where the reader is. */

/* The square of the board, as a card that turns on its vertical axis. */
.hunch-flip {
  container: side / size;
  perspective: 2400px;
}

.hunch-turn {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  /* The crossword script waits the same time for the turn (FLIP_MS). */
  transition: transform 650ms cubic-bezier(0.45, 0.05, 0.2, 1);
}

.hunch-turn[data-flipped] {
  transform: rotateY(180deg);
}

.hunch-front,
.hunch-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
}

.hunch-front > *,
.hunch-back > * {
  width: 100%;
  height: 100%;
}

.hunch-back {
  transform: rotateY(180deg);
}

/* With reduced motion, one side fades into the other. */
@media (prefers-reduced-motion: reduce) {
  .hunch-turn[data-flipped],
  .hunch-back {
    transform: none;
  }

  .hunch-front,
  .hunch-back {
    transition: opacity 0.2s !important;
  }

  .hunch-turn[data-flipped] .hunch-front,
  .hunch-turn:not([data-flipped]) .hunch-back {
    opacity: 0;
  }
}

/* The marks, for the title, the squares and the keys. */
.hunch-card [data-mark="correct"],
.hunch-panel [data-mark="correct"] {
  --mark: var(--correct);
}

.hunch-card [data-mark="present"],
.hunch-panel [data-mark="present"] {
  --mark: var(--present);
}

.hunch-card [data-mark="absent"],
.hunch-panel [data-mark="absent"] {
  --mark: var(--absent);
}

/* The back of the grid: its paper, its frame, and padding in proportion to
   the square, so that the small board of a phone keeps its squares large. */
.hunch-card {
  --pad: clamp(10px, 4.5cqmin, 32px);
  position: relative;
  display: flex;
  flex-direction: column;
  padding: var(--pad);
  /* The paper colour of the page, under the frame of the board. */
  background: var(--paper);
  box-shadow: inset 0 0 0 var(--hair, 1px) var(--grid-rule);
  outline: none;
}

/* The close buttons: a cross in the corner, here and on the finish card. */
.hunch-close,
.completion-close {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--muted);
}

.hunch-close svg,
.completion-close svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

/* The cross of HUNCH! is level with the padding of the squares. */
.hunch-close {
  z-index: 1;
  top: max(0px, var(--pad) / 2 - 6px);
  right: max(0px, var(--pad) / 2 - 6px);
}

@media (hover: hover) {
  .hunch-close:hover {
    background: var(--surface);
    color: var(--ink);
  }
}

/* Six rows of squares for the letters of the answer, as large as the card
   allows: up to about 64px on a computer, and larger on the large board of a
   tablet. The gap between the words of a phrase is wider. */
.hunch-field {
  container-type: size;
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
}

.hunch-rows {
  --gap: clamp(3px, 1.6cqmin, 6px);
  --size: min(
    clamp(60px, 14cqmin, 76px),
    (100cqw - (var(--letters) - 1 + var(--breaks)) * var(--gap)) / var(--letters),
    (100cqh - 5 * var(--gap)) / 6
  );
  display: grid;
  gap: var(--gap);
}

.hunch-row {
  display: flex;
  gap: var(--gap);
}

.hunch-tile {
  --mark: transparent;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border: max(1.5px, var(--size) * 0.04) solid var(--rule);
  color: var(--ink);
  font: 700 calc(var(--size) * 0.52) / 1 ui-rounded, var(--font-sans);
  text-transform: uppercase;
}

.hunch-tile[data-break] {
  margin-right: var(--gap);
}

.hunch-tile[data-mark] {
  border-color: var(--mark);
  background: var(--mark);
  color: var(--mark-ink);
}

/* A typed letter makes its square darker, and appears with a short
   animation. */
.hunch-tile[data-typed] {
  border-color: var(--grid-rule);
  animation: hunch-pop 0.12s ease-out;
}

@keyframes hunch-pop {
  50% {
    transform: scale(1.1);
  }
}

/* The letters that the grid already has, or that a green found, show lightly
   in the empty squares of the next guess. The reader can type over them. */
.hunch-tile[data-hint] {
  color: var(--muted);
  font-weight: 500;
  opacity: 0.55;
}

/* Pink shows where the next letter goes. */
.hunch-tile[data-cursor] {
  border-color: var(--pink);
}

/* A guess turns its squares one by one, and each mark shows at the halfway
   point. */
.hunch-row[data-state="revealing"] .hunch-tile {
  animation: hunch-turn 0.5s ease-in-out both;
  animation-delay: calc(var(--i) * var(--stagger));
}

@keyframes hunch-turn {
  0%,
  49.9% {
    border-color: var(--grid-rule);
    background: transparent;
    color: var(--ink);
  }

  0% {
    transform: rotateX(0);
  }

  50% {
    transform: rotateX(-90deg);
    border-color: var(--mark);
    background: var(--mark);
    color: var(--mark-ink);
  }

  100% {
    transform: rotateX(0);
  }
}

/* The winning guess jumps, square by square. */
.hunch-row[data-state="dancing"] .hunch-tile {
  animation: hunch-jump 0.6s ease both;
  animation-delay: calc(var(--i) * 90ms);
}

@keyframes hunch-jump {
  0%,
  20% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-34%);
  }

  50% {
    transform: translateY(4%);
  }

  60% {
    transform: translateY(-14%);
  }

  80% {
    transform: translateY(2%);
  }

  100% {
    transform: translateY(0);
  }
}

/* The toast: a note on the top edge of the card, like a sticker, so that it
   covers no guess, in reversed colours. Praise is in pixel letters, hot pink
   on charcoal, like the tags of ahhhh.app. */
.hunch-toast {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  margin: 0;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font: 600 14px/1.1 var(--font-sans);
  white-space: nowrap;
  translate: -50% -50%;
  box-shadow: 0 6px 18px #0000002e;
  animation: hunch-toast 0.18s ease-out;
  pointer-events: none;
}

.hunch-toast[data-kind="win"],
.hunch-toast[data-kind="loss"] {
  padding: 12px 14px 11px;
  background: var(--charcoal);
  color: var(--pink);
  font: 10px/1 var(--font-pixel), monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hunch-toast[data-kind="loss"] {
  color: #ffffff;
}

@keyframes hunch-toast {
  from {
    opacity: 0;
    translate: -50% calc(-50% - 6px);
  }
}

/* The HUNCH! deck: the same size as the crossword keyboard on a touch screen. */
.hunch-panel {
  container: panel / size;
  height: 100%;
}

.hunch-banner {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0 12px;
  overflow-y: auto;
  text-align: center;
}

.hunch-label {
  margin: auto 0 6px;
}

.hunch-clue {
  margin: 0 0 auto;
  font: 500 15px/1.25 var(--font-sans);
  text-wrap: balance;
}

.hunch-key,
.hunch-enter,
.hunch-erase {
  transition: background-color 0.2s, color 0.2s;
}

.hunch-enter {
  font: 8px/1 var(--font-pixel), monospace;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Enter shows its word where it fits, and a return arrow where it does not. */
.hunch-enter svg {
  display: none;
}

@container (width < 330px) {
  .hunch-enter .hunch-word {
    display: none;
  }

  .hunch-enter svg {
    display: block;
  }
}

.hunch-key[data-mark] {
  background: var(--mark);
  color: var(--mark-ink);
}

/* In dark mode, the key of a letter that is not in the answer becomes as dark
   as the deck. The crossword keys are already dark, so grey would hide it. */
.hunch-key[data-mark="absent"] {
  --mark: var(--hunch-mark);
  color: var(--hunch-absent-ink);
}

.hunch-key:active,
.hunch-enter:active,
.hunch-erase:active {
  filter: brightness(0.9);
}

@media (hover: hover) {
  .hunch-key:hover,
  .hunch-enter:hover,
  .hunch-erase:hover {
    filter: brightness(0.96);
  }
}

/* On a computer, in a tall window with the deck under the board, the deck is
   shortest. The clue has one or two lines above shorter keys. Letters come
   from the keyboard of the computer. These keys show the marks, and a mouse
   can click them. */
@media not all and (pointer: coarse) {
  .hunch-deck {
    --key-width: min(46px, (100cqw - 52px) / 10);
    --key-height: clamp(26px, (100cqh - 64px) / 3, 40px);
    gap: 6px;
    max-width: 600px;
    margin-inline: auto;
    padding: 6px 8px 8px;
  }

  .hunch-banner {
    display: block;
  }

  .hunch-label {
    display: inline;
    margin-right: 8px;
  }

  .hunch-clue {
    display: inline;
    font-size: 14px;
  }

  .hunch-keys,
  .hunch-key-row {
    gap: 4px;
  }

  /* Next to the board, the clue of the hunch is where the clues were, level
     with the top of the board, and the keys are along the bottom of the
     board. */
  @container panel (height >= 300px) {
    .hunch-deck {
      --key-width: min(44px, (100cqw - 16px - 9 * 5px) / 10);
      --key-height: clamp(34px, var(--key-width) * 1.2, 50px);
      justify-content: space-between;
      gap: 24px;
      max-width: none;
      padding: 0;
      border-radius: 0;
      background: none;
    }

    .hunch-banner {
      display: flex;
      flex: 0 1 auto;
      padding: 0;
      text-align: left;
    }

    .hunch-label {
      display: block;
      margin: 0 0 14px;
      padding-bottom: 10px;
      border-bottom: var(--hair, 1px) solid var(--rule);
    }

    .hunch-clue {
      display: block;
      font-size: clamp(17px, 4cqw, 22px);
      line-height: 1.3;
      text-wrap: pretty;
    }

    .hunch-keys {
      gap: 5px;
      padding: 10px 8px;
      border-radius: 16px;
      background: var(--surface);
    }

    .hunch-key-row {
      gap: 5px;
    }
  }
}

/* HUNCH! in the masthead: a hollow H on the same square as the gear, with a
   dot at the bottom for each hunch left (green, then grey after it is used).
   It is pink while its hunch shows. */
.badge-hunch {
  position: relative;
  flex: none;
}

/* Next to the ring on a phone. On a computer, the gap of the masthead stays
   between the progress and the controls. */
@media (width >= 600px) {
  .badge-hunch {
    margin-left: 12px;
  }
}

/* The H alone is on the middle line of the masthead, level with the gear. The
   dots do not count. */
.badge {
  position: relative;
}

.badge[aria-pressed="true"] {
  background: var(--word);
}

/* A tenth of its height, as thick as the line of the gear. */
.badge-h {
  width: auto;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 10;
  stroke-linejoin: round;
}

.badge[data-spent] .badge-h {
  color: var(--muted);
}

/* Three round dots, as round as the ends of the H, at the bottom of the
   square. */
.badge-pips {
  position: absolute;
  top: calc(50% + 8.5px + 4px);
  left: 50%;
  display: flex;
  gap: 2px;
  translate: -50% 0;
}

.badge-pips span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--correct);
}

.badge-pips span[data-spent] {
  background: var(--rule);
}

/* The tip, under the H: one line in a bubble, whose point is up at the H. */
.badge-tip {
  position: absolute;
  z-index: 10;
  top: calc(100% + 12px);
  right: -4px;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--badge-tip);
  box-shadow: 0 12px 32px #00000024;
  color: var(--ink);
  font: 400 17px/1.25 var(--font-sans);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  translate: 0 -4px;
  transition: opacity 0.15s, translate 0.15s, visibility 0.15s;
  pointer-events: none;
}

.badge-tip::before {
  content: "";
  position: absolute;
  top: -7px;
  /* Under the middle of the H: half the width of the square, minus the overhang
     of the bubble. */
  right: calc(22px + 4px - 6px);
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  border-top-left-radius: 3px;
  background: inherit;
  rotate: 45deg;
}

.badge-tip b {
  font-weight: 700;
}

@media (hover: hover) {
  .badge-hunch[data-inviting]:hover .badge-tip {
    transition-delay: 0.25s;
  }

  .badge-hunch[data-inviting]:not([data-quiet]):hover .badge-tip,
  .badge-hunch[data-inviting] .badge:focus-visible + .badge-tip {
    opacity: 1;
    visibility: visible;
    translate: 0 0;
  }
}

.badge-hunch[data-told] .badge-tip {
  opacity: 1;
  visibility: visible;
  translate: 0 0;
}

/* The finish card: the share photo in an airmail envelope, then the buttons
   to send it, above a dark sky with pixel stars and fireworks. */

/* The dialog is the whole stage: the window, transparent, above the darker
   page. Only an open dialog has a layout, so a closed dialog stays hidden. */
.completion-dialog {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.completion-dialog[open] {
  display: grid;
  place-items: center;
}

.completion-dialog::backdrop {
  background: radial-gradient(120% 90% at 50% 38%, #160e30e6, #04030ef7);
  animation: completion-dusk 0.8s ease-out;
}

@keyframes completion-dusk {
  from {
    opacity: 0;
  }
}

.completion-fireworks {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.completion-stage {
  position: relative;
  z-index: 1;
}

/* The axolotl (views.js) dances to a 120 bpm beat: a bounce each half second,
   a sway to each side each second, the arms and gills in time, and "AHHHH!"
   one time. It stands next to the card if there is space, and sits on the
   corner of the card on a phone. On a short phone, it does not show, and
   only the fireworks show. With reduced motion, the axolotl and its bubble
   do not move. */
.completion-mascot {
  position: absolute;
  bottom: 18px;
  left: calc(100% + 4px);
  display: block;
  width: 156px;
  border-radius: 16px;
  container-type: inline-size;
  animation: mascot-arrive 0.6s cubic-bezier(0.2, 1.5, 0.4, 1) 0.35s both;
}

@media (width <= 759px) {
  .completion-mascot {
    top: -70px;
    bottom: auto;
    left: 6px;
    width: 92px;
  }

  @media (height <= 739px) {
    .completion-mascot {
      display: none;
    }
  }
}

@keyframes mascot-arrive {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.6);
  }
}

.mascot-dancer {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  transform-origin: 50% 90%;
  animation: mascot-dance 1s ease-in-out infinite;
}

@keyframes mascot-dance {
  0%,
  100% {
    transform: translateY(0) rotate(-6deg) scale(1.04, 0.95);
  }

  25%,
  75% {
    transform: translateY(-9%) rotate(0deg) scale(0.98, 1.03);
  }

  50% {
    transform: translateY(0) rotate(6deg) scale(1.04, 0.95);
  }
}

.mascot-shadow {
  position: absolute;
  left: 50%;
  bottom: 3%;
  width: 46%;
  height: 6%;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.32);
  transform: translateX(-50%);
  animation: mascot-shadow 0.5s ease-in-out infinite;
}

@keyframes mascot-shadow {
  50% {
    transform: translateX(-50%) scale(0.78);
    opacity: 0.6;
  }
}

/* Each part turns about the point where it joins the body, in the units of
   the drawing, one beat to each side. The eyes blink at intervals. */
.mascot-arm-left,
.mascot-arm-right,
.mascot-gills-left,
.mascot-gills-right,
.mascot-tail,
.mascot-hat,
.mascot-eyes,
.mascot-mouth {
  transform-box: view-box;
  animation: mascot-swing 0.5s ease-in-out infinite alternate;
}

.mascot-arm-left {
  --from: rotate(45deg);
  --to: rotate(150deg);
  transform-origin: 58px 112px;
}

.mascot-arm-right {
  --from: rotate(-150deg);
  --to: rotate(-45deg);
  transform-origin: 102px 112px;
}

.mascot-gills-left {
  --from: rotate(-8deg);
  --to: rotate(8deg);
  transform-origin: 44px 71px;
}

.mascot-gills-right {
  --from: rotate(8deg);
  --to: rotate(-8deg);
  transform-origin: 116px 71px;
}

.mascot-tail {
  --from: rotate(-12deg);
  --to: rotate(10deg);
  transform-origin: 98px 120px;
}

.mascot-hat {
  --from: rotate(-6deg);
  --to: rotate(6deg);
  transform-origin: 92px 44px;
}

.mascot-mouth {
  --from: scaleY(0.8);
  --to: scaleY(1.12);
  transform-origin: 80px 80px;
}

.mascot-eyes {
  transform-origin: 80px 68px;
  animation: mascot-blink 3.8s infinite;
}

@keyframes mascot-swing {
  from {
    transform: var(--from);
  }

  to {
    transform: var(--to);
  }
}

@keyframes mascot-blink {
  0%,
  93%,
  100% {
    transform: none;
  }

  96% {
    transform: scaleY(0.12);
  }
}

/* A speech bubble that appears, shows its text and goes away. */
.mascot-bubble {
  position: absolute;
  left: 42%;
  bottom: 94%;
  padding: 8px 10px 7px;
  border: 2px solid #161616;
  border-radius: 12px;
  background: #ffffff;
  color: #161616;
  font: 12px/1 var(--font-pixel);
  letter-spacing: 1px;
  white-space: nowrap;
  transform: rotate(-4deg);
  transform-origin: 15% 100%;
  pointer-events: none;
  animation: mascot-pop 3.4s cubic-bezier(0.2, 1.5, 0.4, 1) 0.8s both;
}

.mascot-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 14px;
  width: 10px;
  height: 10px;
  border-right: 2px solid #161616;
  border-bottom: 2px solid #161616;
  background: #ffffff;
  transform: translateY(-50%) rotate(45deg) skew(12deg, 12deg);
}

.mascot-bang {
  color: var(--pink);
}

@keyframes mascot-pop {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(-10deg);
  }

  10% {
    opacity: 1;
    transform: scale(1.08) rotate(-4deg);
  }

  16%,
  84% {
    opacity: 1;
    transform: scale(1) rotate(-4deg);
  }

  100% {
    opacity: 0;
    transform: scale(0.85) rotate(-4deg);
  }
}

/* On a phone, where the axolotl is small and on the corner, the bubble is at
   its side. */
@container (width <= 110px) {
  .mascot-bubble {
    left: 82%;
    bottom: 62%;
    padding: 6px 7px 5px;
    font-size: 9px;
  }
}

.completion-envelope {
  width: min(100vw - 24px, 408px);
  padding: 9px;
  border-radius: 34px;
  background: repeating-linear-gradient(-45deg, #e63946 0 9px, #ff69b4 9px 18px, #2a9d8f 18px 27px,
    #3a86ff 27px 36px);
  box-shadow: 0 24px 80px #00000073;
  animation: completion-land 0.6s cubic-bezier(0.2, 1.3, 0.35, 1) both;
}

@keyframes completion-land {
  from {
    opacity: 0;
    transform: translateY(28px) rotate(-3deg) scale(0.94);
  }
}

.completion-card {
  position: relative;
  display: grid;
  justify-items: center;
  max-height: calc(100dvh - 34px);
  overflow: auto;
  padding: 48px 20px 14px;
  border-radius: 25px;
  /* In dark mode a shadow cannot show, so the card colour separates the card
     from the darker page. */
  background: var(--completion-card);
}

/* The photo is 4:5 and as large as the window allows, with space for the
   buttons under it. A white edge and a small turn make it look like a print,
   as the stickers on it do. */
.completion-photo {
  display: grid;
  place-items: center;
  width: min(100% - 12px, calc((100dvh - 270px) * 0.8));
  aspect-ratio: 4 / 5;
  margin: 0 0 22px;
  overflow: hidden;
  border: 6px solid var(--completion-photo-edge);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 2px 0 var(--completion-photo-shadow), 0 14px 30px #00000038;
  transform: rotate(-2deg);
}

.completion-photo img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  animation: completion-appear 0.25s ease-out;
}

@keyframes completion-appear {
  from {
    opacity: 0;
  }
}

.completion-drawing {
  color: var(--muted);
  font: 400 14px/1.4 var(--font-sans);
}

.completion-share {
  width: 100%;
  height: 50px;
  border-radius: 14px;
  background: var(--pink);
  color: var(--selection-ink);
  font: 600 17px/1 var(--font-sans);
}

.completion-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  margin-top: 10px;
}

.completion-actions button {
  min-height: 36px;
  padding: 0 2px;
  font: 500 14px/1 var(--font-sans);
}

.completion-actions button:hover {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--pink);
  text-underline-offset: 4px;
}

.completion-actions button:focus-visible {
  border-radius: 6px;
}

.completion-share:disabled,
.completion-actions button:disabled {
  opacity: 0.4;
  cursor: default;
}

.completion-status {
  min-height: 1.4em;
  margin: 6px 0 0;
  color: var(--muted);
  font: 400 13px/1.4 var(--font-sans);
  text-align: center;
}

.completion-close {
  top: 4px;
  right: 4px;
}

.completion-close svg {
  width: 16px;
  height: 16px;
}

/* A printed crossword: one sheet, with the board above all the clues in three
   columns, in ink, with no typed letters and no controls. Outlines print
   where shadows can fail to print, and blocks keep their black. */
@media print {
  html.play {
    overflow: visible;
  }

  .crossword-page {
    display: block;
    height: auto;
  }

  .crossword-play {
    container-type: normal;
    width: auto;
  }

  .crossword-stage {
    --hair: 0.5pt;
    --side: 104mm;
    display: block;
    height: auto;
    padding: 0;
  }

  .crossword-board {
    width: 104mm;
    height: 104mm;
    margin: 0 auto 7mm;
  }

  .crossword-clues {
    container-type: normal;
  }

  .crossword-columns {
    display: block;
    height: auto;
    padding: 0;
    column-count: 3;
    column-gap: 7mm;
  }

  .crossword-keyboard,
  .crossword-float,
  .completion-dialog,
  .completion-dialog::backdrop {
    display: none !important;
  }

  .crossword-printed {
    display: block;
    margin: 5mm 0 0;
    color: #000;
    font: 8pt/1.3 var(--font-sans);
    text-align: center;
  }

  .board > * {
    box-shadow: none;
    outline: 0.5pt solid #000;
    outline-offset: -0.25pt;
  }

  .board-block {
    background: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .board-cell,
  .board-cell[data-state] {
    background: #fff;
    color: #000;
  }

  .board-letter,
  .board-arrow {
    visibility: hidden;
  }

  .clues-column {
    display: block;
  }

  .clues-heading {
    padding: 0 0 1.5mm;
    border-bottom: 0.5pt solid #000;
    font-size: 10pt;
    break-after: avoid;
  }

  .clues-heading svg {
    display: none;
  }

  .clues-list {
    height: auto;
    margin: 2mm 0 5mm;
    padding: 0;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .clues-list li {
    break-inside: avoid;
  }

  .clues-clue,
  .clues-clue[aria-current] {
    width: auto;
    margin: 0;
    padding: 0.5mm 0;
    background: none;
    color: #000;
    font-size: 8.5pt;
    line-height: 1.25;
  }

  /* The front of the board, never a hunch, and no toast on it. */
  .hunch-turn,
  .hunch-turn[data-flipped] {
    transform: none;
  }

  .hunch-back,
  .hunch-toast {
    display: none;
  }
}
