/* checkbox.toys — site identity. Everything is a checkbox: the logo, the rules, the ticks on the cards, the games. */

:root {
  --paper: #f5f3ec;
  --card: #ffffff;
  --ink: #141414;
  --ink-2: #5d5a52;
  --ink-3: #9a968b;
  --line: #141414;
  --blue: #2357ff;
  --red: #ff3b2f;
  --gold: #f2a900;
  --green: #12a150;
  --purple: #7a3ff0;
  --radius: 10px;
  --font: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --ruled: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Crect x='6.5' y='6.5' width='11' height='11' rx='2.5' fill='none' stroke='%23141414' stroke-opacity='.075'/%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #101010;
    --card: #1a1a1a;
    --ink: #f2f0ea;
    --ink-2: #b4b0a6;
    --ink-3: #6f6c64;
    --line: #f2f0ea;
    --ruled: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Crect x='6.5' y='6.5' width='11' height='11' rx='2.5' fill='none' stroke='%23ffffff' stroke-opacity='.07'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #101010;
  --card: #1a1a1a;
  --ink: #f2f0ea;
  --ink-2: #b4b0a6;
  --ink-3: #6f6c64;
  --line: #f2f0ea;
  --ruled: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Crect x='6.5' y='6.5' width='11' height='11' rx='2.5' fill='none' stroke='%23ffffff' stroke-opacity='.07'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  background-image: var(--ruled);
  background-size: 24px 24px;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  margin: 0;
}

:where(input[type="checkbox"]) {
  accent-color: var(--ink);
}

/* colour ticks — used by screens (.c-*) and static pixel art (data-c). --a is the tick colour;
   screens and pixel art read it so their half-ticks can mix it lighter (see below). */
.c-red,
[data-c="r"],
[data-c="R"] {
  --a: var(--red);
  accent-color: var(--red);
}
.c-gold,
[data-c="y"],
[data-c="Y"] {
  --a: var(--gold);
  accent-color: var(--gold);
}
.c-green,
[data-c="g"],
[data-c="G"] {
  --a: var(--green);
  accent-color: var(--green);
}
.c-blue,
[data-c="b"],
[data-c="B"] {
  --a: var(--blue);
  accent-color: var(--blue);
}
.c-purple,
[data-c="p"],
[data-c="P"] {
  --a: var(--purple);
  accent-color: var(--purple);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- static pixel art (logo mark, card icons) ---------- */
.px {
  --px: 12px;
  display: inline-grid;
  grid-template-columns: repeat(var(--cols), var(--px));
  grid-auto-rows: var(--px);
  line-height: 0;
}

.px input {
  width: calc(var(--px) - 2px);
  height: calc(var(--px) - 2px);
  margin: 1px;
  padding: 0;
  pointer-events: none;
}

/* on 2× screens, pixel art uses the same ~11% gap as the game screens (the logo keeps its dots) */
@media (min-resolution: 2dppx) {
  .px:not(.mark) input {
    width: calc(var(--px) - 1.5px);
    height: calc(var(--px) - 1.5px);
    margin: 0.75px;
  }
}

/* ---------- checkbox screen (toys.screen) ---------- */
.scr {
  display: grid;
  grid-template-columns: repeat(var(--w), var(--box, 12px));
  grid-auto-rows: var(--box, 12px);
  gap: var(--gap, 1px);
  padding: 8px;
  width: max-content;
  max-width: 100%;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  line-height: 0;
}

.scr input {
  display: block;
  width: var(--box, 12px);
  height: var(--box, 12px);
  margin: 0;
  padding: 0;
  pointer-events: none;
}

/* Three tones without opacity. Empty boxes are disabled, the browser's own faded box (toys.js and
   pixels.html set it). Ticks are full colour. Half-ticks mix their colour toward the paper, so the
   three states still read as three tones at small sizes.
   PERF: never give individual boxes opacity, filter or transform. Each one becomes its own GPU layer
   and triggers layout when it toggles, which halves the frame rate of a busy screen. */
.scr input,
.px input {
  accent-color: var(--a, var(--ink));
}

.scr input:indeterminate,
.px input:indeterminate {
  accent-color: color-mix(in srgb, var(--a, var(--ink)) 70%, var(--card));
}

.scr-bare input:indeterminate {
  accent-color: color-mix(in srgb, var(--a, var(--ink)) 70%, var(--paper));
}

/* bare screens (pixel titles, read-outs) show only their ticks: faint empties blur the letters */
.scr-bare input:disabled {
  visibility: hidden;
}

.mark input:not([data-c]) {
  visibility: hidden;
}

.scr-bare {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.scr-live {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

/* ---------- on-screen controller (controls.pad) ---------- */
.pad {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-top: 4px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: none) and (pointer: coarse) {
  .pad {
    display: flex;
  }
}

.pad.pad-always {
  display: flex;
}

.pad-dirs {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(3, 60px);
  place-items: center;
}

.pad-dirs.pad-lr,
.pad-dirs.pad-ud {
  display: flex;
  gap: 12px;
}

.pad-dirs.pad-ud {
  flex-direction: column;
}

.pad-btn {
  width: 54px;
  height: 54px;
  margin: 0;
  cursor: pointer;
}

.pad-up {
  grid-column: 2;
  grid-row: 1;
}
.pad-left {
  grid-column: 1;
  grid-row: 2;
}
.pad-right {
  grid-column: 3;
  grid-row: 2;
}
.pad-down {
  grid-column: 2;
  grid-row: 3;
}

.pad-act {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.pad-action {
  width: 76px;
  height: 76px;
  accent-color: var(--red);
}

/* ---------- site bar (game + legal pages) ---------- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px;
}

.bar-home {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.bar-home:hover span {
  text-decoration: underline;
}

.mark {
  --px: 6px;
}

.bar-sound {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.bar-sound input {
  width: 16px;
  height: 16px;
  margin: 0;
}

/* ---------- home ---------- */
.marquee {
  display: flex;
  justify-content: center;
  padding: 36px 16px 6px;
}

.marquee .scr-live {
  touch-action: pan-y;
  cursor: crosshair;
}

/* the wordmark sits on a sheet of empty boxes you can tick. The shadow is the sheet's margin
   (padding would shift the pointer mapping of a bare screen). */
.marquee .scr-bare {
  background: var(--paper);
  border-radius: 2px;
  box-shadow: 0 0 0 10px var(--paper);
}

.marquee .scr-bare input:disabled {
  visibility: visible;
}

.home-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 22px;
  margin: 12px 16px 0;
}

.home-count {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 1.4em;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.home-progress {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
}

.home-progress input {
  width: 13px;
  height: 13px;
  margin: 0;
  pointer-events: none;
  accent-color: var(--green);
}

.home-random {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}

.home-random input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--red);
}

.shelves {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

.shelf {
  margin-top: 40px;
}

.shelf-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.shelf-label {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.2em;
  white-space: nowrap;
}

.shelf-count {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-2);
}

/* a horizontal rule made of checkboxes; ticks itself in when it scrolls into view */
.cb-rule {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  height: 16px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, #000 80%, transparent);
  mask-image: linear-gradient(90deg, #000 80%, transparent);
}

.cb-rule input {
  flex: none;
  width: 13px;
  height: 13px;
  margin: 0;
  pointer-events: none;
}

/* Cards: the game's icon on its own sheet of ruled paper, with the name and blurb below. The cards
   wrap with flex so a short last row sits centred: four to a row on desktop, fewer as it narrows, and
   one big card per row on a phone home page. The icon's pitch follows the card's width (whole px). */
.cards {
  --per: 4;
  --cards-gap: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--cards-gap);
}

.card {
  position: relative;
  flex: 0 0 calc((100% - (var(--per) - 1) * var(--cards-gap)) / var(--per));
  min-width: 0;
  display: flex;
  flex-direction: column;
  container-type: inline-size;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.card:hover,
.card:focus-visible {
  transform: translate(-3px, -3px);
  box-shadow: 5px 5px 0 var(--line);
  outline: none;
}

.card-check {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  width: 20px;
  height: 20px;
  margin: 0;
  pointer-events: none;
  accent-color: var(--green);
}

.card-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  background-color: var(--paper);
  background-image: var(--ruled);
  background-size: 24px 24px;
  background-position: center;
  border-bottom: 2px solid var(--line);
}

/* 32px each side keeps the icon clear of the corner tick */
.card-icon {
  --px: clamp(12px, round(down, (100cqi - 64px) / 11, 1px), 28px);
}

.card-name {
  padding: 14px 16px 0;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.01em;
}

.card-blurb {
  padding: 4px 16px 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
}

.card-best {
  margin-top: auto;
  min-height: calc(1.3em + 22px);
  padding: 8px 16px 14px;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 800;
  color: var(--green);
}

.shelf-solo {
  margin-top: 32px;
}

@media (max-width: 1040px) {
  .cards {
    --per: 3;
  }
  .more .cards {
    --per: 4;
    --cards-gap: 16px;
  }
}

@media (max-width: 760px) {
  .cards,
  .more .cards {
    --per: 2;
    --cards-gap: 14px;
  }
}

@media (max-width: 520px) {
  .home .cards {
    --per: 1;
    --cards-gap: 16px;
  }
  .home .card-stage {
    aspect-ratio: 16 / 10;
  }
  .more .card-name {
    padding: 10px 12px 0;
    font-size: 15px;
  }
  .more .card-blurb {
    padding: 4px 12px 0;
    font-size: 13px;
  }
  .more .card-best {
    padding: 6px 12px 10px;
  }
  .more .card-check {
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
  }
}

/* ---------- toy page ---------- */
.toy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 6px 16px 28px;
  text-align: center;
}

.toy-title {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 30px;
  margin-top: 4px;
}

.toy-tip {
  max-width: 540px;
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
}

.toy-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.toy-status {
  min-height: 1.5em;
  font-size: 14px;
  font-weight: 800;
}

.toy-actions,
.toy-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.toy-actions:empty,
.toy-options:empty {
  display: none;
}

.toy-button {
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--line);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.toy-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--line);
}

.toy-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

a.toy-button {
  display: inline-block;
  text-decoration: none;
}

.lost {
  padding-top: 40px;
}

.toy-button:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
  box-shadow: 3px 3px 0 var(--line);
}

.toy-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.toy-option input {
  width: 18px;
  height: 18px;
  margin: 0;
}

/* ad slot under the game (Playwire desktop leaderboard, 728×90). A fixed gap so the page never jumps
   when it fills, capped so a taller creative can't push the page around. Phones get no desktop tag,
   so the gap folds away below tablet width. */
.game-block {
  display: flex;
  justify-content: center;
  max-width: 1100px;
  height: 91px;
  max-height: 91px;
  margin: 20px auto 0;
  overflow: hidden;
}

@media (max-width: 767px) {
  .game-block {
    height: auto;
    margin-top: 0;
  }
}

.more {
  max-width: 1100px;
  margin: 28px auto 0;
  padding: 0 16px;
}

.more .shelf-head {
  margin-bottom: 14px;
}

/* ---------- footer ---------- */
.foot {
  max-width: 1100px;
  margin: 48px auto 0;
  padding: 0 16px 40px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.foot nav input {
  width: 12px;
  height: 12px;
  margin: 0;
  pointer-events: none;
}

/* ---------- legal ---------- */
.legal article {
  max-width: 700px;
  margin: 8px auto 0;
  padding: 20px 22px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

.legal article h1 {
  font-size: 20px;
  margin-bottom: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .toy-button {
    transition: none;
  }
}
