/* Desk Drawer Contours: the play screen, cut and pasted onto the drawer floor like a zine. */

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, var(--ak-bg-art));
  background-size: cover;
  background-position: center bottom;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  color: inherit;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 3px;
}

/* ---------- Paper: a torn scrap with a chalk-white edge. The tear itself is set per scrap in game.js. ---------- */

.paper {
  position: relative;
  isolation: isolate;
}

.paper::before,
.paper::after {
  content: '';
  position: absolute;
  pointer-events: none;
  clip-path: var(--torn, none);
}

.paper::before {
  inset: -4px;
  z-index: -2;
  background: var(--edge, var(--ak-ink));
}

.paper::after {
  inset: 0;
  z-index: -1;
  background: var(--fill, var(--ak-surface));
}

.tape {
  position: absolute;
  z-index: 3;
  width: clamp(44px, 18%, 76px);
  height: 20px;
  background: color-mix(in srgb, var(--ak-ink-muted) 62%, var(--ak-ink));
  opacity: 0.88;
  clip-path: polygon(0 12%, 6% 0, 12% 14%, 20% 2%, 30% 10%, 42% 0, 55% 8%, 68% 0, 80% 10%, 90% 0, 100% 14%, 96% 50%, 100% 88%, 90% 100%, 78% 90%, 64% 100%, 50% 92%, 36% 100%, 22% 90%, 10% 100%, 0 86%, 4% 50%);
  pointer-events: none;
}

/* ---------- The play screen ---------- */

.play {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "top" "caption" "stage" "actions" "tools";
  gap: 8px;
  padding:
    calc(var(--ac-status-h, 64px) + 4px)
    max(6px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(6px, env(safe-area-inset-left));
  touch-action: manipulation;
}

.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  min-height: 48px;
}

.logo {
  display: block;
  height: clamp(34px, 6dvh, 46px);
  width: auto;
  margin-right: auto;
  rotate: -2deg;
}

.scrap-btn {
  --fill: var(--ak-surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 48px;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 17px;
}

.scrap-btn svg { width: 22px; height: 22px; flex: none; }

/* The top half is plain ink: words and a marker underline, no paper, no tape. */
.shelf-btn {
  padding: 0 6px;
  text-decoration: underline 3px var(--ak-ink-muted);
  text-underline-offset: 7px;
}
.hint-btn {
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  border-radius: 3px;
  rotate: -2deg;
}

/* Cut-out caption: chalk-white words on a navy scrap. */
.caption {
  grid-area: caption;
  justify-self: start;
  max-width: 100%;
  margin: 0 6px;
  padding: 4px 8px 6px;
  font-size: clamp(15px, 2.1dvh, 18px);
  line-height: 1.32;
  color: var(--ak-ink);
  rotate: -1deg;
  min-height: 3.2em;
  display: flex;
  align-items: center;
}

.caption.is-teach {
  padding: 10px 14px;
  border-left: 5px solid var(--ak-accent);
  background: var(--ak-surface);
  font-size: clamp(18px, 2.4dvh, 20px);
  font-weight: 700;
  rotate: 0.6deg;
}

/* Guided teaching under the reveal line: its own solid strip, 18px and up, never over the sheets. */
.caption.has-teach-line { flex-direction: column; align-items: flex-start; gap: 8px; }
.caption .teach-line {
  display: block;
  padding: 6px 10px;
  border-left: 5px solid var(--ak-accent);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.caption .note-line {
  display: block;
  color: var(--ak-ink-muted);
  font-size: 0.95em;
}

.caption .lead {
  font-family: var(--ak-font-display);
  font-weight: 400;
}

/* ---------- Stage: one sheet to look and draw, two at the reveal, three pairs at the end ---------- */

.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 18px;
  padding: 12px 10px 16px;
}

.stage[data-mode="reveal"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.stage[data-mode="spread"] { display: block; }
.stage[data-mode="spread"] .sheet { display: none; }

.sheet {
  --fill: var(--ak-surface);
  --rot: -1.5deg;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  justify-self: center;
  max-width: min(100%, 640px);
  transform: rotate(var(--rot));
}

.sheet-b { --rot: 1.4deg; }

.sheet .tape-1 { top: -9px; left: 12%; rotate: -8deg; }
.sheet .tape-2 { top: -8px; right: 10%; rotate: 6deg; }

.obj {
  position: absolute;
  z-index: 1;
  background-repeat: no-repeat;
  pointer-events: none;
}

.ink {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.sheet-b .ink { cursor: default; }

.pen-dot {
  position: absolute;
  z-index: 4;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 3px solid var(--ak-accent);
  border-radius: 50%;
  pointer-events: none;
}

.sheet-tag {
  position: absolute;
  z-index: 3;
  bottom: -12px;
  padding: 2px 10px;
  font-family: var(--ak-font-display);
  font-size: 14px;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  display: none;
}

/* Lay it over: the drawing sheet slides onto the object, its paper falls away, the line settles at 40 percent. */
.sheet-b { z-index: 2; }
.sheet-b::before,
.sheet-b::after,
.sheet-b .tape { transition: opacity 300ms ease; }
.stage.is-over .sheet-b::before,
.stage.is-over .sheet-b::after,
.stage.is-over .sheet-b .tape { opacity: 0; }
.sheet-b .ink { opacity: 1; }
/* The 40 percent itself is set by game.js (OVER_ALPHA) when the sheet lays over. */

.tag-a { left: 10%; rotate: -3deg; }
.tag-b { right: 10%; rotate: 2deg; }
.stage[data-mode="reveal"] .sheet-tag { display: block; }
.stage.is-over .tag-b { display: none; }

/* The chalk pencil across the top of the sheet: it shortens as the look runs out. */
.pencil {
  --left: 1;
  position: absolute;
  z-index: 3;
  top: 3.5%;
  left: 8%;
  right: 8%;
  height: 22px;
  color: var(--ak-ink);
  display: none;
}

.stage[data-mode="look"] .pencil { display: block; }

.pencil svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--left));
  transform-origin: left center;
}

.puff { position: absolute; left: 0; top: 50%; width: 0; height: 0; }
.puff i {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px;
  border-radius: 50%;
  background: var(--ak-ink-muted);
  opacity: 0;
}

/* ---------- Actions, kept line, tools ---------- */

.actions {
  grid-area: actions;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 16px;
  min-height: 52px;
  padding: 0 6px;
}

.act {
  --fill: var(--ak-btn-fill);
  --edge: var(--ak-bg);
  min-height: 48px;
  min-width: 48px;
  padding: 0 20px;
  font-family: var(--ak-font-display);
  font-size: 18px;
  color: var(--ak-btn-ink);
  rotate: -1.5deg;
}

.act-next,
.act-yes {
  --fill: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  rotate: 2deg;
}

.act-no,
.act-close {
  --fill: var(--ak-surface);
  --edge: var(--ak-ink);
  color: var(--ak-ink);
}

.act-lay[aria-pressed="true"] { --fill: var(--ak-choice-bg); --edge: var(--ak-accent); color: var(--ak-choice-ink); }

/* Outside the sheets a button is a flat, cleanly cut fill: the torn edge is kept for paper the player draws on. */
.act:not(.paper) {
  background: var(--fill);
  border-radius: 3px;
  box-shadow: 3px 4px 0 var(--ak-bg);
}
.act-lay:not(.paper)[aria-pressed="true"] { outline: 3px solid var(--ak-accent); outline-offset: -3px; }

.kept {
  flex-basis: 100%;
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--ak-ink-muted);
}

.actions .act:not([hidden]) ~ .kept { display: none; }
.kept.is-trouble { color: var(--ak-ink); font-weight: 700; }

.tools {
  grid-area: tools;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-row {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 2px;
}

.chip {
  --fill: var(--ak-surface);
  position: relative;
  flex: 1 1 0;
  min-width: 44px;
  max-width: 64px;
  min-height: 48px;
  display: grid;
  place-items: center;
  color: var(--ak-ink);
  rotate: var(--tilt, 0deg);
}

.chip svg { width: 30px; height: 30px; display: block; }
.chip .dot { border-radius: 50%; background: var(--ak-ink); }

.chip-word {
  max-width: 96px;
  flex: 1.5 1 0;
  display: flex;
  gap: 4px;
  padding: 0 8px;
  font-family: var(--ak-font-display);
  font-size: 15px;
}

.chip-word svg { width: 22px; height: 22px; }

.chip[aria-pressed="true"] {
  --fill: var(--ak-choice-bg);
  --edge: var(--ak-accent);
  z-index: 1;
  translate: 0 -5px;
}

.chip[aria-pressed="true"]::before { inset: -5px; }

.chip[aria-pressed="true"] .mark {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 26px;
  height: 7px;
  translate: -50% 0;
  background: var(--ak-accent);
  clip-path: polygon(0 20%, 20% 0, 45% 25%, 70% 0, 100% 30%, 92% 100%, 60% 70%, 35% 100%, 8% 80%);
}

.chip[aria-disabled="true"] { opacity: 0.5; }

/* The drawer's front lip: one thick tangerine marker band, and the tool row sits on it. */
.lip {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  height: calc(30px + env(safe-area-inset-bottom));
  background: var(--ak-accent);
  clip-path: polygon(0 18%, 4% 8%, 9% 16%, 15% 4%, 22% 14%, 30% 6%, 38% 15%, 46% 3%, 54% 12%, 62% 5%, 70% 16%, 78% 6%, 86% 14%, 93% 4%, 100% 12%, 100% 100%, 0 100%);
}

/* ---------- Guided teaching: a pulsing ring and a marker arrow ---------- */

.guide {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.guide-ring {
  position: absolute;
  border: 4px solid var(--ak-accent);
  border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
}

.guide-arrow {
  position: absolute;
  width: 54px;
  height: 54px;
  color: var(--ak-accent);
}

/* ---------- The end spread: three pairs taped down the page ---------- */

.spread {
  position: absolute;
  inset: 12px 4px 4px;
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.pair:nth-child(1) { rotate: -1.2deg; margin-right: 14px; }
.pair:nth-child(2) { rotate: 1.6deg; margin-left: 18px; }
.pair:nth-child(3) { rotate: -0.6deg; margin-right: 6px; }

.mini {
  --fill: var(--ak-surface);
  position: relative;
  min-height: 0;
}

.mini canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mini .tape { width: 40px; height: 14px; top: -7px; left: 36%; rotate: -6deg; }
.mini + .mini .tape { left: 30%; rotate: 5deg; }

.mini-name {
  position: absolute;
  z-index: 3;
  left: 6px;
  bottom: -8px;
  padding: 1px 8px;
  font-family: var(--ak-font-display);
  font-size: 13px;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  rotate: -2deg;
}

.mini-drift {
  position: absolute;
  z-index: 3;
  right: 6px;
  bottom: -8px;
  padding: 1px 8px;
  font-family: var(--ak-font-display);
  font-size: 13px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  border: 2px solid var(--ak-ink-muted);
  rotate: 2deg;
  white-space: nowrap;
}

@media (orientation: landscape) {
  .mini-drift,
  .mini-name { font-size: 12px; padding: 1px 6px; }
}

/* The pencil ghost: a faint dashed ring where the outline might start. Shown in the look and the draw. */
.ghost {
  position: absolute;
  z-index: 3;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  color: var(--ak-ink-muted);
  opacity: 0.55;
  pointer-events: none;
}
.ghost svg { display: block; width: 100%; height: 100%; }

.banner {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 44%;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: max-content;
  max-width: 94%;
  translate: -50% -50%;
  pointer-events: none;
}

.banner span {
  --fill: var(--ak-surface);
  --edge: var(--ak-accent);
  padding: 4px 12px 6px;
  font-family: var(--ak-font-display);
  font-size: clamp(24px, 5dvh, 40px);
  color: var(--ak-ink);
}

.banner span:nth-child(odd) { rotate: -3deg; }
.banner span:nth-child(even) { rotate: 2deg; translate: 0 6px; }
.banner span:nth-child(3) { --fill: var(--ak-choice-selected-bg); --edge: var(--ak-ink); color: var(--ak-choice-selected-ink); }

.burst { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: visible; }
.burst i {
  position: absolute;
  left: 50%;
  top: 45%;
  width: 14px;
  height: 8px;
  background: var(--c, var(--ak-accent));
  opacity: 0;
}

/* ---------- In-page sheets: the Clear ask and the drawer shelf ---------- */

.ask,
.shelf {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--ak-bg) 82%, transparent);
}

.ask { z-index: 36; }

/* Keep the help corner clear: the sheets start below the round ? button. */
.ask,
.shelf { padding-top: calc(max(12px, env(safe-area-inset-top)) + 62px); }

.ask-paper,
.shelf-paper {
  --fill: var(--ak-surface);
  width: min(100%, 420px);
  padding: 30px 24px 22px;
  rotate: 1.5deg;
}

.ask-paper .tape-1,
.shelf-paper .tape-1 { top: -10px; left: 40%; rotate: -4deg; }
.shelf-paper .tape-2 { top: -8px; right: 8%; rotate: 7deg; }

.ask-title,
.shelf-title {
  margin: 0 0 8px;
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: 26px;
  color: var(--ak-ink);
  rotate: -1.5deg;
}

.ask-body { margin: 0 0 18px; font-size: 17px; line-height: 1.4; color: var(--ak-ink); }
.ask-buttons { display: flex; flex-wrap: wrap; gap: 14px; }

.shelf-paper {
  width: min(100%, 680px);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  rotate: -0.8deg;
}

.shelf-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.shelf-body {
  min-height: 0;
  overflow-y: auto;
  padding: 10px 4px 14px;
}

.shelf-body h3 {
  margin: 8px 0 12px;
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: 19px;
  color: var(--ak-ink);
}

.shelf-empty { margin: 8px 0; font-size: 17px; line-height: 1.4; color: var(--ak-ink); }

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 22px 16px;
}

.thumb {
  --fill: var(--ak-bg);
  display: flex;
  flex-direction: column;
  min-height: 48px;
  padding: 0 0 6px;
  text-align: left;
}

.thumb:nth-child(3n + 1) { rotate: -2deg; }
.thumb:nth-child(3n + 2) { rotate: 1.5deg; }
.thumb:nth-child(3n) { rotate: -0.5deg; }

.thumb canvas { display: block; width: 100%; aspect-ratio: 3 / 4; }
.thumb b { padding: 4px 8px 0; font-family: var(--ak-font-display); font-weight: 400; font-size: 15px; color: var(--ak-ink); }
.thumb small { padding: 0 8px; font-size: 13px; color: var(--ak-ink-muted); }

.shelf-pairs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}

.shelf-pairs .pair { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, auto); margin: 0; }
.shelf-pairs .mini { height: min(24dvh, 170px); }

.detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.detail .mini { height: min(36dvh, 280px); }
.detail-words { margin: 0 0 14px; font-size: 16px; line-height: 1.4; color: var(--ak-ink); }
.detail-buttons { display: flex; flex-wrap: wrap; gap: 14px; }
.act-delete { --fill: var(--ak-surface); --edge: var(--ak-accent); color: var(--ak-ink); }

.shelf-kept { margin-top: 6px; }

/* ---------- Sideways: the board on one side, the controls and status on the other ---------- */

@media (orientation: landscape) {
  .play {
    max-width: 1180px;
    grid-template-columns: minmax(0, 1.3fr) minmax(380px, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "stage top"
      "stage caption"
      "stage actions"
      "stage tools";
    column-gap: 18px;
    row-gap: 6px;
  }

  .stage { padding: 12px 8px 10px; }
  .actions { align-self: center; }
  .logo { height: clamp(30px, 8dvh, 52px); }
  .caption { font-size: clamp(14px, 3.6dvh, 18px); min-height: 0; }
  .caption.is-teach { font-size: 18px; }
  .lip { right: 0; left: auto; width: min(100%, calc(380px + 40px + env(safe-area-inset-right))); }

  .spread { grid-template-rows: minmax(0, 1fr); grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .spread .pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .pair:nth-child(n) { margin: 0; }
}

@media (orientation: landscape) and (max-height: 420px) {
  .top { min-height: 44px; }
  .act { font-size: 16px; padding: 0 14px; }
  .kept { font-size: 12px; }
}

@media (min-width: 700px) and (orientation: portrait) {
  .tools { flex-direction: row; justify-content: center; gap: 10px; }
}

/* ---------- Motion: every move eases and squashes; all of it rests under Less motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .scrap-btn,
  :root:not(.ac-still) .act,
  :root:not(.ac-still) .chip,
  :root:not(.ac-still) .thumb {
    transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1), translate 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  }

  :root:not(.ac-still) .scrap-btn:active,
  :root:not(.ac-still) .act:active,
  :root:not(.ac-still) .chip:active,
  :root:not(.ac-still) .thumb:active { transform: scale(0.9, 0.86) rotate(-2deg); }

  :root:not(.ac-still) .chip.is-picked { animation: chip-pop 320ms cubic-bezier(0.34, 1.56, 0.64, 1); }
  :root:not(.ac-still) .act:not([hidden]) { animation: scrap-in 420ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
  :root:not(.ac-still) .caption.is-new { animation: caption-in 380ms cubic-bezier(0.22, 1, 0.36, 1) both; }

  :root:not(.ac-still) .obj.is-dropping { animation: tape-drop 620ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
  :root:not(.ac-still) .obj.is-peeling { animation: peel-away 560ms cubic-bezier(0.55, 0, 0.75, 0.3) forwards; }
  :root:not(.ac-still) .sheet.is-taping { animation: sheet-tape 560ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
  :root:not(.ac-still) .sheet-b.is-taping { animation-delay: 140ms; }
  :root:not(.ac-still) .sheet-b.is-sliding { transition: transform 680ms cubic-bezier(0.34, 1.3, 0.64, 1); }
  :root:not(.ac-still) .sheet-b .ink { transition: opacity 500ms ease 200ms; }
  :root:not(.ac-still) .sheet-b::before,
  :root:not(.ac-still) .sheet-b::after { transition: opacity 400ms ease; }
  :root:not(.ac-still) .pair.is-taping { animation: pair-tape 520ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
  :root:not(.ac-still) .banner span { animation: cut-in 460ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
  :root:not(.ac-still) .banner span:nth-child(2) { animation-delay: 90ms; }
  :root:not(.ac-still) .banner span:nth-child(3) { animation-delay: 180ms; }
  :root:not(.ac-still) .banner span:nth-child(4) { animation-delay: 270ms; }
  :root:not(.ac-still) .pencil.is-out .puff i { animation: puff 640ms ease-out both; }
  :root:not(.ac-still) .pencil.is-out .puff i:nth-child(2) { --dx: -14px; --dy: -16px; animation-delay: 40ms; }
  :root:not(.ac-still) .pencil.is-out .puff i:nth-child(3) { --dx: 16px; --dy: -10px; animation-delay: 80ms; }
  :root:not(.ac-still) .pencil.is-out .puff i:nth-child(4) { --dx: -6px; --dy: 16px; animation-delay: 30ms; }
  :root:not(.ac-still) .pencil.is-out .puff i:nth-child(5) { --dx: 20px; --dy: 12px; animation-delay: 110ms; }
  :root:not(.ac-still) .burst i { animation: fling 1300ms cubic-bezier(0.2, 0.7, 0.3, 1) both; }
  :root:not(.ac-still) .guide-ring { animation: ring-pulse 1300ms ease-in-out infinite; }
  :root:not(.ac-still) .guide-arrow { animation: arrow-nudge 1100ms ease-in-out infinite; }
  :root:not(.ac-still) .play.is-nudge .stage { animation: nudge 360ms ease; }

  /* Idle: the tape lifts a little at its ends, and the shelf scrap breathes. */
  :root:not(.ac-still) .sheet .tape-1 { animation: tape-idle 4.2s ease-in-out infinite; }
  :root:not(.ac-still) .sheet .tape-2 { animation: tape-idle 5s ease-in-out 1.2s infinite; }
  :root:not(.ac-still) .shelf-btn { animation: bob 3.6s ease-in-out infinite; }
  :root:not(.ac-still) .play[data-phase="draw"] .sheet-a { animation: breathe 3s ease-in-out infinite; }

  @keyframes chip-pop { 0% { transform: scale(1); } 40% { transform: scale(1.18, 0.86); } 70% { transform: scale(0.95, 1.06); } 100% { transform: scale(1); } }
  @keyframes scrap-in { from { opacity: 0; transform: translateY(14px) rotate(-5deg) scale(0.9); } to { opacity: 1; transform: none; } }
  @keyframes caption-in { from { opacity: 0; transform: translateY(16px) rotate(2deg); } to { opacity: 1; transform: none; } }
  @keyframes tape-drop {
    0% { opacity: 0; transform: translateY(-36px) rotate(6deg) scale(1.1); }
    55% { opacity: 1; transform: translateY(4px) rotate(-1.5deg) scale(1.02, 0.96); }
    75% { transform: translateY(-2px) rotate(1deg) scale(0.99, 1.02); }
    100% { transform: none; }
  }
  @keyframes peel-away {
    0% { transform: none; opacity: 1; }
    30% { transform: translate(4px, -6px) rotate(-3deg); }
    100% { transform: translate(60%, -70%) rotate(-24deg) scale(0.7); opacity: 0; }
  }
  @keyframes sheet-tape {
    0% { opacity: 0; transform: translateY(-24px) rotate(calc(var(--rot) + 5deg)) scale(1.08); }
    60% { opacity: 1; transform: translateY(3px) rotate(calc(var(--rot) - 1deg)) scale(1.01, 0.97); }
    100% { transform: rotate(var(--rot)); }
  }
  @keyframes pair-tape {
    0% { opacity: 0; transform: translateY(-30px) scale(1.06); }
    55% { opacity: 1; transform: translateY(2px); }
    70% { transform: translateX(-4px) rotate(-1deg); }
    85% { transform: translateX(3px) rotate(0.8deg); }
    100% { transform: none; }
  }
  @keyframes cut-in { 0% { opacity: 0; transform: scale(1.6) rotate(-12deg); } 100% { opacity: 1; transform: none; } }
  @keyframes puff { 0% { opacity: 0.9; transform: translate(0, 0) scale(0.4); } 100% { opacity: 0; transform: translate(var(--dx, 0), var(--dy, -12px)) scale(1.8); } }
  @keyframes fling {
    0% { opacity: 1; transform: translate(-50%, -50%) rotate(0) scale(0.6); }
    100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)) scale(1); }
  }
  @keyframes ring-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.04); opacity: 0.6; } }
  @keyframes arrow-nudge { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(5px, 5px); } }
  @keyframes nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
  @keyframes tape-idle { 0%, 100% { transform: none; } 50% { transform: translateY(-2px) skewX(-4deg); } }
  @keyframes bob { 0%, 100% { transform: none; } 50% { transform: translateY(-3px) rotate(-1deg); } }
  @keyframes breathe { 0%, 100% { transform: rotate(var(--rot)) scale(1); } 50% { transform: rotate(var(--rot)) scale(1.006); } }
}

/* The toast sits over the tool row on a phone: taps pass through to the tools, and the chrome still clears it on that tap. */
#activity-chrome-toast { pointer-events: none; }

/* ---------- The ending (drawn by chrome.js): kept whole on every screen ----------
   chrome.js adds its own stylesheet after this one, so these rules carry extra weight (html body …).
   The card centres when it fits and scrolls from its top when it does not, so the pin and the
   buttons are always reachable. Sideways, the print sits beside the words so it all fits at once. */

html body #activity-chrome-ending.site-inspicacity {
  justify-content: flex-start;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

html body #activity-chrome-ending.site-inspicacity .ac-card {
  flex: none;
  margin: auto 0;
}

/* The drift check is the card's second line: smaller, in muted ink. */
html body #activity-chrome-ending.site-inspicacity .ac-line + .ac-line {
  margin-top: 4px;
  font-size: 0.88em;
  color: var(--ak-ink-muted);
}

/* Room for the print's tape strips, so they never sit on the words above. */
html body #activity-chrome-ending.site-inspicacity .ac-work { margin-top: 14px; }

/* Upright, the print takes what the words and buttons leave: about 430px of them on a small phone. */
html body #activity-chrome-ending.site-inspicacity .ac-work img {
  max-height: clamp(130px, calc(100dvh - 520px), 46dvh);
  width: auto;
}

/* Narrow and upright, the card's words start below the round ? button in the top-right corner. */
@media (orientation: portrait) and (max-width: 480px) {
  html body #activity-chrome-ending.site-inspicacity .ac-card { padding: 48px 18px 18px; gap: 8px; }
  html body #activity-chrome-ending.site-inspicacity .ac-verdict { font-size: clamp(22px, 7vw, 30px); }
  html body #activity-chrome-ending.site-inspicacity .ac-lines { font-size: 15px; line-height: 1.38; }
  html body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: clamp(120px, calc(100dvh - 520px), 46dvh); }
}

@media (orientation: landscape) and (max-height: 640px) {
  html body #activity-chrome-ending.site-inspicacity {
    padding-right: calc(72px + env(safe-area-inset-right));
  }

  html body #activity-chrome-ending.site-inspicacity .ac-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: 1fr auto auto auto auto 1fr;
    column-gap: 28px;
    row-gap: 8px;
    width: min(100%, 860px);
    padding: 22px 22px 16px;
    text-align: left;
  }

  html body #activity-chrome-ending.site-inspicacity .ac-number { font-size: 17px; }
  html body #activity-chrome-ending.site-inspicacity .ac-verdict { font-size: clamp(20px, 6.5dvh, 32px); }
  html body #activity-chrome-ending.site-inspicacity .ac-lines { font-size: clamp(13px, 3.8dvh, 17px); line-height: 1.32; }
  html body #activity-chrome-ending.site-inspicacity .ac-line { margin: 0; }
  html body #activity-chrome-ending.site-inspicacity .ac-actions { gap: 10px 12px; }
  html body #activity-chrome-ending.site-inspicacity .ac-actions button { padding: 0 14px; font-size: 16px; }

  html body #activity-chrome-ending.site-inspicacity .ac-number { grid-column: 2; grid-row: 2; }
  html body #activity-chrome-ending.site-inspicacity .ac-verdict { grid-column: 2; grid-row: 3; }
  html body #activity-chrome-ending.site-inspicacity .ac-lines { grid-column: 2; grid-row: 4; }
  html body #activity-chrome-ending.site-inspicacity .ac-actions { grid-column: 2; grid-row: 5; justify-content: flex-start; }

  html body #activity-chrome-ending.site-inspicacity .ac-work {
    margin-top: 0;
    grid-column: 1;
    grid-row: 1 / -1;
    align-self: center;
  }

  /* The card's padding, the print's white border and the page's own padding leave this much height. */
  html body #activity-chrome-ending.site-inspicacity .ac-work img {
    max-height: calc(100dvh - 32px - 38px - 38px - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}


/* ---------- The end of a sitting: the tool tray is tucked away and the spread takes the page ---------- */

.play[data-phase="spread"] {
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "top" "caption" "stage";
}
.play[data-phase="spread"] .tools,
.play[data-phase="spread"] .actions,
.play[data-phase="spread"] .lip { display: none; }

@media (orientation: landscape) {
  .play[data-phase="spread"] {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "top caption" "stage stage";
  }
  .play[data-phase="spread"] .caption { align-self: center; }
}

/* ---------- The status bar in plain ink: no chips, no tape ----------
   chrome.js adds its stylesheet after this one, so these carry extra weight (html body …). */

html body #activity-chrome-status.site-inspicacity { gap: 2px 18px; padding: 2px 4px 0; }
html body #activity-chrome-status.site-inspicacity > * {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  rotate: none;
}
html body #activity-chrome-status.site-inspicacity > *::before { content: none; }
html body #activity-chrome-status.site-inspicacity .ac-open {
  padding: 0 4px;
  text-decoration: underline 3px var(--ak-ink-muted);
  text-underline-offset: 7px;
}
html body #activity-chrome-status.site-inspicacity .ac-progress { font-family: var(--ak-font-display); color: var(--ak-ink); }
html body #activity-chrome-status.site-inspicacity .ac-label { font-family: var(--ak-font-body); font-size: 16px; color: var(--ak-ink-muted); }

/* ---------- The opening (drawn by start.js): a bright sheet of graph paper laid on the drawer floor ----------
   Dark ink on white paper is the kit's own button pair (--ak-btn-fill with --ak-btn-ink). */

#activity-start.site-inspicacity .ak-scene,
#activity-start.site-inspicacity .ak-sheet {
  position: relative;
  box-sizing: border-box;
  padding: 30px clamp(18px, 5vw, 40px) 28px;
  background-color: var(--ak-btn-fill);
  background-image:
    linear-gradient(color-mix(in srgb, var(--ak-btn-ink) 13%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ak-btn-ink) 13%, transparent) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ak-btn-ink);
  box-shadow: 6px 8px 0 color-mix(in srgb, var(--ak-bg) 70%, transparent);
  rotate: -0.8deg;
}

#activity-start.site-inspicacity .ak-scene { min-height: calc(100dvh - 64px); }

#activity-start.site-inspicacity .ak-scene::before,
#activity-start.site-inspicacity .ak-sheet::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 50%;
  width: 96px;
  height: 24px;
  translate: -50% 0;
  rotate: -3deg;
  background: color-mix(in srgb, var(--ak-ink-muted) 62%, var(--ak-ink));
  clip-path: polygon(0 12%, 8% 0, 18% 12%, 30% 2%, 44% 10%, 58% 0, 72% 10%, 86% 0, 100% 14%, 96% 50%, 100% 88%, 88% 100%, 74% 90%, 58% 100%, 42% 92%, 26% 100%, 10% 90%, 0 86%, 4% 50%);
}

#activity-start.site-inspicacity .ak-title,
#activity-start.site-inspicacity .ak-tagline,
#activity-start.site-inspicacity .ak-scene-line,
#activity-start.site-inspicacity .ak-first,
#activity-start.site-inspicacity .ak-first-label,
#activity-start.site-inspicacity .ak-how,
#activity-start.site-inspicacity .ak-jump { color: var(--ak-btn-ink); }

#activity-start.site-inspicacity .ak-first { background: none; }

#activity-start.site-inspicacity .ak-go {
  border-color: var(--ak-btn-ink);
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  box-shadow: 4px 5px 0 var(--ak-btn-ink);
}

#activity-start.site-inspicacity .ak-jump { font-weight: 700; }
