/**
 * MonoBoard — stylesheet.
 *
 * One file, no preprocessor, no framework. Layers keep specificity flat so a
 * component rule always beats a token rule without anyone writing !important.
 *
 * The palette is the app's own: a monochrome e-ink system where paper and ink
 * swap roles between light and dark, with one warm amber carried over from the
 * reading light. Nothing here is borrowed from another product.
 *
 * Several rules exist because of bugs found the hard way on a sibling site and
 * are marked LOAD-BEARING. They look removable. They are not.
 */

@layer tokens, base, layout, components, utilities;

/* =========================================================== tokens */
@layer tokens {
  :root {
    /* Paper and ink, straight from InkPalette's light mode. */
    --paper: #f0f0ec;
    --paper-raised: #f7f7f4;
    --paper-sunk: #e6e6e0;
    --ink: #111111;
    --ink-2: #444440;
    /* Must clear AA on BOTH light surfaces, not just the lighter one: 4.99:1 on
       --paper and 4.55:1 on --paper-sunk. The previous value passed on paper
       (4.70:1) but dropped to 4.29:1 inside a tinted section. */
    --muted: #676760;
    --rule: rgb(17 17 17 / 0.13);
    --rule-strong: rgb(17 17 17 / 0.26);

    /* The board itself, from InkPalette's light mode. Deliberately stronger
       than the page surfaces: a board has to read as an object, not a panel. */
    --board-light: #dcdcd4;
    --board-dark: #a4a49d;

    /* The reading light, darkened until it carries text on paper. */
    --warm: #8a6520;
    --warm-soft: rgb(138 101 32 / 0.1);

    --focus: #1b4ea8;

    /* Type: a quiet grotesque for prose, monospace for labels — as in InkType. */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
      Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

    --step--1: clamp(0.82rem, 0.79rem + 0.14vw, 0.9rem);
    --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.09rem);
    --step-1: clamp(1.18rem, 1.1rem + 0.36vw, 1.4rem);
    --step-2: clamp(1.45rem, 1.28rem + 0.75vw, 1.95rem);
    --step-3: clamp(1.85rem, 1.5rem + 1.55vw, 2.9rem);
    --step-4: clamp(2.3rem, 1.6rem + 3.1vw, 4.4rem);

    /* One spacing scale. Sections must never invent their own margins. */
    --section-space: clamp(3.5rem, 2.2rem + 5.4vw, 6.5rem);
    --shell-pad: clamp(1.15rem, 0.75rem + 1.9vw, 2.5rem);
    --shell-max: 68rem;
    --shell-narrow: 44rem;

    --radius: 2px;
    --header-h: 3.75rem;

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  }

  /* Dark mode inverts the system exactly as the app does: light ink on
     near-black paper, still warm-tintable. Only tokens change. */
  @media (prefers-color-scheme: dark) {
    :root {
      --paper: #151513;
      --paper-raised: #1d1d1a;
      --paper-sunk: #101010;
      --ink: #edece4;
      --ink-2: #b9b8ae;
      --muted: #8b8a81;
      --rule: rgb(237 236 228 / 0.14);
      --rule-strong: rgb(237 236 228 / 0.28);
      --board-light: #3b3b36;
      --board-dark: #24241f;
      --warm: #e2c288;
      --warm-soft: rgb(226 194 136 / 0.12);
      --focus: #8fb4ff;
    }
  }
}

/* ============================================================= base */
@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  /* LOAD-BEARING: the clip lives on html alone. Putting overflow on body too
     breaks viewport propagation, and the drawer's scroll lock stops working. */
  html {
    overflow-x: clip;
    scroll-padding-top: calc(var(--header-h) + 1rem);
    -webkit-text-size-adjust: 100%;
  }

  @media (prefers-reduced-motion: no-preference) {
    html {
      scroll-behavior: smooth;
    }
  }

  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--step-0);
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }

  h1,
  h2,
  h3 {
    margin: 0;
    line-height: 1.14;
    font-weight: 600;
    letter-spacing: -0.014em;
    text-wrap: balance;
  }

  p {
    margin: 0;
    text-wrap: pretty;
  }

  ul,
  ol,
  dl,
  dd {
    margin: 0;
    padding: 0;
  }

  li {
    list-style: none;
  }

  a {
    color: inherit;
    text-decoration-color: var(--rule-strong);
    text-underline-offset: 0.18em;
  }

  a:hover {
    text-decoration-color: currentColor;
  }

  :focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 3px;
    border-radius: 1px;
  }

  svg {
    display: block;
  }

  ::selection {
    background: var(--warm-soft);
  }
}

/* =========================================================== layout */
@layer layout {
  .shell {
    width: 100%;
    max-width: var(--shell-max);
    margin-inline: auto;
    padding-inline: max(var(--shell-pad), env(safe-area-inset-left));
  }

  .shell--narrow {
    max-width: var(--shell-narrow);
  }

  .section {
    padding-block: var(--section-space);
  }

  .section--tint {
    background: var(--paper-sunk);
  }

  .section--doc {
    padding-block: clamp(2.5rem, 1.6rem + 3.6vw, 4.5rem) var(--section-space);
  }

  .section__head {
    max-width: 38rem;
    margin-bottom: clamp(2rem, 1.4rem + 2.4vw, 3.25rem);
  }

  .section__title {
    font-size: var(--step-3);
    margin-block: 0.35em 0.5em;
  }

  /* An authored line break, not a wrap: the title is composed, so the break
     stays where it was written instead of moving with the container width. */
  .title__line {
    display: block;
  }

  .section__lead {
    color: var(--ink-2);
    font-size: var(--step-1);
    line-height: 1.5;
  }

  .section__note {
    margin-top: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
    max-width: 42rem;
    color: var(--muted);
    font-size: var(--step--1);
    line-height: 1.66;
  }
}

/* ======================================================= components */
@layer components {
  .kicker {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    font-weight: 500;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--muted);
  }

  /* ------------------------------------------------------ skip link */
  .skip-link {
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 100;
    padding: 0.6rem 0.9rem;
    background: var(--ink);
    color: var(--paper);
    font-size: var(--step--1);
    text-decoration: none;
    transform: translateY(-160%);
    transition: transform 0.16s var(--ease);
  }

  .skip-link:focus-visible {
    transform: none;
  }

  /* --------------------------------------------------------- header */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--rule);
  }

  .site-header__inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: var(--header-h);
  }

  .wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-decoration: none;
    white-space: nowrap;
  }

  /* The real production app icon. It ships with its own paper background, so
     it is not tinted, masked or recoloured here — only rounded the way iOS
     rounds it, and sized to sit on the type baseline. */
  .brand-mark {
    width: 1.6rem;
    height: 1.6rem;
    flex: none;
    display: block;
    border-radius: 22.5%;
    border: 1px solid var(--rule);
  }

  .brand-mark--hero {
    width: clamp(3.5rem, 2.6rem + 3.6vw, 5rem);
    height: clamp(3.5rem, 2.6rem + 3.6vw, 5rem);
    border-radius: 22.5%;
    box-shadow: 0 1px 2px rgb(17 17 17 / 0.06), 0 8px 24px -12px rgb(17 17 17 / 0.28);
  }

  @media (prefers-color-scheme: dark) {
    .brand-mark--hero {
      box-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 28px -12px rgb(0 0 0 / 0.7);
    }
  }

  .wordmark picture {
    display: block;
    flex: none;
  }

  .site-nav {
    margin-inline: auto;
  }

  .site-nav__list {
    display: flex;
    gap: clamp(1rem, 0.4rem + 1.6vw, 2rem);
  }

  .site-nav__list a {
    font-size: var(--step--1);
    text-decoration: none;
    color: var(--ink-2);
  }

  .site-nav__list a:hover {
    color: var(--ink);
  }

  .site-header__end {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-left: auto;
  }

  .lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--font-mono);
    font-size: var(--step--1);
  }

  .lang-switch__item {
    text-decoration: none;
    color: var(--muted);
  }

  .lang-switch__item[aria-current] {
    color: var(--ink);
  }

  .lang-switch__item abbr {
    text-decoration: none;
  }

  .lang-switch__sep {
    color: var(--rule-strong);
  }

  /* --------------------------------------------------- menu button */
  .nav-toggle {
    display: none;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    place-content: center;
    gap: 5px;
  }

  .nav-toggle__bar {
    display: block;
    width: 1.25rem;
    height: 1.5px;
    background: currentColor;
  }

  /* -------------------------------------------------------- drawer */
  .drawer {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr); /* LOAD-BEARING: see below */
    background: var(--paper);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    /* LOAD-BEARING: visibility is delayed only while closing. Delaying it on
       open as well means focus() lands on a still-invisible element and the
       drawer never receives keyboard focus. */
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease),
      visibility 0s linear 0.2s;
  }

  .drawer[data-open="true"] {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0s;
  }

  .drawer__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-h);
    padding-top: env(safe-area-inset-top);
    border-bottom: 1px solid var(--rule);
  }

  /* LOAD-BEARING: min-height:0. A grid item defaults to min-height:auto, which
     refuses to shrink below its content — overflow-y alone then does nothing
     and the end of the menu is unreachable in short landscape viewports. */
  .drawer__body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-block: clamp(1.5rem, 1rem + 2.4vw, 2.75rem);
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 2rem;
  }

  .drawer__list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }

  .drawer__list a {
    display: block;
    padding-block: 0.55rem;
    font-size: var(--step-2);
    font-weight: 600;
    letter-spacing: -0.015em;
    text-decoration: none;
  }

  .drawer__foot {
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
    font-size: var(--step--1);
    color: var(--muted);
  }

  /* ---------------------------------------------------------- hero */
  .hero {
    padding-block: clamp(3rem, 1.6rem + 6.5vw, 7.5rem) var(--section-space);
  }

  /* No narrower max-width on `.hero__inner`. `.shell` centres whatever box it
     is given, so capping it re-centres the hero and pushes it out of alignment
     with the header and every section below. The cap belongs on the text. */
  .hero__inner {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    align-items: center;
    gap: clamp(2rem, 1rem + 4vw, 5rem);
  }

  .hero__lead,
  .hero__note {
    max-width: 34rem;
  }

  .hero__brand {
    margin-bottom: clamp(1.25rem, 0.9rem + 1.4vw, 2rem);
  }

  /* The board plate.
     Two boxes on purpose: the outer one owns the layout square and the shadow,
     the inner face owns the tilt. Keeping them apart means the pointer can move
     the board without the shadow sliding out from under it.

     --depart is written by js/hero.js as the hero leaves the viewport; it only
     ever softens the shadow, so if the script never runs the board simply sits
     at its resting depth. */
  .hero__plate {
    --depart: 0;
    position: relative;
    aspect-ratio: 1;
    width: 100%;
    max-width: 30rem;
    margin-inline: auto;
    perspective: 1400px;
  }

  .hero__plate-face {
    height: 100%;
    padding: clamp(0.75rem, 0.4rem + 1.4vw, 1.4rem);
    background: var(--board-light);
    border: 1px solid var(--rule-strong);
    border-radius: 3px;
    transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg))
      translate3d(var(--shift-x, 0px), var(--shift-y, 0px), 0);
    /* Paper, not glass: a hairline of light along the top edge, a close contact
       shadow, and one long soft shadow that lifts the board off the page. */
    box-shadow: 0 1px 0 rgb(255 255 255 / 0.55) inset,
      0 1px 2px rgb(17 17 17 / calc(0.1 * (1 - var(--depart) * 0.6))),
      0 22px 48px -30px rgb(17 17 17 / calc(0.42 * (1 - var(--depart) * 0.7)));
    transition: box-shadow 0.9s var(--ease);
  }

  /* An inner boundary, one hairline in from the frame. It is what makes the
     plate read as a board with an edge rather than a filled rectangle. */
  .hero__plate-face::after {
    content: "";
    position: absolute;
    inset: calc(clamp(0.75rem, 0.4rem + 1.4vw, 1.4rem) - 1px);
    border: 1px solid var(--rule);
    pointer-events: none;
  }

  .hero__plate.is-moving .hero__plate-face {
    box-shadow: 0 1px 0 rgb(255 255 255 / 0.55) inset,
      0 2px 3px rgb(17 17 17 / 0.13),
      0 26px 54px -30px rgb(17 17 17 / 0.5);
  }

  @media (prefers-color-scheme: dark) {
    .hero__plate-face {
      box-shadow: 0 1px 0 rgb(255 255 255 / 0.05) inset,
        0 1px 2px rgb(0 0 0 / calc(0.5 * (1 - var(--depart) * 0.6))),
        0 22px 48px -30px rgb(0 0 0 / calc(0.9 * (1 - var(--depart) * 0.7)));
    }

    .hero__plate.is-moving .hero__plate-face {
      box-shadow: 0 1px 0 rgb(255 255 255 / 0.05) inset,
        0 2px 3px rgb(0 0 0 / 0.6),
        0 26px 54px -30px rgb(0 0 0 / 1);
    }
  }

  .board {
    display: block;
    width: 100%;
    height: 100%;
  }

  /* One board is lit at a time. The opening scene is marked in the HTML, so a
     page without scripting shows a finished, legal position rather than four
     boards stacked on top of each other. */
  .scene {
    opacity: 0;
    transition: opacity 1s var(--ease);
  }

  .scene.is-on {
    opacity: 1;
  }

  .board__checks {
    fill: var(--board-dark);
  }

  .board__rules {
    stroke: var(--board-dark);
    stroke-width: 0.25;
    opacity: 0.55;
    fill: none;
  }

  .board__dots {
    fill: var(--board-dark);
    opacity: 0.75;
  }

  /* A piece sits at --x,--y and travels by --dx,--dy. Keeping travel in its own
     pair of properties means the resting square stays declared in the HTML: a
     move can always be wound back to a legal starting position. */
  .piece {
    opacity: var(--o, 1);
    transform: translate(calc((var(--x, 50) + var(--dx, 0)) * 1px),
                         calc((var(--y, 50) + var(--dy, 0)) * 1px));
    transition: transform 0.8s var(--ease), opacity 0.45s var(--ease);
  }

  /* The app's own two-tone convention: the dark army is solid ink, the light
     army is filled with the board and outlined, so neither disappears when
     paper and ink change places in dark mode. */
  .piece--dark {
    fill: var(--ink);
    stroke: none;
  }

  .piece--light {
    fill: var(--board-light);
    stroke: var(--ink);
    stroke-width: 0.9;
    stroke-linejoin: round;
  }

  /* Chess only. The draughts men and the Reversi discs keep the heavier line —
     a plain circle needs it to hold its edge — but on a shape that already has
     a silhouette it reads as weight the piece does not have. */
  .piece--figure.piece--light {
    stroke-width: 0.5;
  }

  /* The turned rim of a draughts man reads as a groove, not a second piece. */
  .piece--dark .piece__rim {
    fill: none;
    stroke: var(--board-light);
    stroke-width: 0.5;
    opacity: 0.5;
  }

  .piece--light .piece__rim {
    fill: none;
    stroke-width: 0.5;
    opacity: 0.5;
  }

  /* A Reversi disc turning over: edge-on at the halfway point, where the
     runtime swaps its face. */
  .piece.is-flipping {
    animation: disc-turn 0.7s var(--ease);
  }

  /* The weight a piece puts down when it arrives. */
  .piece.is-settling {
    animation: piece-settle 0.28s var(--ease);
  }

  @keyframes disc-turn {
    0% { transform: translate(calc(var(--x) * 1px), calc(var(--y) * 1px)) scaleX(1); }
    50% { transform: translate(calc(var(--x) * 1px), calc(var(--y) * 1px)) scaleX(0.05); }
    100% { transform: translate(calc(var(--x) * 1px), calc(var(--y) * 1px)) scaleX(1); }
  }

  @keyframes piece-settle {
    0% {
      transform: translate(calc((var(--x) + var(--dx, 0)) * 1px),
                           calc((var(--y) + var(--dy, 0)) * 1px)) scale(1.04);
    }
    100% {
      transform: translate(calc((var(--x) + var(--dx, 0)) * 1px),
                           calc((var(--y) + var(--dy, 0)) * 1px)) scale(1);
    }
  }

  .hero__eyebrow {
    margin-bottom: 1.5rem;
  }

  /* LOAD-BEARING: grid, not block. Each line needs vertical breathing room for
     descenders; with block layout the negative margin that buys it collapses
     against the next element and the whole page shifts. */
  .hero__title {
    display: grid;
    font-size: var(--step-4);
    line-height: 1.04;
    letter-spacing: -0.03em;
  }

  /* fit-content, so the sweep below is the width of the words rather than the
     width of the column. */
  .hero__line {
    /* Room for descenders without adding leading between the lines. */
    --bleed: 0.14em;
    position: relative;
    display: block;
    width: fit-content;
    padding-block: var(--bleed);
    margin-block: calc(var(--bleed) * -1);
  }

  /* The sweep. It grows from the left, the words follow a beat later, and then
     it clears from the left as well — so nothing is left highlighted. Sits at
     scaleX(0) by default, which is also what a page without scripting shows. */
  .hero__line::before {
    content: "";
    position: absolute;
    inset: calc(var(--bleed) + 0.04em) -0.1em;
    z-index: -1;
    background: var(--paper-sunk);
    transform: scaleX(0);
    transform-origin: left center;
    pointer-events: none;
  }

  .hero__line-in {
    display: block;
  }

  .hero__lead {
    margin-top: clamp(1.25rem, 0.9rem + 1.4vw, 2rem);
    max-width: 34rem;
    font-size: var(--step-1);
    line-height: 1.52;
    color: var(--ink-2);
  }

  .hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  }

  .hero__note {
    margin-top: 1.5rem;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--muted);
  }

  /* -------------------------------------------------------- buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.9rem;
    padding: 0.7rem 1.35rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: var(--step--1);
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: background-color 0.16s var(--ease), color 0.16s var(--ease),
      border-color 0.16s var(--ease);
  }

  .btn--primary {
    background: var(--ink);
    color: var(--paper);
    border-color: var(--ink);
  }

  .btn--primary:hover {
    background: var(--warm);
    border-color: var(--warm);
    color: var(--paper);
  }

  @media (prefers-color-scheme: dark) {
    .btn--primary:hover {
      color: #151513;
    }
  }

  .btn--ghost {
    border-color: var(--rule-strong);
    color: var(--ink);
  }

  .btn--ghost:hover {
    border-color: var(--ink);
  }

  /* Not a link: the address exists as a constant, not yet as a mailbox. */
  .btn--disabled {
    border-color: var(--rule);
    color: var(--muted);
    font-family: var(--font-mono);
    font-weight: 500;
    cursor: default;
  }

  /* ---------------------------------------------------------- games */
  /* Three columns, not auto-fit: nine games divide into 3×3 exactly, and any
     other count leaves a stranded card alone on the last row. The hairline
     grid is a 1px gap over a ruled background, so the lines never double up. */
  .games {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--rule);
    border-block: 1px solid var(--rule);
  }

  /* Two columns cannot divide nine, so the ninth card takes the whole last
     row rather than sitting alone next to a hole. */
  @media (max-width: 60rem) {
    .games {
      grid-template-columns: repeat(2, 1fr);
    }

    .games > :last-child {
      grid-column: 1 / -1;
    }
  }

  .game {
    display: flex;
    gap: 1.1rem;
    align-items: flex-start;
    padding: clamp(1.25rem, 1rem + 1vw, 1.75rem);
    background: var(--paper);
  }

  .section--tint .game {
    background: var(--paper-sunk);
  }

  .game {
    transition: background-color 0.25s var(--ease);
  }

  .game:hover {
    background: var(--paper-raised);
  }

  .section--tint .game:hover {
    background: var(--paper);
  }

  .game__motif {
    flex: none;
    width: 3rem;
    height: 3rem;
    color: var(--ink);
    transition: transform 0.35s var(--ease), opacity 0.35s var(--ease);
    opacity: 0.88;
  }

  .game:hover .game__motif {
    transform: scale(1.06);
    opacity: 1;
  }

  .motif {
    width: 100%;
    height: 100%;
  }

  .motif__fill {
    fill: currentColor;
  }

  .motif__stroke {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .game__name {
    font-size: var(--step-1);
  }

  .game__origin {
    margin-top: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--warm);
  }

  .game__line {
    margin-top: 0.5rem;
    font-size: var(--step--1);
    line-height: 1.6;
    color: var(--ink-2);
  }

  /* --------------------------------------- reading-light showcase
   *
   * Three states, driven entirely by radio inputs and sibling selectors —
   * no JavaScript at any point. The inputs are visually hidden but focusable,
   * so the control is fully keyboard operable and readable by screen readers.
   *
   * Every colour below comes from the app's InkPalette:
   *   day     paper #F0F0EC · board #DCDCD4 / #A4A49D · ink #111111
   *   reading the same tones blended 85% toward the reading-light hues
   *   night   paper #151513 · board #3B3B36 / #24241F · ink #EDECE4
   */
  .lamp {
    --stage-paper: #f0f0ec;
    --stage-square: #dcdcd4;
    --stage-ink: #111111;
    --stage-open: #f0f0ec;
    --stage-rule: rgb(17 17 17 / 0.16);
  }

  /* Reading light: warmth 0.70 on the app's light ramp — a Paperwhite-style
     amber rather than the ramp's maximum, which reads orange over a large area. */
  .lamp:has(#lamp-reading:checked) {
    --stage-paper: #f2d6a9;
    --stage-square: #e0c799;
    --stage-ink: #111111;
    --stage-open: #f2d6a9;
    --stage-rule: rgb(75 63 44 / 0.22);
  }

  .lamp:has(#lamp-night:checked) {
    --stage-paper: #151513;
    --stage-square: #3b3b36;
    --stage-ink: #edece4;
    --stage-open: #24241f;
    --stage-rule: rgb(237 236 228 / 0.2);
  }

  .lamp__panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(1.75rem, 1rem + 3.4vw, 3.5rem);
  }

  .lamp__stage {
    aspect-ratio: 1;
    width: 100%;
    max-width: 26rem;
    padding: clamp(0.6rem, 0.35rem + 1vw, 1.1rem);
    background: var(--stage-paper);
    border: 1px solid var(--stage-rule);
    border-radius: 3px;
    box-shadow: 0 20px 50px -32px rgb(17 17 17 / 0.45);
    transition: background-color 0.55s var(--ease), border-color 0.55s var(--ease);
  }

  .stage__art { width: 100%; height: 100%; }
  .stage__paper { fill: var(--stage-paper); transition: fill 0.55s var(--ease); }
  .stage__squares { fill: var(--stage-square); transition: fill 0.55s var(--ease); }

  .stage__stone {
    transition: fill 0.55s var(--ease), stroke 0.55s var(--ease);
  }
  .stage__stone.is-solid { fill: var(--stage-ink); }
  .stage__stone.is-open {
    fill: var(--stage-open);
    stroke: var(--stage-ink);
    stroke-width: 1.7;
  }

  .lamp__switch {
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--rule-strong);
    border-radius: 999px;
    gap: 2px;
  }

  .lamp__label {
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.03em;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
  }

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

  .lamp:has(#lamp-day:checked)     label[for="lamp-day"],
  .lamp:has(#lamp-reading:checked) label[for="lamp-reading"],
  .lamp:has(#lamp-night:checked)   label[for="lamp-night"] {
    background: var(--ink);
    color: var(--paper);
  }

  /* The focus ring belongs on the label, because the input it controls is
     visually hidden — without this the control is invisible to keyboard use. */
  .lamp__radio:focus-visible + .lamp__panel label,
  .lamp__radio:focus-visible ~ .lamp__panel label[for] {
    outline: none;
  }
  .lamp__radio#lamp-day:focus-visible     ~ .lamp__panel label[for="lamp-day"],
  .lamp__radio#lamp-reading:focus-visible ~ .lamp__panel label[for="lamp-reading"],
  .lamp__radio#lamp-night:focus-visible   ~ .lamp__panel label[for="lamp-night"] {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
  }

  /* Only the active state's copy is shown. Without JavaScript the first state
     is checked by default, so there is always exactly one description. */
  .lamp__copy { display: none; margin-top: 1.5rem; max-width: 30rem; }
  .lamp:has(#lamp-day:checked)     .lamp__copy[data-state="day"],
  .lamp:has(#lamp-reading:checked) .lamp__copy[data-state="reading"],
  .lamp:has(#lamp-night:checked)   .lamp__copy[data-state="night"] {
    display: block;
  }

  .lamp__headline { font-size: var(--step-2); margin-bottom: 0.6rem; }
  .lamp__copy p { color: var(--ink-2); line-height: 1.66; }

  .lamp__caption {
    margin-top: 1.5rem;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--muted);
  }

  .points--sub {
    margin-top: clamp(2.5rem, 1.8rem + 2.8vw, 4rem);
  }

  /* --------------------------------------------- MonoBoard Originals */
  .band {
    background: var(--paper-raised);
    border-block: 1px solid var(--rule);
  }

  .originals {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(1.5rem, 1rem + 2.2vw, 2.5rem);
  }

  .original {
    display: grid;
    gap: 1.5rem;
    padding: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem);
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    border-radius: 3px;
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  }

  .original:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 40px -30px rgb(17 17 17 / 0.5);
  }

  .original__motif {
    width: clamp(4.5rem, 3.5rem + 3.6vw, 6.5rem);
    height: clamp(4.5rem, 3.5rem + 3.6vw, 6.5rem);
    color: var(--ink);
  }

  /* The motifs are drawn for a 3rem card. Blown up to more than twice that,
     the same relative stroke reads as a heavy mesh — thin it back down so the
     large version stays as quiet as the small one. */
  .original__motif .motif__stroke {
    stroke-width: 1;
  }

  .original__motif .motif {
    transition: transform 0.4s var(--ease);
  }

  .original:hover .motif {
    transform: scale(1.03);
  }

  .original__mark {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--warm);
    margin-bottom: 0.6rem;
  }

  .original__name {
    font-size: var(--step-2);
    letter-spacing: 0.01em;
  }

  .original__line {
    margin-top: 0.75rem;
    color: var(--ink-2);
    line-height: 1.66;
  }

  /* ---------------------------------------------- points / pillars */
  .points,
  .pillars,
  .denies {
    display: grid;
    gap: clamp(1.75rem, 1.2rem + 2.2vw, 3rem);
  }

  .points,
  .pillars {
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  }

  .denies {
    grid-template-columns: repeat(auto-fit, minmax(14.5rem, 1fr));
  }

  .point__title,
  .pillar__title,
  .deny__title {
    font-size: var(--step-1);
    margin-bottom: 0.55rem;
  }

  .point,
  .pillar {
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule-strong);
  }

  .point p,
  .pillar p,
  .deny p {
    color: var(--ink-2);
    font-size: var(--step--1);
    line-height: 1.66;
  }

  .deny__title::before {
    content: "";
    display: inline-block;
    width: 0.9rem;
    height: 1px;
    margin-right: 0.55rem;
    vertical-align: 0.28em;
    background: var(--warm);
  }

  /* ------------------------------------------------------- download */

  .download__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  }

  /* Not a button and not a link: a stated fact, sized to sit level with the
     one real control beside it. Nothing here is focusable, because there is
     nowhere for focus to go. */
  .status {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 2.9rem;
    padding: 0.7rem 1.35rem;
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--ink-2);
    cursor: default;
  }

  /* Decorative. The words already say what the state is; this only gives the
     line the one warm note the reading light introduced elsewhere. */
  .status__mark {
    flex: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warm);
  }

  /* -------------------------------------------------- document pages */
  .doc__head {
    max-width: var(--shell-narrow);
    margin-bottom: clamp(2rem, 1.4rem + 2.2vw, 3rem);
  }

  .doc__title {
    font-size: var(--step-3);
  }

  .doc__meta {
    margin-top: 0.75rem;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    color: var(--muted);
  }

  .doc__lead {
    margin-top: 1.1rem;
    font-size: var(--step-1);
    line-height: 1.5;
    color: var(--ink-2);
  }

  .doc__block {
    padding-top: clamp(1.5rem, 1.1rem + 1.4vw, 2.25rem);
  }

  .doc__block + .doc__block {
    border-top: 1px solid var(--rule);
    margin-top: clamp(1.5rem, 1.1rem + 1.4vw, 2.25rem);
  }

  .doc__block h2 {
    font-size: var(--step-1);
    margin-bottom: 0.9rem;
  }

  .doc__block p + p,
  .doc__block ul + p {
    margin-top: 0.85rem;
  }

  .doc__block p,
  .doc__block li {
    color: var(--ink-2);
    line-height: 1.7;
    /* Long policy links must wrap rather than push the page sideways. */
    overflow-wrap: anywhere;
  }

  .doc__list {
    margin-top: 0.85rem;
    display: grid;
    gap: 0.4rem;
  }

  .doc__list li {
    padding-left: 1.1rem;
    position: relative;
  }

  .doc__list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.72em;
    width: 0.55rem;
    height: 1px;
    background: var(--rule-strong);
  }

  .support__mail {
    margin-top: 0.25rem;
  }

  .support__pending {
    margin-top: 0.9rem;
    font-size: var(--step--1);
    color: var(--muted);
    line-height: 1.66;
  }

  /* ------------------------------------------------ homepage contact
   *
   * The closing section: eyebrow, a composed headline, three columns and one
   * action. Structurally the same idea as the sibling site; visually all
   * MonoBoard — hairlines instead of cards, ink instead of accent colour.
   */
  .contact-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(1.75rem, 1.2rem + 2.2vw, 3rem);
  }

  .contact-card {
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule-strong);
  }

  .contact-card__name {
    font-size: var(--step-1);
    margin-bottom: 0.55rem;
  }

  .contact-card__text {
    color: var(--ink-2);
    font-size: var(--step--1);
    line-height: 1.66;
  }

  .contact-action {
    margin-top: clamp(2rem, 1.4rem + 2.4vw, 3.25rem);
  }

  /* Two by one rather than three cramped columns once the measure gets tight;
     the third item takes the full width instead of being squeezed. */
  @media (max-width: 60rem) {
    .contact-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .contact-grid > :last-child {
      grid-column: 1 / -1;
    }
  }

  @media (max-width: 40rem) {
    .contact-grid {
      grid-template-columns: 1fr;
    }

    .contact-action .btn {
      width: 100%;
    }
  }

  /* ---------------------------------------------- portfolio teaser
   *
   * The other product, named once. A single hairline separates it from the
   * page, the way the document sections are separated — no card, no panel,
   * no tint. Everything except the app icon is MonoBoard's own language.
   */
  .portfolio {
    border-top: 1px solid var(--rule);
    padding-block: clamp(2.25rem, 1.6rem + 2.4vw, 3.5rem);
  }

  .portfolio__inner {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(1rem, 0.6rem + 1.6vw, 2rem);
  }

  .portfolio__icon {
    width: 3rem;
    height: 3rem;
    border-radius: 22.5%;
    border: 1px solid var(--rule);
    display: block;
  }

  .portfolio__title {
    font-size: var(--step-1);
    margin: 0.3rem 0 0.4rem;
  }

  .portfolio__body {
    max-width: 46ch;
    font-size: var(--step--1);
    line-height: 1.62;
    color: var(--ink-2);
  }

  .portfolio__cta {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
    font-size: var(--step--1);
    font-weight: 600;
    text-decoration: none;
    color: var(--ink);
    /* The rule under the link is what marks it, not the colour. */
    border-bottom: 1px solid var(--rule-strong);
    padding-bottom: 2px;
    transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
  }

  .portfolio__cta:hover,
  .portfolio__cta:focus-visible {
    color: var(--warm);
    border-bottom-color: currentColor;
  }

  .portfolio__arrow {
    transition: transform 0.2s var(--ease);
  }

  .portfolio__cta:hover .portfolio__arrow {
    transform: translateX(2px);
  }

  /* --------------------------------------------------------- footer */
  .site-footer {
    border-top: 1px solid var(--rule);
    padding-top: clamp(2.5rem, 1.8rem + 2.6vw, 4rem);
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }

  .site-footer__inner {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(2rem, 1.2rem + 3vw, 4rem);
    justify-content: space-between;
  }

  .site-footer__tagline {
    margin-top: 0.75rem;
    max-width: 20rem;
    font-size: var(--step--1);
    color: var(--muted);
  }

  /* Four groups, as a grid rather than a flex row: the columns can then fall
     to 2×2 on tablets without ever being squeezed into four narrow strips.
     `auto-fit` with a readable minimum does the deciding. */
  .site-footer__cols {
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: clamp(1.75rem, 1rem + 2.6vw, 3.5rem);
  }

  .site-footer__title {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.75rem;
  }

  .site-footer__cols ul {
    display: grid;
    gap: 0.4rem;
  }

  .site-footer__cols a {
    /* inline-block plus padding lifts every row past a 24px target without
       touching the type size — landscape phones are touch devices too, and
       they sit above the narrow-phone breakpoint. */
    display: inline-block;
    padding-block: 0.2rem;
    font-size: var(--step--1);
    text-decoration: none;
    color: var(--ink-2);
  }

  .site-footer__cols a:hover {
    color: var(--ink);
    text-decoration: underline;
  }

  .site-footer__base {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    justify-content: space-between;
    margin-top: clamp(2.5rem, 1.8rem + 2.6vw, 4rem);
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
    font-size: var(--step--1);
    color: var(--muted);
  }

  .site-footer__base a {
    text-decoration: none;
  }

  .site-footer__base a:hover {
    text-decoration: underline;
  }
}

/* ======================================================= utilities */
@layer utilities {
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* Reveal-on-scroll. Only ever active when JS confirmed it is observing;
     without JS, or if the module fails, the failsafe drops js-reveal and
     everything below is inert. */
  .js-reveal .reveal {
    opacity: 0;
    transform: translateY(0.6rem);
  }

  .js-reveal .reveal.is-in {
    opacity: 1;
    transform: none;
    transition: opacity 0.5s var(--ease) calc(var(--i, 0) * 45ms),
      transform 0.5s var(--ease) calc(var(--i, 0) * 45ms);
  }

  /* Locked by nav.js while the drawer is open. Applied to the root element,
     because body-level overflow does not reliably stop the viewport. */
  .is-locked {
    overflow: hidden;
  }
}

/* ====================================================== breakpoints */

/* Below the two-column threshold the hero stacks: text first, plate under it.
   The plate keeps its square proportion rather than being squashed. */
@media (max-width: 60rem) {
  .hero__inner {
    grid-template-columns: 1fr;
    gap: clamp(2rem, 1.4rem + 3vw, 3rem);
  }

  .hero__plate {
    max-width: 24rem;
    margin-inline: 0;
  }

  .lamp__panel {
    grid-template-columns: 1fr;
  }

  .lamp__stage {
    max-width: 22rem;
  }

  .originals {
    grid-template-columns: 1fr;
  }

  .portfolio__inner {
    grid-template-columns: auto minmax(0, 1fr);
    row-gap: 1.25rem;
  }

  .portfolio__cta {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

/* Tablet and below: the drawer takes over from the inline nav. */
@media (max-width: 56rem) {
  .site-nav {
    display: none;
  }

  .nav-toggle {
    display: grid;
  }

  .site-footer__inner {
    flex-direction: column;
  }

  /* Below the inline-nav threshold the brand block sits above the groups, so
     the four groups get the full width: two by two, still spacious. */
  .site-footer__cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
    max-width: 32rem;
  }
}

/* Phones: tighter rhythm, single-column cards. */
@media (max-width: 40rem) {
  :root {
    --section-space: clamp(2.75rem, 2rem + 3.5vw, 3.75rem);
  }

  .games {
    grid-template-columns: 1fr;
  }

  /* Two columns still read comfortably at phone widths and keep the footer
     from becoming a long ladder of headings. */
  .site-footer__cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.75rem 1.25rem;
    max-width: none;
  }



  .hero__actions .btn {
    flex: 1 1 auto;
  }

  /* Three labels do not fit one row on a narrow phone; let the switch wrap
     instead of forcing a horizontal scroll. */
  .lamp__switch {
    display: flex;
    flex-wrap: wrap;
    border-radius: 6px;
  }

  .lamp__label {
    flex: 1 1 auto;
    text-align: center;
    border-radius: 4px;
  }

  .hero__plate,
  .lamp__stage {
    max-width: 100%;
  }
}

/* Short landscape: the hero must not eat the whole viewport, and the drawer
   list has to stay scrollable rather than overflow behind the fold. */
@media (orientation: landscape) and (max-height: 30rem) {
  .hero {
    padding-block: 2.25rem 2.75rem;
  }

  .hero__title {
    font-size: clamp(1.9rem, 1.2rem + 4vw, 2.6rem);
  }

  .hero__lead {
    font-size: var(--step-0);
  }

  .drawer__list a {
    font-size: var(--step-1);
    padding-block: 0.4rem;
  }

  .drawer__body {
    gap: 1.25rem;
  }

  .hero__brand {
    margin-bottom: 0.9rem;
  }

  .brand-mark--hero {
    width: 2.75rem;
    height: 2.75rem;
  }

  /* Back to two columns, even though the viewport is narrower than the desktop
     threshold. A phone held sideways has width to spare and no height at all:
     stacking here would push the board two screens down and leave half the
     hero empty. */
  .hero__inner {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: center;
    gap: 1.75rem;
  }

  .hero__plate {
    max-width: 15rem;
    margin-inline: auto;
  }

  .hero__lead {
    max-width: 28rem;
  }
}

/* ============================================ hero entrance
 *
 * Staged, but short. Everything is in place inside 0.9s and nothing waits on a
 * network round trip: the `js` class is set by the inline script in the head,
 * before the first paint, so these run whether or not the module ever arrives.
 *
 * Only opacity and transform, and only once. The text is legible from its first
 * frame — it rises a few pixels, it does not fade up from nothing.
 */
@media (prefers-reduced-motion: no-preference) {
  .js .hero__brand,
  .js .hero__eyebrow,
  .js .hero__lead,
  .js .hero__actions,
  .js .hero__note {
    animation: hero-rise 0.5s var(--ease) both;
  }

  .js .hero__brand    { animation-delay: 0.06s; }
  .js .hero__eyebrow  { animation-delay: 0.12s; }
  .js .hero__lead     { animation-delay: 0.38s; }
  .js .hero__actions  { animation-delay: 0.48s; }
  .js .hero__note     { animation-delay: 0.58s; }

  /* Headline: the sweep opens the line, the words follow 0.16s behind it. */
  .js .hero__line::before {
    animation: hero-sweep 0.82s var(--ease) both;
    animation-delay: calc(0.2s + var(--i, 0) * 0.1s);
  }

  .js .hero__line-in {
    animation: hero-rise 0.46s var(--ease) both;
    animation-delay: calc(0.36s + var(--i, 0) * 0.1s);
  }

  .js .hero__plate {
    animation: hero-plate 0.7s var(--ease) both;
    animation-delay: 0.26s;
  }

  /* `backwards`, not `both`. A filling animation keeps hold of opacity after it
     ends and the sequence's own transition would never get a look in — pieces
     would jump between squares instead of moving. */
  .js .scene.is-on .piece {
    animation: piece-in 0.45s var(--ease) backwards;
    animation-delay: 0.5s;
  }

  @keyframes hero-rise {
    from { opacity: 0; transform: translateY(0.5rem); }
    to   { opacity: 1; transform: none; }
  }

  /* Grows from the left edge, then clears from the same edge — a hand moving a
     sheet of paper aside, not a bar sliding past. */
  @keyframes hero-sweep {
    0%   { transform: scaleX(0); transform-origin: left center; }
    46%  { transform: scaleX(1); transform-origin: left center; }
    54%  { transform: scaleX(1); transform-origin: right center; }
    100% { transform: scaleX(0); transform-origin: right center; }
  }

  @keyframes hero-plate {
    from { opacity: 0; transform: translateY(0.75rem) scale(0.985); }
    to   { opacity: 1; transform: none; }
  }

  @keyframes piece-in {
    from { opacity: 0; }
    to   { opacity: var(--o, 1); }
  }

  /* Same reasoning as the stones: the plate must be free once it has arrived,
     because js/hero.js writes to the face beneath it every frame. */
}

/* ==================================================== reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  /* Never leave a reveal target stuck at opacity 0 when motion is off. */
  .js-reveal .reveal {
    opacity: 1;
    transform: none;
  }

  /* The hero is present and finished, just not moving. The board keeps its
     opening position: layers, stone placement and faces all come from the HTML,
     so there is nothing here to restore. Pointer tilt and scroll separation are
     refused in js/hero.js, and the custom properties they would have written
     are neutralised here as well. */
  .hero__plate {
    --tilt-x: 0deg;
    --tilt-y: 0deg;
    --shift-x: 0px;
    --shift-y: 0px;
    --depart: 0;
  }

  .hero__brand,
  .hero__eyebrow,
  .hero__lead,
  .hero__actions,
  .hero__note,
  .hero__line-in,
  .hero__plate,
  .piece {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  /* The chess array stays exactly as the HTML declares it: every piece on its
     own square, before the move. js/hero.js never starts the sequence here, so
     --dx and --dy are never written and nothing needs winding back. */
  .piece {
    opacity: var(--o, 1) !important;
    transform: translate(calc(var(--x, 50) * 1px), calc(var(--y, 50) * 1px)) !important;
  }

  .hero__line::before {
    animation: none !important;
    transform: scaleX(0) !important;
  }



  .original:hover {
    transform: none;
  }

  .portfolio__cta:hover .portfolio__arrow {
    transform: none;
  }
}

/* ===================================================== launch sections
 *
 * The app's own screens, the free/Plus comparison and the two game pages.
 * Same paper, hairlines and type scale as everything above; no new colour.
 */
@layer components {
  /* ------------------------------------------------------------ screens */
  .screens {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(1rem, 0.4rem + 3vw, 3rem);
    max-width: 54rem;
    margin-inline: auto;
  }

  .screen {
    margin: 0;
  }

  /* A device is suggested, not drawn: one hairline, the screen's own corner
     radius and a soft lift. The picture inside is the real, unretouched app. */
  .screen__frame {
    overflow: hidden;
    border: 1px solid var(--rule-strong);
    background: var(--paper-sunk);
    box-shadow: 0 1px 0 var(--rule), 0 18px 40px -22px rgb(17 17 17 / 0.45);
  }

  .screen--phone .screen__frame {
    border-radius: clamp(1rem, 0.4rem + 2.6vw, 2.1rem);
  }

  .screen--tablet {
    max-width: 54rem;
    margin: clamp(2rem, 1.2rem + 3vw, 3.5rem) auto 0;
  }

  .screen--tablet .screen__frame {
    border-radius: clamp(0.6rem, 0.3rem + 1.2vw, 1.1rem);
  }

  .screen__frame img {
    display: block;
    width: 100%;
    height: auto;
  }

  .screen figcaption {
    margin-top: 0.9rem;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    color: var(--muted);
  }

  /* -------------------------------------------------------------- tiers */
  .tiers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-top: 1px solid var(--rule-strong);
    border-bottom: 1px solid var(--rule-strong);
  }

  .tier {
    padding: clamp(1.4rem, 1rem + 1.6vw, 2.25rem) 0;
  }

  .tier--plus {
    padding-left: clamp(1.25rem, 0.6rem + 2.6vw, 3rem);
    border-left: 1px solid var(--rule-strong);
  }

  .tier--free {
    padding-right: clamp(1.25rem, 0.6rem + 2.6vw, 3rem);
  }

  .tier__title {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .tier--plus .tier__title {
    color: var(--warm);
  }

  .tier__list {
    margin-top: 1.1rem;
    display: grid;
    gap: 0.7rem;
    list-style: none;
    padding: 0;
  }

  /* The filled square is the app's mark for "included". */
  .tier__list li {
    position: relative;
    padding-left: 1.35rem;
    line-height: 1.5;
  }

  .tier__list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.52em;
    width: 0.45rem;
    height: 0.45rem;
    background: var(--ink);
  }

  .tier--free .tier__list li::before {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--ink);
  }

  /* -------------------------------------------------------------- plans */
  .plans {
    margin-top: clamp(1.75rem, 1.2rem + 2vw, 2.75rem);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(0.75rem, 0.4rem + 1.4vw, 1.5rem);
    list-style: none;
    padding: 0;
  }

  .plan {
    padding: clamp(1rem, 0.8rem + 1vw, 1.5rem);
    border: 1px solid var(--rule-strong);
    background: var(--paper-raised);
  }

  .plan__name {
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .plan__price {
    margin-top: 0.5rem;
    font-size: var(--step-2);
    font-weight: 600;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
  }

  .plan__note {
    margin-top: 0.35rem;
    font-size: var(--step--1);
    color: var(--ink-2);
    line-height: 1.5;
  }

  /* ------------------------------------------------- links to game pages */
  .game__name a,
  .original__more a {
    color: inherit;
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.22em;
    text-decoration-color: var(--rule-strong);
  }

  .game__name a:hover,
  .original__more a:hover {
    text-decoration-color: currentColor;
  }

  .original__more {
    margin-top: 0.9rem;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  /* ---------------------------------------------------------- game pages */
  .game-head__motif {
    width: clamp(4.5rem, 3.6rem + 4vw, 6.5rem);
    margin-bottom: 1.4rem;
    color: var(--ink);
  }

  .game-head .kicker {
    margin-bottom: 0.6rem;
  }

  .game-actions {
    margin-top: clamp(2rem, 1.5rem + 2vw, 3rem);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
  }

  @media (max-width: 40rem) {
    .tiers {
      grid-template-columns: 1fr;
    }

    .tier--plus {
      padding-left: 0;
      border-left: 0;
      border-top: 1px solid var(--rule-strong);
    }

    .tier--free {
      padding-right: 0;
    }

    .plans {
      grid-template-columns: 1fr;
    }

    .screen figcaption {
      letter-spacing: 0.02em;
      font-size: 0.68rem;
    }
  }
}

@layer components {
  /* More than one sibling product: each keeps its own row, a little apart. */
  .portfolio__inner + .portfolio__inner {
    margin-top: clamp(1.5rem, 1rem + 2vw, 2.5rem);
  }
}

@layer components {
  /* On a phone three screens side by side are thumbnails. They become one
     row to swipe through instead, each large enough to read. */
  @media (max-width: 40rem) {
    .screens {
      display: flex;
      gap: 1rem;
      max-width: none;
      margin-inline: calc(var(--shell-pad) * -1);
      padding-inline: var(--shell-pad);
      overflow-x: auto;
      scroll-snap-type: x mandatory;
      scroll-padding-inline: var(--shell-pad);
      -webkit-overflow-scrolling: touch;
      scrollbar-width: none;
    }

    .screens::-webkit-scrollbar {
      display: none;
    }

    .screen--phone {
      flex: 0 0 62%;
      scroll-snap-align: start;
    }
  }
}
