/* Kidsize: the family game cupboard.
   A mustard-painted cupboard with wood shelves, boxes in their own colours with
   masking-tape labels, and a green felt table where the white rule sheets lie. */

:root {
  color-scheme: light;

  --mustard: #E0A526;
  --mustard-deep: #CF9418;
  --ink: #1A1A1A;
  --ink-soft: #3B2E0E;
  --wood: #9C6B2E;
  --shelf: #C99353;
  --shelf-shade: #B27C40;
  --lip: #7E5222;
  --rim: #6A4219;
  --tape: #EBD9A8;
  --tape-edge: #D6C28A;
  --red: #D7263D;
  --red-hover: #C11F35;
  --red-ink: #B01E31;
  --red-felt: #FF808B; /* marker red lifted so it still reads on the green felt */
  --felt: #275E47;
  --felt-lit: #2F6E54;
  --felt-soft: #D3E6DC;
  --paper: #FFFFFF;
  --paper-warm: #FFFDF6;
  --paper-ink: #1F1F1F;
  --paper-soft: #55534E;
  --rule: #E6E1D6;
  --rule-strong: #8C877E;
  --focus: #1A1A1A;

  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
  --marker: "Permanent Marker", "Comic Sans MS", "Chalkboard SE", cursive;
  --box-font: "Archivo", "Arial Narrow", "Roboto Condensed", sans-serif;

  --bar-h: 60px;
  /* Masking tape: a solid middle and small torn teeth down both cut ends. */
  --tape-mask:
    linear-gradient(#000 0 0) center / calc(100% - 8px) 100% no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='8'%3E%3Cpath d='M5 0H1L0 2l2 2-2 2 1 2h4z'/%3E%3C/svg%3E") left top / 5px 8px repeat-y,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='8'%3E%3Cpath d='M0 0h4l1 2-2 2 2 2-1 2H0z'/%3E%3C/svg%3E") right top / 5px 8px repeat-y;
  /* The wood: three tiling textures, each shown at half its size so it
     stays sharp on a phone. The shelf is light grain whose average colour
     is the shelf's own (#CE9859 against #C99353); its shaded back and lip
     are the same grain under a brown tint, .2 and .6, which come out at
     about shelf-shade and lip. The frame, round the shelves and between
     them, is oak (about #9E6020, against wood); the table's rim is walnut
     (about #5A2D0A, against rim). The flat colours sit under each texture
     while it loads. */
  --wood-photo: url("/assets/shelf-wood.webp") 0 0 / 512px auto;
  --frame-photo: url("/assets/frame-wood.webp") 0 0 / 543px auto;
  --rim-photo: url("/assets/rim-wood.webp") 0 0 / 543px auto;
  --tint-shade: rgba(70, 35, 0, .2);
  --tint-lip: rgba(70, 35, 0, .6);
  --felt-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Serbian: Permanent Marker has no č ć š ž đ, so the marker words use the
   closest felt-tip that does and still reads easily: Kalam, bold. */
html[lang="sr"] { --marker: "Kalam", "Permanent Marker", "Comic Sans MS", "Chalkboard SE", cursive; }

/* Until js/i18n.js fills in Serbian, index.html's English words stay hidden
   (the head script sets i18n-pending). */
html.i18n-pending [data-i18n] { visibility: hidden; }

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

html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--lip) var(--mustard); }

body {
  background: var(--mustard);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--tape); color: var(--ink); }

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

img, svg { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

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

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px;
  font-weight: 700; text-decoration: none;
}
.skip:focus { top: 10px; }

.icon { display: inline-flex; width: 1.2em; height: 1.2em; flex: none; }
.icon svg { width: 100%; height: 100%; }
.star.on { color: var(--ink); }

/* ---------- Top bar ---------- */

.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--bar-h);
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  background: var(--mustard);
}
.wordmark {
  display: inline-flex; align-items: baseline; gap: 10px; min-width: 0;
  font-weight: 800; font-size: 25px; letter-spacing: -.02em; text-decoration: none;
}
/* A long family name gives way to the remixes beside it. */
.bar-tag {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--marker); font-weight: 400; font-size: 16px; letter-spacing: 0; color: var(--ink-soft);
}
.bar-end { display: flex; align-items: center; gap: 4px; flex: none; }
/* Too narrow for a name worth reading: the menu still has it. */
@media (max-width: 360px) { .bar-tag { display: none; } }

/* The remixes left, on a strip of tape in the bar: the count in ink, and a
   red plus disc (red: pressing it asks for more). The tape is a child, so
   the button's focus ring isn't masked away with its torn ends. */
.remix-chip {
  display: inline-grid; place-items: center;
  min-height: 48px; padding: 0 2px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink);
}
.remix-chip[hidden] { display: none; }
.remix-chip-tape {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 9px 5px 12px;
  font-family: var(--marker); font-size: 16px; line-height: 1.1; white-space: nowrap;
  background: rgba(235, 217, 168, .93);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .12);
  -webkit-mask: var(--tape-mask); mask: var(--tape-mask);
  transform: rotate(-2deg);
  transition: transform .15s ease;
}
.remix-chip-plus {
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--red); color: #fff;
  transition: background-color .15s ease;
}
.remix-chip-plus .icon { width: 14px; height: 14px; }
.remix-chip-plus .icon svg { stroke-width: 3; }
.remix-chip:hover .remix-chip-tape { transform: rotate(0deg); }
.remix-chip:hover .remix-chip-plus { background: var(--red-hover); }
.remix-chip:active .remix-chip-tape { transform: rotate(0deg) translateY(1px); }
body:has(.room[data-view="shared"]) .bar-tag { display: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 48px; height: 48px; border-radius: 12px;
  border: 0; background: transparent; color: inherit;
}
.icon-btn .icon { width: 26px; height: 26px; }
.icon-btn[hidden] { display: none; }
.icon-btn:hover { background: rgba(0, 0, 0, .08); }
.icon-btn.on-felt:hover { background: rgba(255, 255, 255, .12); }
/* The menu's cog turns a tooth under the pointer, and half round while the
   menu is open, settling back with a little overshoot. */
.cog svg { display: block; width: 100%; height: 100%; transition: transform .6s cubic-bezier(.34, 1.56, .64, 1); }
@media (hover: hover) { #menuBtn:hover .cog svg { transform: rotate(45deg); } }
#menuBtn:active .cog svg { transform: rotate(90deg); transition-duration: .25s; }
body:has(#menu[open]) #menuBtn .cog svg { transform: rotate(180deg); }

/* ---------- Buttons ---------- */

.marker-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  /* 4px at the bottom matches the dark bottom edge, so the words and icon
     centre on the button's face. Permanent Marker's small caps carry the
     line, so this is where they look centred. */
  min-height: 58px; padding: 0 24px 4px;
  border: 0; border-radius: 12px;
  background: var(--red); color: #fff;
  font-family: var(--marker); font-size: 21px; line-height: 1.1; text-decoration: none; text-align: center;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18);
  transition: background-color .15s ease, transform .1s ease;
}
.marker-btn .icon { width: 22px; height: 22px; flex: none; }
.marker-btn:hover { background: var(--red-hover); }
.marker-btn:active { transform: translateY(1px); }
.marker-btn:disabled { background: #8C8279; cursor: not-allowed; transform: none; }

.tool {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 0 14px;
  border: 2px solid var(--rule-strong); border-radius: 10px;
  background: var(--paper); color: var(--paper-ink);
  font-size: 16px; font-weight: 700; text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease;
}
.tool:hover { border-color: var(--ink); }
.tool[aria-pressed="true"] { background: var(--tape); border-color: var(--tape-edge); }
.tool:disabled { opacity: .45; cursor: not-allowed; }
.tool:disabled:hover { border-color: var(--rule-strong); }
.tool.quiet { border-color: transparent; background: transparent; color: var(--paper-soft); padding-inline: 8px; }
.tool.quiet:hover { color: var(--ink); }
.tool.on-felt { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .55); }
.tool.on-felt:hover { border-color: #fff; background: rgba(255, 255, 255, .08); }
.tool.on-felt.quiet { border-color: transparent; color: var(--felt-soft); }
.tool.on-felt.quiet:hover { color: #fff; background: transparent; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }

.danger-btn {
  min-height: 48px; padding: 0 18px; border: 0; border-radius: 10px;
  background: var(--red); color: #fff; font-weight: 800;
}
.danger-btn:hover { background: var(--red-hover); }

/* ---------- The cupboard ---------- */

.cupboard { padding: 2px 12px calc(124px + env(safe-area-inset-bottom)); }

.cupboard-title {
  padding: 6px 6px 14px;
  max-width: 15ch;
  text-wrap: balance;
  font-size: clamp(31px, 8.6vw, 46px); line-height: 1.03; font-weight: 800; letter-spacing: -.02em;
}
.cupboard-title:focus { outline: none; }
.lede { padding: 0 6px 16px; max-width: 46ch; font-size: 17px; }

.shelf-msg {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 6px 14px; padding: 12px 14px; border-radius: 6px;
  background: var(--tape); font-weight: 700;
}

.frame {
  border-radius: 8px; padding: 10px;
  background: var(--frame-photo), var(--wood);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .1);
}

.shelves {
  --row: 200px;
  --gap: 10px;
  list-style: none;
  display: flex; flex-wrap: wrap; align-content: flex-start;
  column-gap: 6px; row-gap: var(--gap);
  padding: 0 8px;
  border-radius: 4px;
  position: relative; isolation: isolate;
}
/* One shelf per row: a shaded back, the plank, its dark lip, each a tint
   over the shelf grain. Between the rows the shelf is masked away, so the
   frame's oak shows through. It lies behind the boxes inside the shelves'
   own stacking context (isolate), so it never sinks under the frame. */
.shelves::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(to bottom,
    var(--tint-shade) 0, transparent 22px,
    transparent calc(var(--row) - 12px),
    var(--tint-lip) calc(var(--row) - 12px), var(--tint-lip) var(--row),
    transparent var(--row), transparent calc(var(--row) + var(--gap))),
    var(--wood-photo), var(--shelf);
  -webkit-mask: repeating-linear-gradient(to bottom, #000 0, #000 var(--row), transparent var(--row), transparent calc(var(--row) + var(--gap)));
  mask: repeating-linear-gradient(to bottom, #000 0, #000 var(--row), transparent var(--row), transparent calc(var(--row) + var(--gap)));
}
/* A cupboard always has at least two shelves, even with one box in it. */
.shelves { min-height: calc(var(--row) * 2 + var(--gap)); }
/* While the shelf loads: box-shaped shadows where the boxes will stand,
   breathing slowly, one after another. Reduced motion holds them still. */
.box-waiting {
  display: block;
  width: calc(var(--w) * var(--scale, 1)); height: calc(var(--h) * var(--scale, 1));
  border-radius: 3px;
  background: rgba(0, 0, 0, .1);
  transform: rotate(var(--tilt)); transform-origin: 50% 100%;
  animation: shelf-wait 1.1s ease-in-out calc(var(--i) * 140ms) infinite alternate both;
}
@keyframes shelf-wait { from { opacity: .35; } to { opacity: 1; } }

/* The first time the boxes show, each is put away in turn, as if by hand:
   it starts close to you (bigger, held a little above the plank and leaning
   back, with a held box's soft shadow), is pushed away from you onto the
   shelf, goes a touch too deep against the back, and eases forward to rest
   at its own tilt. The first ten go one after another; any more go in with
   the tenth. Only the start is held (backwards), so hover works the moment
   a box lands, and each box ends at its own look (a box out on the table
   stays faded). The letter stamps are cut into the shelf and stay put. */
.frame.arrive-wait .slot > :not(.stamp) { opacity: 0; }
.frame.arriving .slot > :not(.stamp) {
  --arrive-delay: calc(min(var(--i, 0), 10) * 90ms + var(--arrive-shift, 0ms));
  animation: put-away 700ms backwards, come-into-view 200ms linear backwards;
  animation-delay: var(--arrive-delay);
}
.frame.arriving .slot > .box {
  animation: put-away 700ms backwards, come-into-view 200ms linear backwards, held-shadow 560ms cubic-bezier(.45, .05, .3, 1) backwards;
  animation-delay: var(--arrive-delay);
}
@keyframes put-away {
  0% {
    transform: perspective(800px) translate3d(0, -26px, 170px) rotateX(9deg) rotate(calc(var(--tilt, 0deg) - 3deg));
    /* held a moment, pushed, slowing as it reaches the back */
    animation-timing-function: cubic-bezier(.45, .05, .3, 1);
  }
  78% {
    transform: perspective(800px) translate3d(0, 0, -8px) rotateX(0deg) rotate(var(--tilt, 0deg));
    animation-timing-function: cubic-bezier(.4, 0, .4, 1);
  }
  100% { transform: perspective(800px) translate3d(0, 0, 0) rotateX(0deg) rotate(var(--tilt, 0deg)); }
}
@keyframes come-into-view { from { opacity: 0; } }
/* The held box's shadow (cupboard.js SHADOW_HELD), tightening to the shelf's. */
@keyframes held-shadow {
  from { box-shadow: inset 0 0 0 2px rgba(0,0,0,.14), inset 0 12px 0 rgba(255,255,255,.07), inset 0 -6px 0 rgba(0,0,0,.18), 0 22px 30px rgba(0,0,0,.3); }
}

.slot { height: var(--row); padding-bottom: 12px; display: flex; align-items: flex-end; }

/* A to Z: the first box of each letter has its letter stamped into the
   shelf's back panel at its top left, pressed into the wood: a dark
   hollow, shadow under the top edge, light catching the bottom edge. */
.stamp {
  flex: none; align-self: flex-start;
  display: grid; place-items: center;
  width: calc(26px * var(--scale, 1)); height: calc(28px * var(--scale, 1));
  margin: calc(16px * var(--scale, 1)) calc(5px * var(--scale, 1)) 0 calc(1px * var(--scale, 1));
  border: 2px solid rgba(74, 44, 14, .42); border-radius: 5px;
  background: rgba(74, 44, 14, .08);
  box-shadow: inset 0 2px 3px rgba(60, 34, 8, .32), 0 1px 0 rgba(255, 238, 205, .38);
  color: rgba(70, 40, 12, .82);
  font-family: var(--box-font); font-weight: 900; font-size: calc(17px * var(--scale, 1)); line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 238, 205, .42);
  user-select: none; -webkit-user-select: none;
}

/* A new box, put away at its letter: a ring of tape colour pulses round it
   twice, so the family sees where it went. */
.box.just-landed::after {
  content: ""; position: absolute; inset: -7px; z-index: 3; pointer-events: none;
  border: 3px solid var(--tape); border-radius: 8px;
  animation: landed 1.1s ease-out 2 both;
}
@keyframes landed {
  0% { opacity: 0; transform: scale(1.14); }
  30% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

.box {
  position: relative;
  width: calc(var(--w) * var(--scale, 1)); height: calc(var(--h) * var(--scale, 1));
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 10px 9px; border: 0; border-radius: 3px;
  background: var(--box); color: var(--box-ink); text-align: left;
  transform: rotate(var(--tilt)); transform-origin: 50% 100%;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, .14),
    inset 0 12px 0 rgba(255, 255, 255, .07),
    inset 0 -6px 0 rgba(0, 0, 0, .18),
    0 2px 4px rgba(0, 0, 0, .25);
  cursor: grab;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .18s ease, opacity .18s ease;
}
.box:hover { transform: translateY(-5px) rotate(var(--tilt)); }
.box:focus-visible { outline-color: var(--ink); outline-offset: 4px; }
.box-title {
  font-family: var(--box-font); font-stretch: 72%; font-weight: 900;
  font-size: calc(var(--title) * var(--scale, 1)); line-height: .95; letter-spacing: .01em; text-transform: uppercase;
  overflow-wrap: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

.tape {
  position: absolute; left: -6px; right: -6px; top: calc(var(--tape-top, 70px) * var(--scale, 1));
  display: flex; flex-direction: column; gap: 3px;
  padding: 4px 7px 5px;
  color: var(--ink);
  font-family: var(--marker); font-size: calc(10.5px * var(--scale, 1)); line-height: 1.12;
  transform: rotate(-2deg);
}
/* Every strip of tape: slightly see-through, torn at both ends. */
.tape, .kid-tape, .gate-tape, .code-tape, .you-tape, .rules-part.turn, .play-tape, .play-crumb, .mini-score, .mini-best, .mini-result {
  background: rgba(235, 217, 168, .93);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .12);
  -webkit-mask: var(--tape-mask); mask: var(--tape-mask);
}
.tape-line { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tape-line.more { color: var(--ink-soft); font-size: calc(10px * var(--scale, 1)); }
/* Between two kid games on one strip: a short squiggle in the same marker. */
.tape-line + .tape-line {
  padding-top: calc(7px * var(--scale, 1));
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 4' fill='none' stroke='%233B2E0E' stroke-opacity='.6' stroke-width='1.1' stroke-linecap='round'%3E%3Cpath d='M1 2.6c2.5-2.4 4.5-2.4 7 0s4.5 2.4 7 0 4.5-2.4 7 0 4.500 2.400 7 0'/%3E%3C/svg%3E") 0 calc(1.5px * var(--scale, 1)) / calc(30px * var(--scale, 1)) calc(4px * var(--scale, 1)) no-repeat;
}
/* A favourite: starred by hand in front of its name, coloured in. */
.tape-star { display: inline-block; width: 1em; height: 1em; margin: 0 .2em 0 -.05em; vertical-align: -.14em; transform: rotate(-8deg); }
.tape-star svg { display: block; width: 100%; height: 100%; overflow: visible; fill: currentColor; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }

/* What is printed on the box itself, under the tape: details of the real box
   as the rule writer knows them (cupboard.js boxLook). A box has any of them
   or none. The band is the box art's second colour. The motif is what the
   game is played with, in the title's colour and fading out under the title.
   The seal is the age on the real box, which is why it needed a kid game. */
.box-band {
  position: absolute; z-index: -1; left: 0; right: 0; bottom: 0; height: 27%;
  border-radius: 0 0 3px 3px; background: var(--box-2);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .16), inset 0 -6px 0 rgba(0, 0, 0, .18), inset 2px 0 0 rgba(0, 0, 0, .14), inset -2px 0 0 rgba(0, 0, 0, .14);
}
.box-motif {
  position: absolute; z-index: -1; inset: 2px; border-radius: 2px;
  background: var(--box-ink); opacity: .13;
  -webkit-mask: var(--motif), linear-gradient(to bottom, transparent 12%, #000 55%); -webkit-mask-composite: source-in;
  mask: var(--motif), linear-gradient(to bottom, transparent 12%, #000 55%); mask-composite: intersect;
}
.box.has-band .box-motif { bottom: 27%; }
.motif-hexes { --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='48' fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M14 0v8M14 8 0 16v16l14 8 14-8V16zM14 40v8'/%3E%3C/svg%3E"); }
.motif-tiles { --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='26' height='26' fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M.8.8h24.4v24.4H.8z'/%3E%3Cpath d='M13 26V17a4 4 0 0 0-4-4H0' stroke-width='3'/%3E%3C/svg%3E"); }
.motif-tracks { --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='22' fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M0 6h12M0 16h12'/%3E%3Cpath d='M6 3v16' stroke-width='3'/%3E%3C/svg%3E"); }
.motif-cards { --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='34' fill='none' stroke='%23000' stroke-width='1.6'%3E%3Crect x='5' y='7' width='12' height='17' rx='2' transform='rotate%28-12 11 15%29'/%3E%3Crect x='16' y='11' width='12' height='17' rx='2' transform='rotate%2810 22 19%29'/%3E%3C/svg%3E"); }
.motif-dice { --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='30' fill='none' stroke='%23000' stroke-width='1.6'%3E%3Crect x='6' y='6' width='18' height='18' rx='4'/%3E%3Cpath d='M11 11h.01M15 15h.01M19 19h.01' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.motif-map { --motif: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='30' fill='none' stroke='%23000' stroke-width='1.6'%3E%3Cpath d='M2 23c8-11 12 6 20-4s10-8 16-6' stroke-dasharray='4 3'/%3E%3Cpath d='M34 4l5 5M39 4l-5 5'/%3E%3C/svg%3E"); }
.box.has-seal .box-title { padding-right: calc(24px * var(--scale, 1)); }
.box-seal {
  position: absolute; z-index: 2; top: calc(-7px * var(--scale, 1)); right: calc(-7px * var(--scale, 1));
  width: calc(34px * var(--scale, 1)); height: calc(34px * var(--scale, 1)); border-radius: 50%;
  display: grid; place-content: center; justify-items: center;
  background: var(--seal); color: var(--seal-ink);
  font-family: var(--box-font); font-stretch: 72%; font-weight: 900; line-height: .9; text-transform: uppercase;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .16), 0 1px 2px rgba(0, 0, 0, .3);
  transform: rotate(8deg);
}
.box-seal small { font-size: calc(7.5px * var(--scale, 1)); letter-spacing: .08em; }
.box-seal b { font-size: calc(15px * var(--scale, 1)); }

/* Kidsize's example boxes carry a straight printed sticker. The family's
   own boxes never do: handwriting on tape is theirs, print is Kidsize's. */
.box-sticker {
  position: absolute; z-index: 2; left: calc(9px * var(--scale, 1)); bottom: calc(12px * var(--scale, 1));
  padding: 1px 6px 2px; border-radius: 999px;
  background: var(--paper); color: var(--ink);
  font-size: calc(10px * var(--scale, 1)); font-weight: 800; line-height: 1.2; letter-spacing: .05em; text-transform: uppercase;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

/* A box out on the table keeps its face on the shelf, greyed and faded, so
   the family still sees which box it is. Hover does nothing to it. */
.box.is-out, .box.is-out:hover { filter: grayscale(1); opacity: .5; transform: rotate(var(--tilt)); cursor: default; }
.box.is-lifting { opacity: .22; transform: rotate(var(--tilt)); }

.ghost {
  position: fixed; z-index: 70; margin: 0;
  pointer-events: none; cursor: grabbing;
  transform-origin: 50% 50%;
  transition: none;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .14), 0 22px 30px rgba(0, 0, 0, .3);
}
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }

/* The empty slot grows to its tape: "Add a box" stays on one line. */
.add-slot {
  display: grid; place-items: center;
  min-width: calc(90px * var(--scale, 1)); height: calc(138px * var(--scale, 1)); padding: 0 8px; border-radius: 4px;
  border: 2px dashed rgba(26, 26, 26, .5);
  text-decoration: none;
  transition: background-color .15s ease;
}
.add-slot:hover { background: rgba(255, 255, 255, .14); }
.add-tape {
  position: static; flex-direction: row; align-items: center; gap: 4px;
  font-size: calc(16px * var(--scale, 1)); color: var(--red-ink); padding: 7px 10px 6px;
  white-space: nowrap;
  transform: rotate(-3deg);
}
.add-tape .icon { width: 16px; height: 16px; flex: none; }

.add-btn { display: flex; margin: 18px 6px 0; white-space: nowrap; }

.foot { margin: 30px 6px 0; max-width: 62ch; font-size: 14px; line-height: 1.5; color: var(--ink-soft); }

/* ---------- The table ---------- */

.table {
  --focus: var(--tape);
  overflow-x: clip; /* a lid slid off the side leaves the table, not the page */
  background-color: var(--felt);
  background-image: radial-gradient(ellipse at 40% 20%, rgba(255, 255, 255, .07), transparent 60%), var(--felt-grain);
  color: #fff;
}

.back {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; margin: 0 0 10px -4px; padding-right: 8px;
  font-weight: 700; text-decoration: none; color: #fff;
}
.back .icon { width: 22px; height: 22px; transition: transform .2s ease; }
.back:hover .icon { transform: translateX(-3px); }
/* Quiet links and buttons: hover or focus draws a marker squiggle under the
   words, left to right like a pen; it lifts off faster than it went on. Its
   colour says what the control does: going somewhere is tape, taking
   something away is red, and undoing (stop sharing) is ink. */
.wiggle-label { position: relative; }
.squiggle {
  position: absolute; left: -2px; right: -2px; bottom: -9px; height: 8px;
  clip-path: inset(-4px calc(100% + 4px) -4px -4px);
  transition: clip-path .14s ease-in;
  pointer-events: none;
}
.squiggle svg { display: block; width: 100%; height: 100%; overflow: visible; }
.squiggle path {
  fill: none; stroke: var(--wiggle, var(--ink)); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
:is(.wiggle-go, .wiggle-remove, .wiggle-undo, .wiggle-edit, .sheet-tab):not(:disabled):is(:hover, :focus-visible) .squiggle {
  clip-path: inset(-4px);
  transition: clip-path .38s cubic-bezier(.3, .1, .3, 1);
}
.wiggle-go { --wiggle: var(--tape); }
.wiggle-remove { --wiggle: var(--red); }
.wiggle-remove.on-felt { --wiggle: var(--red-felt); }
.wiggle-undo, .wiggle-edit { --wiggle: var(--ink); }

/* The empty table: where boxes land, and the last game played. */
.landing-title { font-family: var(--marker); font-size: 20px; line-height: 1.15; color: var(--tape); }
.landing-sub { font-size: 15px; color: var(--felt-soft); }

.last {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 8px 14px 8px 8px; border-radius: 12px;
  background: var(--paper); color: var(--paper-ink); text-decoration: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .25);
}
.last-play {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--red); color: #fff;
}
.last-play .icon { width: 18px; height: 18px; margin-left: 2px; }
.last-text { min-width: 0; display: grid; }
.last-label { font-size: 13px; color: var(--paper-soft); }
.last-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* A box held over the table: the felt lights up (and on phone rises to meet it). */
.table.drop-ready { background-color: var(--felt-lit); }

/* The open box */
.tray {
  position: relative; z-index: 1; /* its print sits under its words, inside it */
  max-width: 680px; margin: 4px 0 26px;
  padding: 18px 20px 26px; border-radius: 6px;
  background: var(--box); color: var(--box-ink);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .16), inset 0 -16px 0 rgba(0, 0, 0, .14), 0 10px 20px rgba(0, 0, 0, .3);
}
.tray-title {
  font-family: var(--box-font); font-stretch: 70%; font-weight: 900;
  font-size: clamp(36px, 10vw, 60px); line-height: .9; text-transform: uppercase; letter-spacing: .005em;
  overflow-wrap: anywhere;
}
.tray-title:focus { outline: none; }
.tray-count { margin-top: 8px; font-size: 16px; font-weight: 700; }

/* The box on the table is printed like the box on the shelf (cupboard.js
   tablePrint), grown to the table. The motif is drawn 1.8 times the shelf's
   size, line and all, a touch fainter (11%), and fades in from the title's
   corner, so the name stays clean and the empty side of the box carries the
   pattern. The lid has the band across its bottom 27%, as on the shelf; the
   tray, the box's bottom, has it on its 16px front wall. The age seal sits
   inside the top right corner (an overhang would be cut off where the tray
   clips while it grows), in the same place on lid and tray, so the lid
   lifts off one seal onto the other. Titles keep 14px clear of it. */
.box-motif.is-big {
  inset: auto; left: 3px; top: 3px;
  width: calc((100% - 6px) / 1.8); height: calc((100% - 6px) / 1.8);
  border-radius: 0; opacity: .11;
  transform: scale(1.8); transform-origin: 0 0;
  -webkit-mask: var(--motif), linear-gradient(to bottom right, transparent 25%, #000 70%); -webkit-mask-composite: source-in;
  mask: var(--motif), linear-gradient(to bottom right, transparent 25%, #000 70%); mask-composite: intersect;
}
.box-motif.is-big.to-band { height: calc((73% - 3px) / 1.8); }
.box-motif.is-big.to-wall { height: calc((100% - 19px) / 1.8); }
.box-band.is-big {
  border-radius: 0 0 7px 7px;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .16), inset 0 -3px 0 rgba(0, 0, 0, .2), inset 3px 0 0 rgba(0, 0, 0, .2), inset -3px 0 0 rgba(0, 0, 0, .2);
}
.box-band.is-wall {
  height: 16px; border-radius: 0 0 6px 6px;
  background: linear-gradient(rgba(0, 0, 0, .14), rgba(0, 0, 0, .14)), var(--box-2);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .16), inset 3px 0 0 rgba(0, 0, 0, .16), inset -3px 0 0 rgba(0, 0, 0, .16);
}
.box-seal.is-big { --scale: 1.4; top: 15px; right: 17px; }
.tray > .box-seal.is-big { top: 12px; right: 14px; }
.tray.has-seal .tray-floor { padding-right: 56px; }
.tray-new.has-seal .tray-floor { padding-right: 64px; }
.lid.has-seal { padding-right: 79px; }

/* New kid game for a box: the box lies open at the top and a fresh sheet
   goes into it. The paper lies on the box floor, so the box's own colour
   frames the form, and its dark front wall shows below the sheet.
   The box's name sits exactly where it sits on the box page (18px down,
   20px in), so it stays still while the tray grows to take the sheet. */
.tray-new { margin-bottom: 0; padding: 18px 12px 24px; }
.tray-new .tray-floor { padding: 0 8px; }
.tray-new .paper { margin-top: 18px; box-shadow: 0 6px 14px rgba(0, 0, 0, .3); }
.tray-new .form-sheet h1 { font-size: clamp(26px, 6vw, 34px); line-height: 1.1; }
@media (min-width: 600px) {
  .tray-new { padding: 18px 20px 28px; }
  .tray-new .tray-floor { padding: 0; }
}
/* Back on the box page, the sheet lies where it lay while it leaves and the
   box closes up (app.js shutTray). */
.tray-closing > .paper { margin: 18px -8px 0; box-shadow: 0 6px 14px rgba(0, 0, 0, .3); }
@media (min-width: 600px) { .tray-closing > .paper { margin: 18px 0 0; } }

/* The signature moment: the lid comes off the box on the table.
   The lid overhangs the tray by 3px like a real lid, and its title sits
   exactly over the tray's, so lifting it never makes the name jump. */
.lid, .ghost-title {
  font-family: var(--box-font); font-stretch: 70%; font-weight: 900; font-size: clamp(36px, 10vw, 60px);
  line-height: .9; letter-spacing: .005em; text-transform: uppercase; overflow-wrap: anywhere;
  color: var(--box-ink);
}
.lid {
  position: absolute; inset: -3px; z-index: 2;
  padding: 21px 23px; border-radius: 7px;
  background: var(--box);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .2), inset 0 14px 0 rgba(255, 255, 255, .08), 0 0 0 rgba(0, 0, 0, 0);
  transform-origin: 50% 50%;
  pointer-events: none;
}
/* Lift it off, then slide it off the side of the table, picking up speed.
   The table is seen from above, so the lift is only its shadow spreading
   under it: the lid neither moves up the screen (that read as a jump) nor
   grows (that read as a zoom). The lift starts from rest (ease-in-out), as
   the flying box has just come to rest on the felt. It stays solid while
   it crosses the box's own title, so the two names never blur together,
   and fades only at the end. Every step has the same transform list, so
   it moves along a straight path. */
@keyframes lid-off {
  0% {
    transform: translate(0, 0) rotate(0deg);
    animation-timing-function: cubic-bezier(.45, 0, .25, 1);
  }
  32% {
    transform: translate(0, 0) rotate(0deg); opacity: 1;
    box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .2), inset 0 14px 0 rgba(255, 255, 255, .08), 0 18px 26px rgba(0, 0, 0, .34);
    animation-timing-function: cubic-bezier(.5, 0, .75, .3);
  }
  80% { opacity: 1; }
  100% {
    transform: translate(72%, 0) rotate(4deg); opacity: 0;
    box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .2), inset 0 14px 0 rgba(255, 255, 255, .08), 0 24px 30px rgba(0, 0, 0, .3);
  }
}

/* The flying box on its way down: the shelf label has faded and the lid's
   big title fades in, laid out at its final width so it never re-wraps. */
.ghost-face { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; }
.ghost-title { position: absolute; top: 21px; left: 0; padding: 0 23px; }

.kid-sheets {
  list-style: none;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 30px 20px; max-width: 900px; margin: 0 0 30px; padding-top: 12px;
}
/* Sheets drop out of the box below it, a beat apart; the beat stops growing
   after the sixth so a full box never keeps the table waiting. */
@keyframes sheet-out {
  0% { opacity: 0; transform: translateY(-18px) rotate(-2.5deg); }
  35% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}
@keyframes table-in { from { opacity: 0; } }

.table[data-opening="arriving"] :is(.tray, .kid-sheets > li, .table-actions) { opacity: 0; }
.table[data-opening="open"] .lid { animation: lid-off 600ms linear both; will-change: transform, opacity; }
.table[data-opening="open"] .kid-sheets > li {
  animation: sheet-out 420ms cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(240ms + min(var(--i), 5) * 55ms);
}
.table[data-opening="open"] .table-actions { animation: table-in 260ms ease-out 320ms both; }

.kid-sheet {
  --r: -.7deg;
  position: relative; height: 100%;
  display: flex; flex-direction: column; gap: 8px;
  padding: 30px 18px 18px; border-radius: 3px;
  background: var(--paper); color: var(--paper-ink); text-decoration: none;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .3);
  transform: rotate(var(--r));
  transition: transform .18s ease, box-shadow .18s ease;
}
.kid-sheets li:nth-child(even) .kid-sheet { --r: .6deg; }
.kid-sheet:hover { transform: translateY(-4px) rotate(0deg); box-shadow: 0 12px 22px rgba(0, 0, 0, .32); }
.kid-sheet:focus-visible { outline-color: var(--tape); outline-offset: 5px; }
/* In the flow, pulled up over the sheet's top edge: a two-line name pushes
   the text down instead of covering it. */
.kid-tape {
  align-self: flex-start; max-width: 100%;
  margin: -44px 0 4px -6px;
  padding: 6px 12px 5px;
  color: var(--ink);
  font-family: var(--marker); font-size: 19px; line-height: 1.15;
  transform: rotate(-1.5deg);
}
.kid-tagline { font-size: 17px; line-height: 1.4; }
.kid-facts { font-size: 14px; color: var(--paper-soft); font-weight: 700; }
.kid-marks { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: auto; padding-top: 4px; }
.mark { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 700; color: var(--paper-ink); }
.mark .icon { width: 16px; height: 16px; }

/* Recent and starred kid games, left lying on the table. */
.recent { width: min(560px, 100%); }
.felt-head { margin-bottom: 18px; font-size: 17px; font-weight: 800; color: var(--felt-soft); }
.recent .kid-sheets { max-width: none; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 26px 16px; margin: 0; }
.recent .kid-sheet { padding: 26px 14px 14px; gap: 6px; }
.recent .kid-tape { margin-top: -40px; font-size: 16px; }

.table-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.felt-note { color: var(--felt-soft); font-size: 15px; max-width: 44ch; }

/* ---------- Paper: rule sheets, the form, notices ---------- */

.paper {
  --focus: var(--ink);
  --pad-x: 20px; /* the side padding; On your turn's tape runs out to the edges through it */
  max-width: 740px;
  padding: 26px var(--pad-x) 30px; border-radius: 4px;
  background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .32);
}
.paper.slim { max-width: 540px; display: grid; gap: 12px; justify-items: start; }
.paper.slim h1 { font-size: clamp(26px, 6vw, 34px); line-height: 1.1; font-weight: 800; }
.paper :is(h1, h2):focus { outline: none; }

.sheet-title { font-size: clamp(33px, 8vw, 50px); line-height: 1.02; font-weight: 800; letter-spacing: -.02em; }
.sheet-tagline { margin-top: 10px; max-width: 40ch; font-size: 20px; line-height: 1.38; }
.sheet-facts { margin-top: 14px; font-size: 15px; font-weight: 700; color: var(--paper-soft); }
.sheet-skills { margin-top: 2px; font-size: 15px; color: var(--paper-soft); }
.sheet-skills span { font-weight: 700; }

.sheet-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 22px 0 4px; }

.versions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.version {
  min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 2px solid var(--rule-strong); background: var(--paper);
  font-size: 15px; font-weight: 700;
}
.version:hover { border-color: var(--ink); }
.version[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* The language of the rules, under the versions: the page's own language
   switch (.lang-switch) when the rules are in both, or the one they are in
   and a button to add the other. */
.rules-lang-wrap { margin-bottom: 20px; }
.rules-lang { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.rules-lang-icon { width: 20px; height: 20px; color: var(--paper-soft); }
.rules-lang-label { margin-right: 2px; font-size: 15px; font-weight: 700; color: var(--paper-soft); }
.rules-lang .rules-lang-add { min-height: 40px; padding: 0 12px; font-size: 15px; }
.rules-lang-add .icon { width: 18px; height: 18px; }
.rules-lang-free { font-size: 14px; color: var(--paper-soft); }
.rules-lang-wrap .form-msg { margin-top: 6px; }

.keep-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px;
  margin: 22px 0 6px; padding: 14px 16px; border-radius: 6px;
  background: var(--tape);
}
.keep-bar p { max-width: 38ch; font-weight: 700; }
.keep-bar .tool { border-color: var(--ink); }

.share-panel {
  display: grid; gap: 10px; margin: 20px 0 4px; padding: 14px 16px;
  border: 2px dashed var(--rule-strong); border-radius: 8px;
}
.share-url a { font-weight: 700; word-break: break-all; text-underline-offset: 3px; }

.rules-part { margin-top: 32px; }
.rules-part h2 { margin-bottom: 12px; font-size: 22px; line-height: 1.2; font-weight: 800; }

.pieces { list-style: none; display: grid; gap: 12px; }
.pieces li { position: relative; display: grid; gap: 1px; padding-left: 30px; }
.pieces li::before {
  content: ""; position: absolute; left: 0; top: 3px;
  width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 4px;
}
.pieces strong { font-weight: 700; }
.pieces span { color: var(--paper-soft); }
.quiet .pieces li::before { top: 11px; height: 3px; border: 0; border-radius: 2px; background: var(--rule-strong); }

/* Take out of the box: tap a piece as it comes out and it's struck off,
   the line drawn left to right. The whole row is the tap target; its 6px
   top and bottom make up the list's gap. Only for this visit (sheet.js). */
.pieces.ticks { gap: 0; }
.pieces.ticks li { padding-left: 0; }
.pieces.ticks li::before { content: none; }
.tick { position: relative; display: grid; gap: 1px; padding: 6px 0 6px 30px; cursor: pointer; }
.tick input {
  appearance: none; -webkit-appearance: none;
  position: absolute; left: 0; top: 9px; width: 18px; height: 18px; margin: 0;
  border: 2px solid var(--ink); border-radius: 4px;
  background: var(--paper) center / 14px no-repeat;
  cursor: pointer;
}
@media (hover: hover) { .tick:hover input:not(:checked) { background-color: var(--tape); } }
.tick input:checked {
  background-color: var(--ink);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
.tick .strike {
  background: linear-gradient(currentColor, currentColor) 0 58% / 0 2px no-repeat;
  transition: background-size 260ms cubic-bezier(.16, 1, .3, 1);
}
.tick input:checked ~ * { color: var(--paper-soft); }
.tick input:checked ~ strong .strike { background-size: 100% 2px; }

.steps { list-style: none; counter-reset: step; display: grid; gap: 14px; }
.steps li {
  counter-increment: step;
  display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: start;
  font-size: 19px; line-height: 1.45;
}
.steps li::before {
  content: counter(step);
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 17px; font-weight: 800;
}
.steps li span { padding-top: 3px; }

/* On your turn: the part read again every turn, so it's the one long strip
   of tape on the sheet, stuck across it a hair off straight and 6px past
   both edges of the paper, so its torn ends (the tape rule above) show on
   the felt. Its name is in marker, after a going-round arrow, and its
   steps are a size up. */
.rules-part.turn {
  margin: 36px calc(-1 * var(--pad-x) - 6px) 0;
  padding: 22px calc(var(--pad-x) + 6px) 26px;
  transform: rotate(-.4deg);
}
.rules-part.turn h2 {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
  font-family: var(--marker); font-weight: 400; font-size: 28px; line-height: 1.1;
}
.rules-part.turn h2 .icon { width: 26px; height: 26px; flex: none; }
.rules-part.turn .steps { gap: 16px; }
.rules-part.turn .steps li { font-size: 20px; }

.win { max-width: 52ch; font-size: 20px; line-height: 1.45; font-weight: 700; }
/* The backstory: read to the child before the first turn. */
.story { max-width: 52ch; font-size: 20px; line-height: 1.5; text-wrap: pretty; }
/* Rules from before stories: a free button where the story would be. */
.story-none { color: var(--paper-soft); }
.story-add-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.story-add .form-msg { margin-top: 8px; }

.tweaks { display: grid; gap: 12px; }
.tweaks dt { font-weight: 800; }
.tips { display: grid; gap: 8px; padding-left: 1.2em; }

.notes {
  display: grid; gap: 8px; margin-top: 30px; padding: 14px 16px; border-radius: 6px;
  background: var(--tape); font-size: 16px;
}

.tweak { margin-top: 36px; padding-top: 26px; border-top: 2px solid var(--rule); }
.tweak-lede { margin-bottom: 12px; color: var(--paper-soft); }
.tweak .didnt-work { margin-top: 12px; }

.note textarea {
  display: block; width: 100%; min-height: 100px; padding: 12px 14px;
  border: 2px solid var(--rule-strong); border-radius: 10px;
  background: var(--paper-warm); font-size: 17px; line-height: 1.45; resize: vertical;
}
.note-status { display: block; min-height: 1.5em; margin-top: 6px; font-size: 14px; color: var(--paper-soft); }

.sheet-end { margin-top: 30px; padding-top: 14px; border-top: 2px solid var(--rule); }
.shared-foot { margin-top: 34px; padding-top: 16px; border-top: 2px solid var(--rule); font-size: 15px; color: var(--paper-soft); }

/* A shared game on its way (app.js openingSheet): the sheet it will be,
   with pencil lines where its words will go. Each line is as tall as the
   text it stands for and spaced like it, so the words land where the lines
   were. They breathe one after another, like the shelf's waiting boxes. */
.opening-title { font-size: clamp(26px, 6vw, 34px); line-height: 1.1; font-weight: 800; }
.wait { display: grid; justify-items: start; margin-top: 10px; }
.wait-line {
  display: block; width: var(--w); max-width: 100%; height: 13px; margin: 7px 0;
  border-radius: 3px; background: var(--rule);
  animation: shelf-wait 1.1s ease-in-out calc(var(--i) * 90ms) infinite alternate both;
}
.wait-facts { height: 10px; margin: 20px 0 6px; }
.wait-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 8px; width: 100%; margin: 22px 0 4px; }
.wait-tools .wait-line { margin: 0; }
.wait-tools .wait-marker { height: 58px; margin-right: 8px; border-radius: 12px; }
.wait-tools .wait-tool { height: 46px; border-radius: 10px; }
.wait-head { height: 15px; margin: 38px 0 18px; }
.wait-piece { display: grid; grid-template-columns: 18px 1fr; column-gap: 12px; width: 100%; margin-bottom: 12px; }
.wait-tick { grid-row: span 2; height: 18px; margin: 3px 0 0; border-radius: 4px; background: none; box-shadow: inset 0 0 0 2px var(--rule); }
.wait-name { height: 11px; margin: 7px 0 6px; }
.wait-job { height: 11px; margin: 6px 0 7px; }
/* The words come onto the waiting sheet: the paper stays put, its heading
   first, the rest a beat later. */
.paper.arrived > * { animation: come-into-view 360ms cubic-bezier(.16, 1, .3, 1) both; }
.paper.arrived > :not(.sheet-head) { animation-delay: 80ms; }

.form-msg { color: var(--red-ink); font-weight: 700; }
.form-msg:empty { display: none; }

/* Writing rules: a marker line drawn over and over. */
.writing { display: grid; justify-items: start; gap: 10px; margin-top: 18px; }
.pen { width: min(320px, 100%); height: 28px; }
.pen svg { width: 100%; height: 100%; overflow: visible; }
.pen path { fill: none; stroke: var(--red); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 420; stroke-dashoffset: 420; animation: draw 1.8s ease-in-out infinite; }
@keyframes draw { 60% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -420; } }
.writing-line { font-size: 22px; font-weight: 800; }
.writing-sub { color: var(--paper-soft); }
/* The rules are back while a mini game is going: the pen line stays drawn. */
.writing.is-done .pen path { animation: none; stroke-dashoffset: 0; }

/* Mini games for the wait (js/mini/): played on a little felt table of
   their own in a walnut rim, shown from the start under a cover. */
.mini { justify-self: stretch; margin-top: 6px; }
.mini-host { position: relative; width: 100%; max-width: 440px; }
/* On the fuse felt the panel is centred; with a game it takes the full
   width, so the game's table isn't squeezed to the words' width. */
.fuse-status .writing:has(.mini-host) { justify-self: stretch; }
.fuse-status .mini-host { margin-inline: auto; }
/* The cover over the table: the felt dimmed under it, the words and buttons
   on top. Over a game in play it fades in, and its buttons take no tap
   until it has (is-arming). */
.mini-cover {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-content: center; justify-items: center; gap: 12px;
  padding: 18px 16px; border-radius: 16px;
  background: rgba(13, 38, 27, .62);
  text-align: center;
  animation: come-into-view 240ms ease-out both;
}
.mini-cover[hidden] { display: none; }
.mini-cover.is-arming { pointer-events: none; }
.mini-cover .marker-btn { max-width: 100%; }
.mini-cover-line { font-family: var(--marker); font-size: 24px; line-height: 1.15; color: #fff; }
.mini-cover-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.mini-keep { min-height: 58px; padding-inline: 18px; border-radius: 12px; font-size: 17px; }
.mini-keep .icon { width: 20px; height: 20px; }
/* A round's height, big on tape; with a star when it beat the best. */
.mini-result {
  display: inline-flex; align-items: center; gap: 6px; min-width: 76px; padding: 4px 18px 3px;
  font-family: var(--marker); font-size: 46px; line-height: 1.05; color: var(--ink);
  font-variant-numeric: tabular-nums; transform: rotate(-3deg);
}
.mini-result .icon { width: 30px; height: 30px; }
.mini-result.is-best { animation: mini-best 520ms cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes mini-best { from { transform: rotate(-3deg) scale(.4); } }
.mini-stage {
  position: relative; display: block; width: 100%; height: 300px; padding: 0;
  border: 6px solid transparent; border-radius: 16px;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255, 255, 255, .07), transparent 60%) padding-box,
    var(--felt-grain) padding-box,
    linear-gradient(var(--felt), var(--felt)) padding-box,
    var(--rim-photo) border-box,
    var(--rim) border-box;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .16), inset 0 10px 18px rgba(0, 0, 0, .18);
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mini-world { position: absolute; inset: 0; overflow: hidden; border-radius: 10px; }
.mini-plank {
  position: absolute; left: 12px; right: 12px; bottom: 0; height: 16px; border-radius: 3px 3px 0 0;
  background: linear-gradient(to bottom, transparent 9px, var(--tint-lip) 9px), var(--wood-photo), var(--shelf);
}
.mini-box { position: absolute; left: 0; top: 0; will-change: transform; }
.mini-face {
  display: grid; place-items: center; width: 100%; height: 100%; padding: 0 6px;
  border-radius: 3px; background: var(--box); color: var(--box-ink);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .14), inset 0 5px 0 rgba(255, 255, 255, .08), inset 0 -4px 0 rgba(0, 0, 0, .18), 0 2px 4px rgba(0, 0, 0, .25);
  transform-origin: 50% 100%; overflow: hidden;
}
.mini-box.has-band .mini-face { background: linear-gradient(to top, var(--box-2) 5px, var(--box) 5px); }
.mini-box.is-fused .mini-face { background: linear-gradient(100deg, var(--box) 50%, var(--box2) 50%); }
.mini-title {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--box-font); font-stretch: 72%; font-weight: 900; font-size: var(--title); line-height: 1.05;
  text-transform: uppercase;
}
.mini-box.is-fused .mini-title { padding: 2px 5px; border-radius: 2px; background: #fff; color: var(--ink); }
/* The height and the chances in one row across the top, the best at the
   right; the game keeps the swinging box below them (HEAD in stack.js). */
.mini-head { position: absolute; top: 10px; left: 10px; z-index: 1; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.mini-score {
  min-width: 46px; padding: 3px 12px 2px;
  font-family: var(--marker); font-size: 28px; line-height: 1.1; text-align: center; color: var(--ink);
  font-variant-numeric: tabular-nums; transform: rotate(-3deg); pointer-events: none;
}
.mini-best {
  position: absolute; top: 12px; right: 10px; z-index: 1; display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 11px 2px; font-family: var(--marker); font-size: 18px; line-height: 1.1; color: var(--ink);
  transform: rotate(2deg); pointer-events: none;
}
.mini-best[hidden] { display: none; }
.mini-best .icon { width: 16px; height: 16px; }
/* The round's chances, little boxes under the height; a lost one is an
   empty dashed place. */
.mini-chances { display: flex; gap: 5px; }
.mini-pip {
  width: 15px; height: 11px; border-radius: 2px;
  background: var(--tape); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .16);
  transition: background-color .2s ease, box-shadow .2s ease;
}
.mini-pip.is-lost { background: transparent; box-shadow: inset 0 0 0 2px rgba(235, 217, 168, .5); }
/* A perfect drop: specks thrown off it and a star rising from it. */
.mini-speck {
  position: absolute; z-index: 1; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: var(--tape); pointer-events: none;
}
.mini-speck.is-white { background: #fff; }
.mini-float {
  position: absolute; z-index: 1; display: inline-flex; align-items: center; gap: 2px;
  font-family: var(--marker); font-size: 22px; line-height: 1; color: var(--tape); white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .25); transform: translateX(-50%); pointer-events: none;
}
.mini-float .icon { width: 22px; height: 22px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .25)); }
.mini-float .star.on { color: var(--tape); }
/* Before the first drop: a ring where a finger goes. */
.mini-hint {
  position: absolute; left: 50%; top: 52%; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border: 3px solid rgba(235, 217, 168, .85); border-radius: 50%; pointer-events: none;
  animation: mini-tap 1.4s cubic-bezier(.16, 1, .3, 1) infinite;
}
@keyframes mini-tap { 0% { transform: scale(.5); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .mini-hint, .mini-cover, .mini-result.is-best { animation: none; opacity: 1; } }

/* ---------- Add a box ---------- */

.form-sheet h1 { font-size: clamp(31px, 7.5vw, 44px); line-height: 1.04; font-weight: 800; letter-spacing: -.02em; }
.form-lede { margin-top: 8px; max-width: 42ch; font-size: 18px; }
.draft-link { margin-top: 14px; padding: 10px 14px; border-radius: 6px; background: var(--tape); }
.draft-link a { font-weight: 700; text-underline-offset: 3px; }

.remix-form { display: grid; gap: 24px; margin-top: 24px; }

/* Which game is it? Kidsize's guess to say yes to, then a name to type
   instead, before a remix is spent. */
.which-photo { margin-top: 20px; }
.which-picks { display: grid; justify-items: start; gap: 10px; margin-top: 24px; }
.form-sheet > .marker-btn { margin-top: 24px; }
.which-other { display: grid; justify-items: start; gap: 16px; margin-top: 28px; }
.which-other .field { width: 100%; }

.photo-pick {
  display: grid; justify-items: center; gap: 4px;
  padding: 26px 16px; border: 2px dashed var(--rule-strong); border-radius: 12px;
  background: var(--paper-warm); text-align: center; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
.photo-pick .icon { width: 42px; height: 42px; margin-bottom: 4px; color: var(--red-ink); }
.photo-pick:hover, .photo-pick.over { border-color: var(--ink); background: var(--tape); }
#photo:focus-visible + .photo-pick { outline: 3px solid var(--focus); outline-offset: 3px; }
.photo-big { font-size: 19px; font-weight: 800; }
.photo-small { font-size: 15px; color: var(--paper-soft); }
/* Locked while a name is typed: no longer a place to put something, so the
   dashed outline goes quiet and the line under it says how to switch. */
.photo-pick.is-off { border-color: var(--rule); background: transparent; cursor: not-allowed; }
.photo-pick.is-off .icon, .photo-pick.is-off .photo-big { color: var(--paper-soft); }
.photo-pick.is-off .photo-small { color: var(--paper-ink); }
.photo-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.photo-preview[hidden], .photo-pick[hidden] { display: none; }
.photo-preview img { width: 104px; height: 104px; object-fit: cover; border-radius: 8px; box-shadow: 0 3px 8px rgba(0, 0, 0, .2); }

.field label { display: block; margin-bottom: 8px; font-size: 17px; font-weight: 800; }
.field input {
  width: 100%; min-height: 54px; padding: 0 14px;
  border: 2px solid var(--rule-strong); border-radius: 10px;
  background: var(--paper-warm); font-size: 18px;
}
.field input:focus-visible { outline-offset: 1px; }
.field-box { position: relative; }
.field-box input:not(:disabled) { padding-right: 56px; }
/* Locked while a photo names the box. */
.field input:disabled { border-style: dashed; border-color: var(--rule); background: transparent; color: var(--paper-soft); cursor: not-allowed; }
.field input:disabled::placeholder { color: transparent; }
.field:has(input:disabled) > label { color: var(--paper-soft); }
.field-clear {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  display: grid; place-items: center; width: 46px; height: 46px;
  border: 0; border-radius: 8px; background: transparent; color: var(--paper-soft); cursor: pointer;
}
.field-clear[hidden] { display: none; }
.field-clear:hover { background: rgba(0, 0, 0, .06); color: var(--paper-ink); }
.field-clear .icon { width: 20px; height: 20px; }

/* What the current choice means, under every field and row of chips. The
   rows have no visible labels: the line names the choice and explains it.
   The name hint keeps two lines so the photo switch never moves the input;
   chip hints keep the gaps between rows even instead. */
.field-hint, .chip-hint {
  margin-top: 8px; max-width: 52ch;
  font-size: 15px; line-height: 1.4; color: var(--paper-soft);
}
.field-hint { min-height: 2.8em; }
.chip-hint { margin-top: 10px; }
.chip-hint strong { font-weight: 800; color: var(--paper-ink); }

.chips { border: 0; min-width: 0; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip label {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 50px; min-height: 50px; padding: 0 16px; border-radius: 999px;
  border: 2px solid var(--rule-strong); background: var(--paper);
  font-weight: 700; cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.chip label:hover { border-color: var(--ink); }
.chip input:checked + label { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }

.privacy { max-width: 54ch; font-size: 14px; color: var(--paper-soft); }

/* ---------- Fuse two boxes ---------- */

/* A fused box: split corner to corner in its two boxes' colours. No ink reads
   on every pair of colours, so its words sit on a paper label. */
.box.is-fused, .tray.is-fused, .lid.is-fused, .fuse-lid.is-fused {
  background: linear-gradient(135deg, var(--box) 50%, var(--box2) 50%);
}
.box.is-fused .box-title, .fuse-lid.is-fused .fuse-lid-title {
  padding: 3px 5px 2px; border-radius: 2px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.fuse-label {
  padding: 0 .14em; border-radius: 2px;
  background: var(--paper); color: var(--ink);
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.tray-count .fuse-label { padding: 1px .45em; }

.fuse { max-width: 680px; }
.fuse-title { font-size: clamp(30px, 7.5vw, 42px); line-height: 1.04; font-weight: 800; letter-spacing: -.02em; }
.fuse-title:focus { outline: none; }
.fuse-lede { margin-top: 8px; max-width: 42ch; color: var(--felt-soft); }
.fuse-wait { margin-top: 18px; color: var(--felt-soft); }

/* The boxes to pick from stand on a short plank of the cupboard laid across
   the top of the table: a wood frame round one shelf, its dark lip under
   the boxes. It scrolls sideways when they don't all fit. */
.fuse-strip {
  --scale: .72;
  list-style: none;
  display: flex; align-items: flex-end; gap: 6px;
  margin-top: 18px; padding: 16px 10px 0;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity; scroll-padding-inline: 10px;
  border: 8px solid transparent; border-radius: 8px;
  background:
    linear-gradient(to bottom, var(--tint-shade) 0, transparent 20px, transparent calc(100% - 12px), var(--tint-lip) calc(100% - 12px)) padding-box,
    var(--wood-photo) padding-box,
    linear-gradient(var(--shelf), var(--shelf)) padding-box,
    var(--frame-photo) border-box,
    var(--wood) border-box;
  scrollbar-width: thin; scrollbar-color: var(--lip) transparent;
}
.fuse-strip li { flex: none; padding-bottom: 12px; scroll-snap-align: start; }

.fuse-choices { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; margin-top: 14px; color: var(--felt-soft); }
.fuse-choices strong { color: #fff; font-weight: 700; }
.fuse-form { display: grid; gap: 22px; margin-top: 8px; max-width: 560px; }
.fuse-form[hidden] { display: none; }
.fuse-form > .tool { justify-self: start; }

/* Two dashed places in the middle of the felt, a plus between them. */
.fuse-board {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px;
  width: min(420px, 100%); margin: 34px auto 0;
}
.fuse-slot {
  position: relative; aspect-ratio: 4 / 5;
  display: grid; place-items: center; padding: 8px;
  border: 3px dashed rgba(235, 217, 168, .6); border-radius: 10px;
  transition: background-color .15s ease, opacity .3s ease;
}
.fuse-slot.is-full { padding: 5px; }
.fuse-slot.drop-ready { background-color: var(--felt-lit); }
.fuse-slot-hint { font-family: var(--marker); font-size: 18px; line-height: 1.15; color: var(--tape); text-align: center; }
.fuse-plus { display: grid; place-items: center; color: var(--tape); transition: opacity .3s ease; }
.fuse-plus .icon { width: 30px; height: 30px; }

/* A box in its place: shut, seen from above. Tapping it takes it out. */
.fuse-take {
  position: relative; display: block; width: 100%; height: 100%;
  padding: 0; border: 0; border-radius: 6px; background: none;
}
.fuse-take:focus-visible { outline-color: var(--tape); }
.fuse-lid {
  display: flex; align-items: flex-start;
  width: 100%; height: 100%; padding: 12px 11px;
  border-radius: 6px;
  background: var(--box); color: var(--box-ink); text-align: left;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .2), inset 0 14px 0 rgba(255, 255, 255, .08), 0 10px 20px rgba(0, 0, 0, .3);
}
.fuse-lid-title {
  font-family: var(--box-font); font-stretch: 70%; font-weight: 900;
  font-size: clamp(19px, 5.4vw, 26px); line-height: .92; letter-spacing: .005em; text-transform: uppercase;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.fuse-x {
  position: absolute; top: -10px; right: -10px;
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
}
.fuse-x .icon { width: 16px; height: 16px; }
.fuse-take:hover .fuse-x { background: var(--tape); }

/* Fusing: the plank and the choices rest, the places empty out, and the two
   lids circle each other over them (js/fuse.js moves them). */
.fuse-strip, .fuse-choices { transition: opacity .3s ease; }
.fuse.is-fusing :is(.fuse-strip, .fuse-choices) { opacity: .4; pointer-events: none; }
.fuse.is-fusing .fuse-slot { border-color: transparent; }
.fuse.is-fusing .fuse-slot > *, .fuse.is-fusing .fuse-plus { visibility: hidden; opacity: 0; }

.fuse-stage { position: absolute; inset: 0; pointer-events: none; }
.orbit-lid, .orbit-trail { position: absolute; left: 50%; top: 50%; will-change: transform; }
/* Faint copies a box leaves behind once it moves fast: no shadow, so they
   read as motion, not as more boxes. */
.orbit-trail { box-shadow: none; opacity: 0; pointer-events: none; }
.orbit-lid.is-arrived { box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .2), inset 0 14px 0 rgba(255, 255, 255, .08), 0 16px 30px rgba(0, 0, 0, .34); }
/* The orbit's path, faint tape-coloured dashes. The front lid passes over
   it and the back one under it. */
.orbit-ring {
  position: absolute; left: 50%; top: 50%; z-index: 3;
  border: 2px dashed rgba(235, 217, 168, .45); border-radius: 50%;
  transform: translate(-50%, -50%); opacity: 0;
}
.speck {
  position: absolute; left: 50%; top: 50%; z-index: 2;
  width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: var(--tape); opacity: 0;
}
.speck:nth-of-type(3n) { background: #fff; }
/* The moment the two hit: a paper-white flash under the new box. */
.fuse-flash {
  position: absolute; left: 50%; top: 50%; z-index: 6;
  width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .9) 0, rgba(255, 253, 246, .5) 34%, rgba(255, 253, 246, 0) 68%);
  opacity: 0;
}
.fuse-burst {
  position: absolute; left: 50%; top: 50%; z-index: 6;
  width: 170px; height: 170px; border: 5px solid var(--mustard); border-radius: 50%;
  opacity: 0;
}

/* Under the places: the writing lines and Stop, or what went wrong. The
   circling boxes are the busy sign, so no pen line here. */
.fuse-status { display: grid; justify-items: center; gap: 12px; min-height: 58px; margin-top: 30px; text-align: center; }
.fuse-status .writing { justify-items: center; margin-top: 0; }
.fuse-status .pen { display: none; }
.fuse-status .writing-sub { color: var(--felt-soft); }
.fuse-msg { max-width: 40ch; font-weight: 700; }

/* ---------- Remixes ----------
   What writing rules costs, under the button that does it, and the card
   that stands in for the button once the family has none left. */

.remix-note { font-size: 14px; color: var(--paper-soft); }
.remix-form .remix-note { margin-top: -16px; }
.tweak .remix-note { margin: -4px 0 12px; }
.fuse-status .remix-note { color: var(--felt-soft); }
.lock-card {
  display: grid; gap: 8px; justify-items: start;
  max-width: 54ch; padding: 16px 18px 18px;
  border: 2px dashed var(--rule-strong); border-radius: 12px;
  background: var(--paper-warm); color: var(--paper-ink); text-align: left;
}
.lock-card .marker-btn { margin-top: 6px; }
.lock-title { font-family: var(--marker); font-size: 22px; line-height: 1.1; }
.remix-count { margin-bottom: 4px; font-size: 20px; font-weight: 800; }
.rules-part > .remix-count + .family-hint { margin: 0 0 14px; }
.menu-credits {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px;
  padding: 2px 2px 4px; font-weight: 700;
}
.menu-credits[hidden] { display: none; }
.get-more {
  padding: 0; border: 0; background: none;
  color: var(--red-ink); font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 3px;
}

/* Get more remixes: how many, a note, send. Paper, like every dialog. */
.more-form .chips { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.more-label { display: block; margin-bottom: 8px; font-weight: 800; }
.more-form textarea {
  width: 100%; min-height: 88px; padding: 10px 12px;
  border: 2px solid var(--rule-strong); border-radius: 10px; background: var(--paper-warm);
  font: inherit; font-size: 17px; resize: vertical;
}
.more-form .marker-btn { width: 100%; }
.more-pending { font-size: 17px; }
/* Looking up the last request: the form waits, faded and still. */
.more-form > :not(.dlg-head) { transition: opacity .2s ease; }
.more-form[aria-busy="true"] > :not(.dlg-head) { opacity: .45; }
/* A request already waiting fills the form's height, OK at the bottom. */
.more-count { font-weight: 800; }

/* Kidsize on an iPhone's home screen: the steps, each led by its icon, and
   the family code in case the new app asks for it. */
.install-steps { display: grid; gap: 14px; margin: 4px 0 6px; padding: 0; list-style: none; counter-reset: step; }
.install-steps li { display: grid; grid-template-columns: 36px 1fr; align-items: start; gap: 12px; font-size: 17px; }
.install-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--tape); color: var(--ink);
}
.install-icon svg { width: 20px; height: 20px; }
.install-steps li > span:last-child { padding-top: 6px; }
.install-code { display: grid; justify-items: start; gap: 10px; margin-top: 4px; }
.install-code .code-tape { font-size: 26px; padding: 6px 18px 5px; }

/* A new deploy is live: under the bar, out of the toast's way. */
.update-bar {
  position: fixed; left: 50%; top: calc(var(--bar-h) + 10px); z-index: 85;
  display: flex; align-items: center; gap: 12px;
  width: max-content; max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 700;
  transform: translateX(-50%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.update-bar .tool { min-height: 40px; flex: none; }
body.playing .update-bar { display: none; }
.dlg.more-waiting { display: flex; flex-direction: column; gap: 14px; }
.dlg.more-waiting .dlg-actions { margin-top: auto; }

/* ---------- Play mode ---------- */

body.playing { overflow: hidden; }

.play {
  --focus: var(--tape);
  position: fixed; inset: 0; z-index: 80;
  display: grid; grid-template-rows: auto auto 1fr auto auto; gap: 14px;
  padding: max(10px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background-color: var(--felt);
  background-image: radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, .07), transparent 60%), var(--felt-grain);
  color: #fff;
  overflow: auto;
}
.play-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.play-name { font-family: var(--marker); font-size: 21px; line-height: 1.15; color: var(--tape); }
/* One step on a sheet of paper, with the part of the game it belongs to
   taped across its top edge, the step's number written big in marker, and
   a dot for each step of that part underneath. */
.play-card {
  position: relative;
  align-self: center; justify-self: center;
  display: grid; align-content: center; gap: 24px;
  width: 100%; max-width: 780px; min-height: 38vh; margin-top: 18px;
  padding: 50px 24px 26px; border-radius: 4px;
  background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 16px 34px rgba(0, 0, 0, .35);
}
.play-tape {
  position: absolute; transform-origin: 20% 50%; top: -17px; left: 14px; max-width: calc(100% - 28px);
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 18px 10px;
  color: var(--ink);
  font-family: var(--marker); font-size: clamp(20px, 5vw, 26px); line-height: 1.1;
  transform: rotate(-2deg);
}
/* A new part: its tape is stuck on the card again, pressed down from a
   little above. */
.play-tape.is-fresh { animation: tape-stick .38s cubic-bezier(.2, .8, .25, 1) both; }
@keyframes tape-stick {
  from { opacity: 0; transform: translate(-8px, -12px) rotate(-7deg) scale(1.08); }
  to { opacity: 1; transform: rotate(-2deg); }
}
.play-step { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: start; }
/* The number is printed, like the title on a box: Permanent Marker's 1 is
   a bare stroke that reads as a stray mark at this size. */
.play-num {
  min-width: .55em;
  font-family: var(--box-font); font-weight: 900; font-stretch: 75%;
  font-size: clamp(60px, 15vw, 96px); line-height: .8; font-variant-numeric: lining-nums;
  color: var(--ink); text-align: center;
}
/* The parts of the game, taped in a row above the card: done ones ticked
   and pressed flat, the current one lifted off the felt, the next ones
   still waiting, faded. A dot per step; the step on the card is the big
   one. */
.play-crumbs {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 12px;
  justify-self: center; width: 100%; max-width: 780px;
}
.play-crumb {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 6px 14px 8px; border: 0;
  color: var(--ink);
  font-family: var(--marker); font-size: clamp(15px, 4vw, 19px); line-height: 1.1;
  transform: rotate(-1.5deg);
  transition: transform .28s cubic-bezier(.2, .8, .25, 1);
}
.play-crumb:nth-child(2) { transform: rotate(1deg); }
.play-crumb:nth-child(3) { transform: rotate(-.6deg); }
.play-crumb:nth-child(2).is-now { transform: rotate(1deg) translateY(-3px) scale(1.08); }
.play-crumb:nth-child(3).is-now { transform: rotate(-.6deg) translateY(-3px) scale(1.08); }
.play-crumb.is-now { transform: rotate(-1.5deg) translateY(-3px) scale(1.08); }
.crumb-name { opacity: .55; transition: opacity .25s ease; }
.play-crumb.is-done .crumb-name, .play-crumb.is-now .crumb-name, .play-crumb:hover .crumb-name { opacity: 1; }

/* The hand-drawn marks (sheet.js MARKS): the tick and the going-round arrow
   share one place, so a part's arrow turns into its tick once it's done. */
.crumb-mark { display: inline-grid; }
.crumb-mark > span, .play-tape > [class^="mark-"] { grid-area: 1 / 1; display: grid; width: 1.05em; height: 1.05em; }
.crumb-mark svg, .play-tape svg { width: 100%; height: 100%; overflow: visible; }
/* Smaller tapes, heavier pen: the marks keep the weight of the letters beside them. */
.crumb-mark svg { stroke-width: 3.8; }
.crumb-mark > .crumb-tick { display: none; color: var(--felt); }
.play-crumb.is-done .crumb-mark > .crumb-tick { display: grid; }
.play-crumb.is-done .crumb-mark > .crumb-round { display: none; }
.play-crumb:not(.is-done):not(:has(.crumb-round)) .crumb-mark { display: none; }
.play-crumb.is-done .crumb-tick path { stroke-dasharray: 1; animation: draw-tick .42s cubic-bezier(.3, .7, .3, 1) .08s both; }
@keyframes draw-tick { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

/* A dot per step: an open ring still to come, filled in green once done,
   the step on the card in ink and a size up. */
.crumb-dots { display: inline-flex; align-items: center; gap: 3px; margin-left: 3px; }
.crumb-dot { display: block; width: 10px; height: 10px; color: var(--ink-soft); transition: color .2s ease, transform .25s cubic-bezier(.3, .7, .3, 1); }
.crumb-dot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.crumb-dot path { fill: transparent; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; transition: fill .2s ease; }
.crumb-dot.is-done { color: var(--felt); }
.crumb-dot.is-done path { fill: currentColor; }
.crumb-dot.is-done:not(.is-now) { animation: dot-fill .3s cubic-bezier(.3, .7, .3, 1) both; }
.crumb-dot.is-now { color: var(--ink); transform: scale(1.35); }
.crumb-dot.is-now path { fill: currentColor; }
@keyframes dot-fill { 0% { transform: scale(.6); } 60% { transform: scale(1.2); } 100% { transform: scale(1); } }
@media (min-width: 600px) {
  .play-card { padding: 58px 44px 34px; }
  .play-tape { left: 32px; }
}
.play-card.turn-in { animation: turn-in .28s ease-out; }
@keyframes turn-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.play-text { font-size: clamp(26px, 6.6vw, 44px); line-height: 1.25; font-weight: 700; text-wrap: pretty; }
.play-text.small { margin-bottom: 14px; font-size: clamp(22px, 5vw, 32px); }
.play-text.play-story { font-size: clamp(22px, 5.2vw, 34px); font-weight: 400; line-height: 1.4; }
.play-list { display: grid; gap: 8px; padding-left: 1.1em; font-size: clamp(19px, 4.6vw, 27px); }
.play-tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.play-tools [hidden] { display: none; }
.play-nav {
  display: grid; grid-template-columns: auto 1fr; gap: 12px;
  justify-self: center; width: 100%; max-width: 780px;
}
.play-back {
  grid-column: 1;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 66px; padding: 0 18px; border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, .55); background: transparent; color: #fff;
  font-size: 17px; font-weight: 700;
}
.play-back:hover { border-color: #fff; background: rgba(255, 255, 255, .08); }
.play-back[hidden] { display: none; }
.play-next { grid-column: 2; min-height: 66px; font-size: 25px; }

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

dialog {
  width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  margin: auto; padding: 0; border: 0; border-radius: 14px;
  background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  --focus: var(--ink);
}
dialog::backdrop { background: rgba(38, 24, 4, .55); }
.dlg { display: grid; gap: 14px; padding: 20px 20px 22px; }
.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dlg-head .icon-btn { margin: -8px -8px 0 0; }
.dlg h2 { font-size: 22px; line-height: 1.2; font-weight: 800; }
.dlg-note { font-size: 14px; color: var(--paper-soft); }

/* Srpski / English: two words in their own language, in the menu and on the
   welcome. The pressed one is the page's language. */
.lang-switch { display: flex; gap: 6px; justify-self: start; }
.lang-switch button {
  min-height: 40px; padding: 0 14px; border: 2px solid var(--rule-strong); border-radius: 999px;
  background: transparent; color: inherit; font-weight: 700;
}
.lang-switch button[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.gate-lang { justify-self: center; margin-top: 6px; }
.gate-lang button { border-color: var(--ink-soft); }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }

.menu-item {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px; border: 2px solid var(--rule); border-radius: 10px;
  background: var(--paper); text-align: left;
}
.menu-item:hover { border-color: var(--ink); }
.menu-item > .icon { width: 26px; height: 26px; margin-top: 1px; }
.menu-item strong { display: block; font-size: 17px; }
.menu-item strong + span { display: block; font-size: 15px; color: var(--paper-soft); }

.qr { justify-self: center; display: grid; place-items: center; width: 220px; height: 220px; background: #fff; }
.qr svg { width: 100%; height: 100%; }
.qr-wait { color: var(--paper-soft); text-align: center; font-size: 15px; padding: 0 16px; }

/* ---------- About me and Support the dev (js/maker.js) ---------- */

/* The two pills under the cupboard's footnote: quiet outlines in the
   footnote's own brown, an offer and not a call to action. */
.foot-maker { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.maker-pill {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 0 16px 0 12px;
  border: 2px solid rgba(59, 46, 14, .32); border-radius: 999px;
  background: transparent; color: var(--ink-soft);
  font: inherit; font-size: 15px; font-weight: 700; line-height: 1;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.maker-pill .icon { width: 19px; height: 19px; }
.maker-pill:hover { border-color: var(--ink-soft); color: var(--ink); background: rgba(255, 255, 255, .2); }
.maker-pill:active { background: rgba(0, 0, 0, .06); }

/* Both dialogs come and go the same way. */
.about[open], .support-sheet[open] { animation: maker-in 350ms cubic-bezier(.16, 1, .3, 1) both; }
.about::backdrop, .support-sheet::backdrop {
  background: rgba(5, 7, 10, .72);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: maker-fade 350ms cubic-bezier(.16, 1, .3, 1) both;
}
.about.is-leaving, .support-sheet.is-leaving { animation: maker-out 200ms cubic-bezier(.16, 1, .3, 1) both; }
.about.is-leaving::backdrop, .support-sheet.is-leaving::backdrop { animation: maker-fade 200ms cubic-bezier(.16, 1, .3, 1) reverse both; }
@keyframes maker-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes maker-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes maker-fade { from { opacity: 0; } }

/* About me: the maker's own card, styled after stancevicbranko.com and not
   after Kidsize: its near-black, its gold, its Geist, the round photo in a
   gold ring and the lifting link tiles. The tokens are scoped to the dialog.
   Geist Sans is by Vercel, under the SIL Open Font License 1.1. */
@font-face {
  font-family: "Geist"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/assets/about/geist-sans.woff2") format("woff2");
}
.about {
  --a-card: #141414;
  --a-accent: #f0b429;
  --a-accent-dim: rgba(240, 180, 41, .15);
  --a-text: #e5e5e5;
  --a-muted: #8f8f8f;
  --a-border: rgba(255, 255, 255, .08);
  --a-ease: cubic-bezier(.16, 1, .3, 1);
  --focus: var(--a-accent);
  width: min(380px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  overflow: visible; border-radius: 0;
  background: none; box-shadow: none; color: var(--a-text);
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5;
}
.about__card {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 34px 24px 24px;
  border: 1px solid var(--a-border); border-radius: 20px;
  background: var(--a-card); box-shadow: 0 30px 90px rgba(0, 0, 0, .6);
  text-align: center;
}
.about__close {
  position: absolute; top: 12px; right: 12px;
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid transparent; border-radius: 10px;
  background: none; color: var(--a-muted); cursor: pointer;
  transition: color 150ms var(--a-ease), border-color 150ms var(--a-ease);
}
.about__close .icon { width: 18px; height: 18px; }
/* The site's status line: small capitals in gold between two short rules. */
.about__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500; letter-spacing: .12em; text-transform: uppercase;
  color: var(--a-accent);
}
.about__eyebrow::before, .about__eyebrow::after { content: ""; width: 32px; height: 1px; background: var(--a-accent); opacity: .5; }
.about__photo {
  width: 120px; height: 120px; margin: 22px 0 20px;
  border-radius: 50%; object-fit: cover;
  border: 2px solid var(--a-border); box-shadow: 0 0 0 4px var(--a-accent-dim);
  background: #0d0d0d;
}
.about__name { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -.04em; line-height: 1.25; }
.about__initial { color: var(--a-accent); }
.about__title { margin: 8px 0 0; font-size: 15px; line-height: 1.4; letter-spacing: -.01em; color: var(--a-muted); text-wrap: balance; }
.about__where { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--a-muted); }
.about__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--a-accent); animation: about-pulse 2.5s ease-in-out infinite; }
@keyframes about-pulse { 50% { opacity: .45; transform: scale(.8); } }
/* Room above the tiles for one to lift into. */
.about__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 30px; }
.about__link-wrap { position: relative; width: 52px; height: 52px; }
.about__link {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--a-border); border-radius: 12px;
  color: var(--a-muted);
  transition: transform 600ms var(--a-ease), border-color 250ms var(--a-ease), color 250ms var(--a-ease);
}
.about__mark, .about__mark svg { display: block; width: 22px; height: 22px; }
.about__link-label {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  font-size: 9px; line-height: 1; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
  color: var(--a-muted); opacity: 0; pointer-events: none;
  transition: opacity 400ms var(--a-ease);
}
.about__site {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 26px; padding: 6px 4px;
  font-size: 13px; color: var(--a-muted); text-decoration: none;
  transition: color 150ms var(--a-ease);
}
.about__out, .about__out svg { display: block; width: 15px; height: 15px; }
.about a:focus-visible, .about__close:focus-visible { outline: 2px solid var(--a-accent); outline-offset: 2px; }
.about__link:focus-visible { border-color: var(--a-accent); color: var(--a-accent); }
@media (hover: hover) and (pointer: fine) {
  .about__link-wrap:hover .about__link { transform: translateY(-15px); border-color: var(--a-accent); color: var(--a-accent); }
  .about__link-wrap:hover .about__link-label { opacity: 1; transition-delay: 100ms; }
  .about__site:hover, .about__close:hover { color: var(--a-accent); }
  .about__close:hover { border-color: var(--a-border); }
}
.about__link:active { border-color: var(--a-accent); color: var(--a-accent); }
/* The smallest phones: the name and the five tiles each keep to one line. */
@media (max-width: 359px) {
  .about__card { padding-inline: 16px; }
  .about__name { font-size: 26px; }
  .about__links { gap: 6px; }
  .about__link-wrap { width: 44px; height: 44px; }
  .about__mark, .about__mark svg { width: 20px; height: 20px; }
}

/* Support the dev: Ko-fi's donation panel on a sheet of Kidsize paper. The
   panel is Ko-fi's own page and nothing here can restyle it; until it has
   loaded, a quiet "Loading Ko-fi…" holds its place, then it fades in. */
.support-sheet {
  width: min(400px, calc(100vw - 32px)); height: min(760px, calc(100dvh - 32px));
  overflow: visible; border-radius: 0; background: none; box-shadow: none;
}
.support-sheet__card {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  border-radius: 14px; background: var(--paper); color: var(--paper-ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.support-sheet__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 58px; padding: 0 8px 0 20px;
  border-bottom: 2px solid var(--rule);
}
.support-sheet__title { font-size: 20px; line-height: 1.2; font-weight: 800; }
.support-sheet__body { position: relative; flex: 1; min-height: 0; background: #FAF8F3; }
.support-sheet__wait { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; color: var(--paper-soft); }
.support-sheet__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity .3s ease; }
.support-sheet__body.is-ready .support-sheet__frame { opacity: 1; }
/* The page's address: the way out to a tab, for anyone who'd rather. */
.support-sheet__out {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; border-top: 2px solid var(--rule);
  font-size: 14px; color: var(--paper-soft); text-decoration: none;
}
.support-sheet__out:hover { color: var(--paper-ink); }
.support-sheet__out:focus-visible { outline-offset: -4px; }
.support-sheet__arrow, .support-sheet__arrow svg { display: block; width: 14px; height: 14px; }
.warn { padding: 12px 14px; border-radius: 8px; background: var(--tape); font-size: 15px; }

/* The family code, written on a strip of tape. */
.family-code { justify-self: center; margin: 2px 0 -2px; }
.code-tape {
  display: inline-block; padding: 8px 22px 7px;
  /* Read off a screen and typed in, so the plainest letters, not the marker. */
  font-family: var(--box-font); font-weight: 900; font-stretch: 110%;
  font-size: 34px; line-height: 1.1; letter-spacing: .08em;
  color: var(--ink); transform: rotate(-1.5deg);
  user-select: all;
}
.family-tools { justify-content: center; }

/* Leaving: the code to come back with, on its tape, and a red marker note
   underneath, its arrow curling up to the tape. */
#askBody { display: grid; gap: 14px; }
/* What the rules being taken out cost: a tape panel, so it is read. */
.ask-cost { padding: 12px 14px; border-radius: 6px; background: var(--tape); font-weight: 700; }
#askBody[hidden] { display: none; }
.leave-code { display: grid; justify-items: center; gap: 4px; padding: 6px 0 2px; }
.leave-keep {
  display: flex; align-items: flex-end; gap: 4px; margin-left: 56px;
  font-family: var(--marker); font-size: 19px; line-height: 1.1; color: var(--red-ink);
  transform: rotate(-3deg);
}
.leave-keep .icon { width: 34px; height: 24px; flex: none; margin-bottom: 6px; }
.leave-keep .icon svg { display: block; width: 100%; height: 100%; }
.rename { padding-top: 18px; border-top: 2px solid var(--rule); }
.rename .field label { font-size: 16px; }
.rename-row { display: flex; gap: 8px; }
.rename-row input { flex: 1; min-width: 0; }
.rename-row .tool { flex: none; min-height: 52px; }

/* ---------- The family page: its devices, its code, its name ---------- */

/* The strip across the top of the sheet: the two family pages and Leave.
   The page you are on keeps its ink squiggle drawn under it. */
.sheet-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 4px;
  margin: -12px -8px 22px; padding-bottom: 8px;
  border-bottom: 2px solid var(--rule);
}
.sheet-tab {
  --wiggle: var(--ink);
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 8px;
  border: 0; background: none; color: var(--paper-soft);
  font: inherit; font-size: 16px; font-weight: 700; text-decoration: none;
  white-space: nowrap; cursor: pointer;
}
.sheet-tab .icon { flex: none; width: 20px; height: 20px; }
.sheet-tab:hover { color: var(--ink); }
.sheet-tab[aria-current="page"] { color: var(--paper-ink); cursor: default; }
.sheet-tab[aria-current="page"] .squiggle { clip-path: inset(-4px); }
.sheet-tab.wiggle-remove { --wiggle: var(--red); margin-left: auto; }

.family-sheet h1 { font-size: clamp(28px, 6vw, 38px); line-height: 1.1; font-weight: 800; overflow-wrap: anywhere; }
.family-lede { margin-top: 10px; max-width: 54ch; color: var(--paper-soft); }
.family-hint { max-width: 54ch; font-size: 15px; color: var(--paper-soft); }
.rules-part > .family-hint { margin-top: 12px; }

/* One line per device, ruled like a list on the inside of a lid. */
.devices { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--rule); }
.device, .devices-note { padding: 14px 0; border-bottom: 2px solid var(--rule); }
.device { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px 14px; }
.devices-note { color: var(--paper-soft); }
.devices-note .tool { margin-left: 4px; }
.device-kind { align-self: start; width: 26px; height: 26px; margin-top: 1px; color: var(--paper-soft); }
.device.is-you .device-kind { color: var(--paper-ink); }
.device-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.device-name { font-size: 18px; line-height: 1.3; font-weight: 800; overflow-wrap: anywhere; }
.you-tape {
  padding: 3px 11px 4px;
  color: var(--ink); font-family: var(--marker); font-size: 14px; line-height: 1.1;
  transform: rotate(-2deg);
}
.device-meta { margin-top: 2px; font-size: 15px; color: var(--paper-soft); }
.device-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px; }
.device-rename { display: grid; gap: 8px; }
.device-rename input {
  width: 100%; min-height: 48px; padding: 0 12px;
  border: 2px solid var(--rule-strong); border-radius: 10px;
  background: var(--paper-warm); font-size: 17px;
}
.device-rename .rename-row .tool { min-height: 48px; }

.bring { display: grid; gap: 14px; justify-items: start; margin-top: 14px; }
.bring > p:not([class]) { max-width: 54ch; }
.bring .family-code, .bring .qr { justify-self: start; }
.bring .family-code { margin: 4px 0 0 6px; }
.bring .family-tools { justify-content: flex-start; }
.bring .warn { max-width: 54ch; }
.code-change { display: flex; flex-wrap: wrap; align-items: center; gap: 0 10px; margin-left: -8px; }
.family-name { display: grid; gap: 10px; max-width: 480px; }

@media (max-width: 559px) {
  .device { grid-template-columns: auto minmax(0, 1fr); }
  .device-tools { grid-column: 2; justify-content: flex-start; margin: -4px 0 -6px -8px; }
  .sheet-tab { gap: 6px; padding: 0 6px; font-size: 15px; }
  .sheet-tab .icon { display: none; }
}

/* The welcome: the cupboard with its doors shut, until this device joins a
   family or starts one. */
html.welcome { overflow: hidden; }
html.welcome body > :not(dialog):not(script) { visibility: hidden; }

#gate { width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; background: var(--mustard); color: var(--ink); box-shadow: none; --focus: var(--ink); }
#gate[open] { display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
#gate::backdrop { background: var(--mustard); }
#gate:not(.left) .if-left, #gate.left .if-hello { display: none; }
/* On a form step the title names the step, and the welcome text steps aside. */
#gate:not([data-step="join"]) .if-join, #gate:not([data-step="new"]) .if-new, #gate:not([data-step="code"]) .if-code { display: none; }
#gate:is([data-step="join"], [data-step="new"], [data-step="code"]) :is(.if-hello, .if-left, #gateText) { display: none; }
.gate-inner { display: grid; gap: 22px; width: 100%; max-width: 420px; }
.gate-doors {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  height: 190px; padding: 10px; border-radius: 8px;
  background: var(--frame-photo), var(--wood);
  perspective: 900px;
}
/* Behind the doors: two bare shelves, drawn like the cupboard's own (shaded
   back, plank, dark lip, the frame's oak between the rows). */
.gate-inside {
  --row: calc((100% - 6px) / 2);
  position: absolute; inset: 10px; z-index: -2; border-radius: 4px;
  background: repeating-linear-gradient(to bottom,
    var(--tint-shade) 0, transparent 20px,
    transparent calc(var(--row) - 8px),
    var(--tint-lip) calc(var(--row) - 8px), var(--tint-lip) var(--row),
    transparent var(--row), transparent calc(var(--row) + 6px)),
    var(--wood-photo), var(--shelf);
  -webkit-mask: repeating-linear-gradient(to bottom, #000 0, #000 var(--row), transparent var(--row), transparent calc(var(--row) + 6px));
  mask: repeating-linear-gradient(to bottom, #000 0, #000 var(--row), transparent var(--row), transparent calc(var(--row) + 6px));
}
/* Each door keeps the room's light off the shelves behind it. Shut, the two
   shadows overlap and the whole inside is dark; as the doors swing out they
   draw back to the hinges and the light comes in down the middle. */
.gate-doors::before, .gate-doors::after {
  content: ""; position: absolute; z-index: -1; top: 10px; bottom: 10px; width: 68%;
  pointer-events: none;
}
.gate-doors::before {
  left: 10px; border-radius: 4px 0 0 4px; transform-origin: 0 50%;
  background: linear-gradient(to right, rgba(70, 35, 0, .72), rgba(70, 35, 0, .64) 58%, rgba(70, 35, 0, 0));
}
.gate-doors::after {
  right: 10px; border-radius: 0 4px 4px 0; transform-origin: 100% 50%;
  background: linear-gradient(to left, rgba(70, 35, 0, .72), rgba(70, 35, 0, .64) 58%, rgba(70, 35, 0, 0));
}
/* A door is a slab, not a card: it has a face, an edge and a knob that
   stands off it (preserve-3d). Its light lives in box-shadow so it can move
   with the swing: --shut is the door flat in the frame, --swung is the door
   turned from the room, its face dimmed (the full-spread inset), darkest at
   the hinge (the offset inset), with its own shadow under it. */
.door {
  --ring: inset 0 0 0 10px var(--mustard), inset 0 0 0 12px rgba(0, 0, 0, .12);
  --shut: inset 0 0 0 0 rgba(70, 35, 0, 0), inset 0 0 0 200px rgba(70, 35, 0, 0), var(--ring), 0 0 0 0 rgba(0, 0, 0, 0);
  --swung: inset calc(var(--swing) * -90px) 0 80px -50px rgba(70, 35, 0, .42), inset 0 0 0 200px rgba(70, 35, 0, .32), var(--ring),
    calc(var(--swing) * 10px) 16px 18px -8px rgba(0, 0, 0, .3);
  position: relative; border-radius: 4px;
  background: var(--mustard-deep);
  box-shadow: var(--ring);
  transform-style: preserve-3d;
}
/* Hung by hand: the left door leads and opens a little wider. */
.door:first-child { --swing: -1; --open: 68deg; transform-origin: left center; }
.door + .door { --swing: 1; --open: 66deg; transform-origin: right center; }
/* The door's thickness: the edge that meets the other door, folded back
   behind the face. Edge-on and unseen while shut; swung out it faces the
   room and catches the light the face has lost. */
.door::before {
  content: ""; position: absolute; top: 4px; bottom: 4px; width: 8px;
  background: linear-gradient(rgba(255, 255, 255, .2), rgba(255, 255, 255, .2)), var(--mustard);
}
.door:first-child::before { right: 0; transform-origin: 100% 50%; transform: rotateY(-90deg); }
.door + .door::before { left: 0; transform-origin: 0 50%; transform: rotateY(90deg); }
.door::after { content: ""; position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%; background: var(--lip); transform: translateZ(4px); }
.door:first-child::after { right: 18px; }
.door + .door::after { left: 18px; }
.gate-tape {
  position: absolute; left: 50%; top: 42%;
  max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
  padding: 8px 18px 7px;
  color: var(--ink);
  font-family: var(--marker); font-size: 22px; white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-3deg);
  transition: transform .3s ease, opacity .2s ease;
}
/* Opening: the tape comes off, the doors swing out, the welcome fades away
   (app.js openDoors waits for the swing). Each door starts from rest, swings
   a touch past its stop and settles back on the hinge; its face dims and
   its shadow draws back as it goes. The doors stop short of edge-on, so the
   face they turn away is still in view. */
#gate.opening .gate-tape { transform: translate(-50%, -160%) rotate(-10deg); opacity: 0; }
#gate.opening .door { animation: door-open 680ms 40ms both; }
#gate.opening .door + .door { animation-delay: 70ms; }
#gate.opening .gate-doors::before, #gate.opening .gate-doors::after { animation: door-shade 544ms cubic-bezier(.4, 0, .2, 1) 40ms both; }
#gate.opening .gate-doors::after { animation-delay: 70ms; }
@keyframes door-open {
  0% { transform: rotateY(0deg); box-shadow: var(--shut); animation-timing-function: cubic-bezier(.4, 0, .2, 1); }
  80% {
    transform: rotateY(calc(var(--swing) * (var(--open) + 3deg))); box-shadow: var(--swung);
    animation-timing-function: cubic-bezier(.4, 0, .4, 1);
  }
  100% { transform: rotateY(calc(var(--swing) * var(--open))); box-shadow: var(--swung); }
}
@keyframes door-shade { to { transform: scaleX(.38); } }
#gate, #gate::backdrop { transition: opacity .26s ease; }
#gate.fading, #gate.fading::backdrop { opacity: 0; }

.gate-body { display: grid; gap: 12px; }
.gate-body h2 { font-size: 30px; line-height: 1.08; font-weight: 800; letter-spacing: -.015em; }
.gate-body h2:focus { outline: none; }
.gate-body .form-msg { color: #7A0F1D; }

.gate-choose { display: grid; gap: 10px; margin-top: 6px; }
.gate-choose[hidden] { display: none; }
.gate-choice {
  display: grid; gap: 2px; padding: 14px 16px 15px;
  border: 2px solid var(--ink); border-radius: 12px;
  background: var(--paper-warm); text-align: left;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .1s ease, box-shadow .1s ease;
}
.gate-choice strong { font-size: 19px; font-weight: 800; }
.gate-choice span { font-size: 15px; color: var(--paper-soft); }
.gate-choice:hover { background: #fff; }
.gate-choice:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.gate-form { display: grid; gap: 12px; margin-top: 2px; }
.gate-form[hidden] { display: none; }
.gate-field { display: grid; gap: 6px; }
.gate-field[hidden] { display: none; }
.gate-field label { font-weight: 800; }
.gate-field input {
  min-height: 58px; padding: 0 16px;
  border: 2px solid var(--ink); border-radius: 10px;
  background: var(--paper-warm); font-size: 21px;
}
.gate-field input::placeholder { color: #8F8778; }
.code-input { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.code-input::placeholder { letter-spacing: .12em; font-weight: 400; }
.gate-hint { font-size: 15px; color: var(--ink-soft); }
/* A quiet way back: the marker squiggle draws in on hover or focus, in ink,
   because tape doesn't show on the gate's yellow. */
.gate-back, .gate-resend {
  justify-self: center; min-height: 44px; padding: 0 12px;
  border: 0; background: transparent;
  font-weight: 700;
}
.gate-resend { text-decoration: underline; text-underline-offset: 3px; }
.gate-resend:disabled { text-decoration: none; color: var(--ink-soft); }
.gate-hint strong { color: var(--ink); overflow-wrap: anywhere; }
.gate-back.wiggle-go { --wiggle: var(--ink); }

@media (max-height: 700px) {
  .gate-doors { height: 120px; }
  .gate-tape { font-size: 19px; }
  .gate-inner { gap: 16px; }
}

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

.toast {
  position: fixed; left: 50%; bottom: calc(108px + env(safe-area-inset-bottom)); z-index: 90;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 10px;
  background: var(--ink); color: #fff; font-weight: 700;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.room:not([data-view="home"]) ~ .toast { bottom: calc(20px + env(safe-area-inset-bottom)); }

/* ---------- Phone ---------- */

@media (max-width: 959px) {
  /* The rim is a 6px walnut border along the top and down both sides (the
     bottom runs off the screen), painted as on the wide table: the felt
     inside the border (padding-box), the wood under it (border-box). Each
     table's padding is 6px less to make room. */
  .table {
    border: 6px solid transparent; border-bottom: 0;
    --felt-now: var(--felt);
    background:
      radial-gradient(ellipse at 40% 20%, rgba(255, 255, 255, .07), transparent 60%) padding-box,
      var(--felt-grain) padding-box,
      linear-gradient(var(--felt-now), var(--felt-now)) padding-box,
      var(--rim-photo) border-box,
      var(--rim) border-box;
  }
  .table.drop-ready { background-color: var(--rim); --felt-now: var(--felt-lit); }

  /* Home: the table is a felt edge along the bottom of the screen. */
  .room[data-view="home"] .table {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    display: flex; align-items: center; gap: 12px;
    min-height: 92px;
    padding: 10px max(10px, calc(env(safe-area-inset-right) - 6px)) calc(14px + env(safe-area-inset-bottom)) max(10px, calc(env(safe-area-inset-left) - 6px));
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -6px 18px rgba(0, 0, 0, .2);
    /* Only the lift moves, on its own layer: changing the felt's colour or
       the shadow repainted the wood and the noise grain on every frame,
       which stuttered and made the rim flash. */
    transition: transform .22s cubic-bezier(.2, .8, .2, 1);
    will-change: transform;
    /* No lid slides off this edge, so nothing needs clipping. Safari clips
       both axes under overflow-x: clip, which would cut off the felt below. */
    overflow-x: visible;
  }
  /* The felt carries on below the screen edge, so the raised table never
     shows a gap under it. */
  .room[data-view="home"] .table::after {
    content: ""; position: absolute; left: -6px; right: -6px; top: 100%; height: 24px;
    border: solid transparent; border-width: 0 6px;
    background: var(--felt-grain) padding-box, linear-gradient(var(--felt), var(--felt)) padding-box, var(--rim-photo) border-box, var(--rim) border-box;
  }
  /* Lit felt under a held box: a tint over the felt (and the strip below it)
     that fades in, behind the words. The wood and the grain stay as they are. */
  .room[data-view="home"] .table::before {
    content: ""; position: absolute; inset: 0 0 -24px; z-index: -1;
    border-radius: 12px 12px 0 0;
    background: rgb(80 170 130 / .2);
    opacity: 0; transition: opacity .15s ease;
    pointer-events: none;
  }
  .room[data-view="home"] .table::after { z-index: -2; }
  .room[data-view="home"] .table.drop-ready { --felt-now: var(--felt); }
  .room[data-view="home"] .table.drop-ready::before { opacity: 1; }
  .shelves { --row: 184px; }
  .add-slot { min-width: 66px; height: 120px; padding: 0 6px; }
  .add-tape { font-size: 14px; padding: 6px 7px 5px; }
  .add-btn {
    position: sticky; z-index: 20;
    bottom: calc(104px + env(safe-area-inset-bottom));
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .18), 0 6px 16px rgba(0, 0, 0, .2);
  }
  .recent { display: none; }

  .room[data-view="home"] .landing { flex: 1; min-width: 0; }
  .room[data-view="home"] .fuse-go { display: none; }
  .room[data-view="home"] .landing-title { font-size: 18px; }
  .room[data-view="home"] .table:has(.last) .landing-sub { display: none; }
  .room[data-view="home"] .last { max-width: 58%; }
  /* Held over the felt edge, the table slides up a little to take the box;
     12px keeps it clear of the sticky Add a box button. */
  .room[data-view="home"] .table.drop-ready { transform: translateY(-12px); }

  /* Everywhere else the table fills the screen and the cupboard waits. */
  .room:not([data-view="home"]) .cupboard { display: none; }
  .room:not([data-view="home"]) .table {
    min-height: calc(100dvh - var(--bar-h));
    padding: 6px 6px 48px;
    border-radius: 18px 18px 0 0;
  }
  .room:not([data-view="home"]) .table > .back { margin-top: 6px; }
}

@media (max-width: 380px) {
  .shelves { --row: 178px; }
  .room[data-view="home"] .last { max-width: 52%; }
  .landing-title { font-size: 18px; }
}

/* ---------- Wide: cupboard on the left, the table on the right ---------- */

@media (min-width: 600px) {
  .paper { --pad-x: 44px; padding: 38px var(--pad-x) 42px; }
  .dlg { padding: 24px 26px 26px; }
}

/* The felt colour of the wide table, registered so it can fade when a box
   is held over it. Keep the initial value equal to --felt. */
@property --felt-now { syntax: "<color>"; inherits: false; initial-value: #275E47; }

@media (min-width: 960px) {
  .room {
    display: grid; grid-template-columns: minmax(480px, 1fr) minmax(440px, 1fr); align-items: start;
  }
  .shelves { --row: 236px; --scale: 1.2; }
  .cupboard-title { max-width: 17ch; }
  .cupboard { padding: 4px 26px 40px 28px; }
  .cupboard-title { padding-top: 10px; }
  .add-btn { display: inline-flex; }

  .table {
    position: sticky; top: var(--bar-h);
    height: calc(100dvh - var(--bar-h)); overflow: hidden auto; overscroll-behavior: contain;
    padding: 14px 40px 56px 24px;
    /* The rim is a border, not an inset shadow: a scrolling table clips its
       paper inside the border, and the inner corner rounds at 28 - 16 =
       12px, so the felt's curve follows the rim's. The felt is painted
       inside the border (padding-box) and the wood under it (border-box):
       grain, a lit top edge, and the felt sunk a little below the rim. */
    border: 16px solid transparent; border-width: 16px 0 0 16px;
    border-radius: 28px 0 0 0;
    --felt-now: var(--felt);
    background:
      radial-gradient(ellipse at 40% 20%, rgba(255, 255, 255, .07), transparent 60%) padding-box,
      var(--felt-grain) padding-box,
      linear-gradient(var(--felt-now), var(--felt-now)) padding-box,
      linear-gradient(rgba(255, 255, 255, .2), transparent 5px) border-box,
      var(--rim-photo) border-box,
      var(--rim) border-box;
    box-shadow: inset 4px 5px 10px -3px rgba(0, 0, 0, .45);
    transition: --felt-now .15s ease;
    scrollbar-color: auto; /* not the page's: Chrome skips ::-webkit-scrollbar under it */
  }
  .table.drop-ready { background-color: var(--rim); --felt-now: var(--felt-lit); }
  /* The table's scrollbar: a thin pill kept clear of the rim and the
     rounded corner, not a bar pressed against the edge. A transparent
     border on the thumb sets it in from the side; the track's margin keeps
     it off the top and bottom. Browsers without ::-webkit-scrollbar get a
     thin standard one. */
  .table::-webkit-scrollbar { width: 16px; }
  .table::-webkit-scrollbar-track { background: transparent; margin: 18px 0; }
  .table::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .3) padding-box;
    border: 5px solid transparent; border-radius: 99px;
  }
  .table::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .5); }
  @supports not selector(::-webkit-scrollbar) {
    .table { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .35) transparent; }
  }
  .table > .back { margin-top: -6px; }

  .room[data-view="home"] .table { display: grid; grid-template-columns: minmax(0, 1fr); align-content: center; justify-items: center; gap: 26px; }
  .landing {
    display: grid; place-content: center; gap: 6px; text-align: center;
    width: min(440px, 100%); min-height: 200px; padding: 24px;
    border: 3px dashed rgba(235, 217, 168, .6); border-radius: 10px;
  }
  .landing-title { font-size: 30px; }
  .landing-sub { font-size: 17px; }
  .last { width: min(440px, 100%); padding: 12px 18px 12px 12px; }
  .table:has(.recent) .last { display: none; }

  .room[data-view="shared"] { display: block; }
  .room[data-view="shared"] .cupboard { display: none; }
  /* The table keeps its screen height and scrolls itself, as it does
     beside the cupboard. A full-height table would never scroll, and its
     overscroll-behavior: contain would swallow the mouse wheel. */
  .room[data-view="shared"] .table {
    border-width: 16px 16px 0;
    border-radius: 28px 28px 0 0;
    box-shadow: inset 0 5px 10px -3px rgba(0, 0, 0, .45);
    padding: 24px 8px 64px;
  }
  .room[data-view="shared"] .paper { margin: 0 auto; }

  .toast { bottom: 28px; }
}

@media (max-width: 959px) {
  .room[data-view="shared"] .cupboard { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .pen path { stroke-dashoffset: 0; }
  .box:hover, .kid-sheet:hover { transform: rotate(var(--tilt, 0deg)); }
  /* Boxes are on the shelf at once, not one after another. */
  .frame.arriving .slot > * { animation: none; }
  /* A new box's ring holds still until app.js takes it off. */
  .box.just-landed::after { animation: none; }
  .about[open], .about::backdrop, .about.is-leaving, .about.is-leaving::backdrop, .about__dot,
  .support-sheet[open], .support-sheet::backdrop, .support-sheet.is-leaving, .support-sheet.is-leaving::backdrop { animation: none; }
  .about__link, .support-sheet__frame { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
  .play-crumb, .crumb-dot, .crumb-name { transition: none; }
  .play-crumb.is-done .crumb-tick path, .crumb-dot.is-done:not(.is-now), .play-tape.is-fresh { animation: none; }
}

/* ---------- Printed rules (js/print.js) ----------
   Cards to cut out and keep in the box, four to an A4 page: white paper,
   a dashed cut line, a strip of tape with the card's name in marker, the
   step numbers big in the box face. Laid out off screen at their printed
   size, so they can be measured, and shown only on paper. */

.print {
  position: fixed; left: -400mm; top: 0; visibility: hidden; pointer-events: none;
  color: var(--ink); font-family: var(--font);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
/* A page is as wide as A4 and a little shorter than Letter, so it fits
   either paper whole: Safari prints on the printer's paper whatever the
   page asks for, and a taller page spills its last lines onto a sheet of
   their own. */
.print-page {
  position: relative; width: 210mm; height: 276mm; margin: 0 auto; padding: 10mm 10mm 0;
  display: grid; grid-template-columns: repeat(2, 92mm); grid-template-rows: repeat(2, 126mm); gap: 6mm;
  background: #fff; overflow: hidden; break-after: page;
}
.print-page:last-child { break-after: auto; }
.print-cut { position: absolute; left: 10mm; right: 10mm; bottom: 4mm; font-size: 7.5pt; color: var(--rule-strong); text-align: center; }

.pcard {
  --s: 1;
  position: relative; display: flex; flex-direction: column; width: 92mm; height: 126mm; overflow: hidden;
  padding: 6mm 6mm 4mm; border: .35mm dashed #A8A196; border-radius: 3.5mm; background: #fff;
  font-size: calc(10.5pt * var(--s)); line-height: 1.34;
}
.pcard-body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: calc(2.6mm * var(--s)); }
.pcard-tape {
  flex: none; align-self: flex-start; display: inline-flex; align-items: center; gap: 1.6mm;
  margin: -1mm 0 3.5mm -2.5mm; padding: 1.2mm 4.5mm 1mm;
  font-family: var(--marker); font-size: 15pt; line-height: 1.1; color: var(--ink);
  /* The screen's tape is see-through and masked to its torn ends; a PDF
     turns a CSS mask into a soft mask that Preview and some printers draw
     black or drop. On paper the same teeth (--tape-mask's) are painted in
     solid tape colour instead. */
  background:
    linear-gradient(var(--tape), var(--tape)) center / calc(100% - 8px) 100% no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='8'%3E%3Cpath fill='%23EBD9A8' d='M5 0H1L0 2l2 2-2 2 1 2h4z'/%3E%3C/svg%3E") left top / 5px 8px repeat-y,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='8'%3E%3Cpath fill='%23EBD9A8' d='M0 0h4l1 2-2 2 2 2-1 2H0z'/%3E%3C/svg%3E") right top / 5px 8px repeat-y;
  transform: rotate(-2deg);
}
.pcard-tape [class^="mark-"] { display: inline-flex; width: 6mm; height: 6mm; }
.pcard-tape svg { width: 100%; height: 100%; }
.pcard-foot {
  flex: none; display: flex; justify-content: space-between; gap: 3mm;
  margin-top: 2.5mm; padding-top: 1.8mm; border-top: .3mm solid var(--rule);
  font-size: 7pt; line-height: 1.2; color: var(--rule-strong);
}
.pcard-foot span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-note { flex: none; margin-top: 2.5mm; font-size: 8.5pt; font-style: italic; color: var(--paper-soft); }
.pcard-soft { color: var(--paper-soft); font-size: .92em; }
.pcard-h { margin-top: 1.5mm; font-size: .82em; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--paper-soft); }

/* Steps: the number big in the box face, like a box title. */
.pcard-steps { list-style: none; display: grid; gap: calc(2.4mm * var(--s)); }
.pcard-steps li { display: grid; grid-template-columns: calc(7.5mm * var(--s)) 1fr; column-gap: 2.6mm; align-items: start; }
.pcard-num {
  font-family: var(--box-font); font-weight: 900; font-stretch: 75%;
  font-size: calc(21pt * var(--s)); line-height: .86; text-align: right;
}
/* Pieces to take out: a box to tick in pencil. Pieces to leave in: quiet. */
.pcard-pieces, .pcard-quiet, .pcard-tips { list-style: none; display: grid; gap: calc(1.7mm * var(--s)); }
.pcard-pieces li { display: grid; grid-template-columns: calc(3.8mm * var(--s)) 1fr; column-gap: 2.4mm; align-items: start; }
.pcard-tick { width: calc(3.8mm * var(--s)); height: calc(3.8mm * var(--s)); margin-top: .2em; border: .4mm solid var(--ink); border-radius: .9mm; }
.pcard-pieces strong, .pcard-quiet strong { font-weight: 800; }
.pcard-pieces span, .pcard-quiet span { color: var(--paper-soft); }
.pcard-pieces span::before, .pcard-quiet span::before { content: " · "; }
.pcard-quiet { font-size: .9em; }
.pcard-tips li { position: relative; padding-left: 4mm; }
.pcard-tips li::before { content: ""; position: absolute; left: 0; top: .62em; width: 2mm; height: .5mm; border-radius: 1mm; background: var(--ink); }
.pcard-pairs { display: grid; gap: calc(1.8mm * var(--s)); }
.pcard-pairs dt { font-weight: 800; }
.pcard-safety { padding: 1.8mm 2.6mm; border-left: 1mm solid var(--red); background: #FBEFF0; }
.pcard-safety strong { font-weight: 800; }
.pcard-story { font-size: 1.12em; line-height: 1.42; }
.pcard-win { font-size: 1.2em; font-weight: 700; line-height: 1.35; }
.pcard.is-turn { border-color: var(--ink); border-style: solid; border-width: .5mm; }

/* The cover: the box lid, in the box's colours. */
.pcard.is-cover { padding: 0 0 4mm; }
.pcard.is-cover .pcard-body, .pcard.is-cover .pcard-note, .pcard.is-cover .pcard-foot { margin-left: 6mm; margin-right: 6mm; }
.pcard.is-cover .pcard-body { padding-top: 4.5mm; }
.pcard-lid {
  position: relative; flex: none; height: 54mm; padding: 6mm 6mm 5mm;
  display: flex; flex-direction: column; gap: 2mm;
  border-radius: 3.2mm 3.2mm 0 0; background: var(--box); color: var(--box-ink); overflow: hidden;
}
.pcard-lid.is-fused { background: linear-gradient(135deg, var(--box) 50%, var(--box2) 50%); }
/* Pushed to the bottom with an auto margin, not flex-end, so a name too
   big overflows downward, where fitName can measure it. */
.pcard-from { margin-top: auto; font-size: 8pt; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.pcard-lid.is-fused .pcard-from { align-self: flex-start; padding: .6mm 1.6mm; border-radius: .6mm; background: #fff; color: var(--ink); }
.pcard-name {
  --t: 1;
  font-family: var(--box-font); font-weight: 900; font-stretch: 72%; text-transform: uppercase;
  font-size: calc(34pt * var(--t)); line-height: .92; letter-spacing: -.01em; overflow-wrap: normal;
}
.pcard-lid.is-fused .pcard-name span { padding: 0 1.5mm; background: #fff; color: var(--ink); box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.pcard-seal {
  position: absolute; top: 5mm; right: 5mm; width: 16mm; height: 16mm; border-radius: 50%;
  display: grid; place-content: center; text-align: center; line-height: 1;
  background: var(--tape); color: var(--ink); transform: rotate(8deg);
  box-shadow: inset 0 0 0 .5mm rgba(0, 0, 0, .12);
}
.pcard-seal small { font-size: 6.5pt; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.pcard-seal b { font-family: var(--box-font); font-weight: 900; font-stretch: 75%; font-size: 17pt; }
.pcard-tagline { font-family: var(--marker); font-size: 1.3em; line-height: 1.2; }
.pcard-facts { font-weight: 800; }
.pcard-skills { color: var(--paper-soft); }
.pcard-skills span { font-weight: 800; color: var(--ink); }
.pcard-note.is-phone { font-family: var(--marker); font-style: normal; font-size: 11pt; line-height: 1.2; color: var(--red-ink); }

/* The family's own changes: ruled lines to write on. */
.pcard-lines { flex: 1; display: grid; grid-auto-rows: 1fr; margin-top: 2mm; }
.pcard-lines span { border-bottom: .3mm solid var(--rule); }
.pcard.is-notes .pcard-soft { margin-top: -1mm; }

/* On paper: only the cards, on whatever paper the printer has (the page
   fits A4 and Letter), with no browser margins, so no header or footer. */
@media print {
  @page { margin: 0; }
  body.printing { background: #fff; min-height: 0; }
  body.printing > :not(.print) { display: none !important; }
  body.printing .print { position: static; visibility: visible; }
}

/* Under the Print button on a rule sheet: what the cards are for. */
.print-hint { max-width: 46ch; font-size: 15px; color: var(--paper-soft); }
