/* Coffee Ring Doodles: a riso poster on a café table. Two drums (riso blue, sunflower), coffee as the
   only third ink, everything a hair out of register, no drop shadows: depth comes from overprint. */

:root {
  --edge: 12px;
  --reg: 3px;
  --wobble: 16px 5px 18px 7px / 6px 15px 7px 17px;
  --wobble-2: 7px 18px 6px 15px / 16px 6px 18px 5px;
  --tape: color-mix(in srgb, var(--ak-accent-2) 88%, var(--ak-bg));
  --side-w: clamp(240px, 36vw, 420px);
  --gutter-w: 76px;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

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

/* ---------- The play screen: portrait stacks, landscape splits ---------- */

.play {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "strip corner"
    "question question"
    "sheet sheet"
    "toolbar toolbar"
    "dock dock";
  column-gap: 8px;
  padding:
    calc(var(--ac-status-h, 64px) + 2px)
    max(var(--edge), env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom))
    max(var(--edge), env(safe-area-inset-left));
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* The poster numeral: a third of the screen tall, its lower half under the question slip and the sheet. */
.strip {
  grid-area: strip;
  position: relative;
  z-index: 0;
  min-height: clamp(84px, 13.5dvh, 132px);
}

.numeral {
  position: absolute;
  left: -4px;
  bottom: 0;
  height: 0;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight, 400);
  font-size: min(33dvh, calc((100dvw - 150px) * 1.2));
  line-height: 1;
  pointer-events: none;
}

.numeral span {
  position: absolute;
  left: 0;
  bottom: -0.36em;
  display: block;
  transform-origin: 50% 70%;
}

.numeral-b {
  color: var(--ak-accent);
}

.numeral-y {
  color: var(--ak-accent-2);
  translate: 0.035em 0.025em;
}

.logo {
  grid-area: logo;
  display: block;
  height: 34px;
  width: auto;
}

/* The corner: the soft clock, the first-round hint and the saved drawings. */
.corner {
  grid-area: corner;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(2, 56px);
  grid-template-areas: "hint clock" "reel clock";
  align-content: end;
  justify-content: end;
  gap: 6px;
  padding-bottom: 6px;
}

.corner .clock { grid-area: clock; align-self: center; }
.corner .hint { grid-area: hint; }
.corner .reel-btn { grid-area: reel; }
.corner:not(:has(.hint:not([hidden]))) { grid-template-areas: "reel clock" "reel clock"; }
.corner:not(:has(.hint:not([hidden]))) .reel-btn { align-self: center; }

.clock {
  position: relative;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ak-surface);
  --p: 0;
}

.clock-track {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.clock-track circle {
  fill: none;
  stroke: var(--ak-accent);
  stroke-width: 3;
  stroke-dasharray: 3 4;
}

.clock-fill {
  position: absolute;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  -webkit-mask-image: conic-gradient(#000 calc(var(--p) * 1turn), transparent 0);
  mask-image: conic-gradient(#000 calc(var(--p) * 1turn), transparent 0);
  pointer-events: none;
}

.clock[aria-disabled="true"] { cursor: default; }

/* The plain word under the ring, so finishing early is not a guess. */
.clock-word {
  position: absolute;
  left: 50%;
  top: 100%;
  translate: -50% 1px;
  padding: 0 5px;
  background: var(--ak-bg);
  color: var(--ak-accent);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
}

.clock[aria-disabled="true"] .clock-word { color: var(--ak-ink-muted); }

.corner-chip {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: 56px;
  min-height: 52px;
  padding: 3px 2px;
  border: 0;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.05;
}

.corner-chip svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.corner-chip::before,
.corner-chip::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--wobble);
}

.corner-chip::before { translate: var(--reg) var(--reg); }

.hint { color: var(--ak-ink); }
.hint::after { background: var(--ak-accent-2); }
.hint::before { background: var(--ak-accent); }
.hint svg path:first-child { fill: var(--ak-surface); }

.reel-btn { color: var(--ak-btn-ink); }
.reel-btn::after { background: var(--ak-btn-fill); border-radius: var(--wobble-2); }
.reel-btn::before { background: var(--ak-accent-2); border-radius: var(--wobble-2); }

/* The question: one blue line on a slip of riso stock, the logo printed at its left. */
.question-strip {
  grid-area: question;
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "logo q" "h h" "s s" "n n";
  align-items: center;
  column-gap: 10px;
  margin: 0 -4px 8px;
  padding: 8px 14px 8px;
  /* Printed in the sunflower drum, square-cut: a poster band, plainly not the paper you draw on. */
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  border-radius: 2px;
}

.question-strip::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 5px;
  background: var(--ak-accent);
  translate: var(--reg) 0;
  pointer-events: none;
}

.question {
  grid-area: q;
  margin: 0;
  color: var(--ak-choice-selected-ink);
  font-family: var(--ak-font-body);
  font-weight: 600;
  font-size: clamp(18px, 5dvw, 22px);
  line-height: 1.2;
}

.how {
  grid-area: h;
  margin: 4px 0 0;
  color: var(--ak-choice-selected-ink);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
}

/* The table special (or the café card's count on the first stain): a sunflower slip, never a score. */
.special {
  grid-area: s;
  justify-self: start;
  margin: 6px 0 0;
  padding: 3px 10px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  border-left: 5px solid var(--ak-accent);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  rotate: -0.6deg;
}

.special:empty { display: none; }

.nudge {
  grid-area: n;
  min-height: 1.3em;
  margin: 2px 0 0;
  color: var(--ak-ink-muted);
  font-size: 16px;
  line-height: 1.3;
}

.nudge.is-on { color: var(--ak-ink); }
.question-strip .nudge { color: var(--ak-choice-selected-ink); }
.nudge b { color: var(--ak-accent); font-weight: 600; }

/* ---------- The sheet: the biggest thing on screen ---------- */

.sheet-wrap {
  grid-area: sheet;
  position: relative;
  z-index: 1;
  touch-action: none;
  container-type: size;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
}

.sheet {
  position: relative;
  --sw: min(100cqw, 100cqh * 5 / 6, 100dvw - 24px);
  width: var(--sw);
  aspect-ratio: 5 / 6;
  background-color: var(--ak-surface);
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
  border-radius: 6px 3px 7px 2px / 3px 7px 2px 6px;
  touch-action: none;
}

.sheet::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 2.5px solid var(--ak-accent);
  border-radius: 9px 4px 11px 3px / 4px 10px 3px 9px;
  translate: calc(var(--reg) + 1px) var(--reg);
  pointer-events: none;
  z-index: 3;
}

.sheet canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.ink-layer {
  cursor: crosshair;
  touch-action: none;
}

.ink-layer:focus-visible { outline-offset: 6px; }

.play.is-resting .ink-layer { cursor: default; }

.kbd-pen {
  position: absolute;
  z-index: 4;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border: 2px solid var(--ak-ink);
  border-radius: 50%;
  pointer-events: none;
}

.kbd-pen::before,
.kbd-pen::after {
  content: '';
  position: absolute;
  background: var(--ak-ink);
}

.kbd-pen::before { left: 11px; top: -8px; width: 2px; height: 38px; }
.kbd-pen::after { top: 11px; left: -8px; height: 2px; width: 38px; }
.kbd-pen.is-down { background: color-mix(in srgb, var(--ak-accent-2) 70%, transparent); }

.tape {
  position: absolute;
  z-index: 4;
  width: clamp(44px, 16%, 76px);
  height: clamp(16px, 4.5%, 24px);
  background:
    repeating-linear-gradient(90deg, transparent 0 9px, color-mix(in srgb, var(--ak-accent-2) 70%, var(--ak-bg)) 9px 11px),
    var(--tape);
  pointer-events: none;
}

.tape-a { left: -14px; top: 6px; rotate: -38deg; }
.tape-b { right: -14px; top: 6px; rotate: 36deg; }
.tape-c { left: -14px; bottom: 6px; rotate: 34deg; }
.tape-d { right: -14px; bottom: 6px; rotate: -40deg; }

/* The stamp: the kept doodle pressed onto its napkin, over the sheet. */
/* The recap, laid out down the sheet: the napkin on top, shrinking as needed, the readback below. */
.kept {
  position: absolute;
  inset: 4% 6% 4%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  pointer-events: none;
}

.stamp {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  max-width: 64%;
  aspect-ratio: 377 / 384;
  margin: 0 0 2.3em;
  rotate: -3deg;
}

/* The page reads the choices back, printed on the sheet under the napkin. */
.stamp-read {
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 6px 8px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: clamp(13px, calc(var(--sw, 300px) * 0.047), 18px);
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
}

.stamp-napkin {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stamp-art {
  position: absolute;
  left: 15%;
  top: 13%;
  width: 70%;
  height: 62%;
}

.stamp-name {
  position: absolute;
  left: 50%;
  top: 101%;
  translate: -50% 0;
  max-width: calc(var(--sw, 300px) * 0.86);
  width: max-content;
  padding: 4px 12px;
  background: var(--ak-bg);
  color: var(--ak-accent);
  font-family: var(--ak-font-display);
  font-size: clamp(13px, calc(var(--sw, 300px) * 0.05), 20px);
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  rotate: 2deg;
}

.pal {
  position: absolute;
  z-index: 6;
  right: -3%;
  top: -3%;
  width: 21%;
  pointer-events: none;
}

/* ---------- The dock: one row of cut-paper tools along the bottom edge ---------- */

.toolbar {
  grid-area: toolbar;
  position: relative;
  z-index: 4;
  container-type: inline-size;
  padding-top: 8px;
}

.toolbar:not(:has(.tools:not([hidden]))) { padding-top: 0; }

.dock {
  grid-area: dock;
  position: relative;
  z-index: 4;
}

.dock > .name-bar,
.dock > .next-bar { margin-top: 8px; }

.next-bar {
  display: flex;
  justify-content: center;
}

.next-btn {
  position: relative;
  isolation: isolate;
  min-height: 56px;
  min-width: min(100%, 240px);
  padding: 0 24px;
  border: 0;
  background: none;
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 17px;
}

.next-btn::after,
.next-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 4px 14px 5px 12px / 12px 4px 14px 5px;
}

.next-btn::after { background: var(--ak-btn-fill); }
.next-btn::before { background: var(--ak-accent-2); translate: var(--reg) var(--reg); }

.tools {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
  transform-origin: 50% 100%;
}

.chip {
  position: relative;
  isolation: isolate;
  flex: 1 1 0;
  min-width: 48px;
  max-width: 78px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px 5px;
  border: 0;
  background: none;
  color: var(--ak-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.05;
  text-align: center;
}

.chip svg {
  width: 28px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.chip::before,
.chip::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
}

/* The fill and its offset second drum. */
.chip::before { translate: var(--reg) var(--reg); }

.pen-chip::after { background: var(--ak-surface); border: 2.5px solid var(--ak-accent); border-radius: 50%; }
.pen-chip::before { background: var(--ak-accent-2); border-radius: 50%; }
.pen-dot {
  display: block;
  width: var(--dot, 18px);
  height: var(--dot, 18px);
  border-radius: 50%;
  background: var(--pen, var(--ak-ink));
  outline: 2px solid var(--ak-ink);
  outline-offset: 2px;
}

.eraser-chip::after { background: var(--ak-accent-2); border-radius: 3px; }
.eraser-chip::before { background: var(--ak-accent); border-radius: 3px; }
.eraser-chip svg rect { fill: var(--ak-surface); }
.eraser-chip[aria-pressed="true"]::after { background: var(--ak-ink); }
.eraser-chip[aria-pressed="true"] { color: var(--ak-accent-2); }
.eraser-chip[aria-pressed="true"] svg rect { fill: var(--ak-accent-2); stroke: var(--ak-accent-2); }
.eraser-chip[aria-pressed="true"] svg path { stroke: var(--ak-ink); }

.undo-chip { color: var(--ak-accent); }
.undo-chip::after { background: var(--ak-surface); border: 2.5px solid var(--ak-accent); border-radius: 22px 8px 20px 6px / 8px 20px 6px 22px; }
.undo-chip::before { background: var(--ak-accent-2); border-radius: 22px 8px 20px 6px / 8px 20px 6px 22px; }

.clear-chip { color: var(--ak-btn-ink); }
.clear-chip::after,
.clear-chip::before {
  clip-path: polygon(0 0, 100% 0, 100% 64%, 91% 70%, 97% 78%, 86% 84%, 90% 93%, 78% 92%, 72% 100%, 0 100%);
}
.clear-chip::after { background: var(--ak-btn-fill); }
.clear-chip::before { background: var(--ak-accent-2); }

.stain-chip::after { background: var(--ak-surface); border: 2.5px dashed var(--ak-accent); border-radius: 50%; }
.stain-chip::before { background: var(--ak-accent-2); border-radius: 50%; }
.stain-chip svg { width: 30px; height: 30px; }
.stain-chip .stain-ring-icon { stroke: #8A5A2E; stroke-width: 4.5; }
.stain-chip .stain-drip-icon { stroke: #8A5A2E; stroke-width: 3; }
.stain-chip .stain-drop-icon { fill: #4E2F14; stroke: none; }
.stain-chip[aria-disabled="true"] { color: var(--ak-ink-muted); }
.stain-chip[aria-disabled="true"] svg { opacity: 0.35; }
.stain-chip[aria-disabled="true"]::before { background: transparent; }
.stain-chip[aria-disabled="true"]::after { border-color: var(--ak-ink-muted); border-style: dotted; }

/* Done: the plain way to finish, a stamped sunflower ticket with a check. */
.done-chip { color: var(--ak-ink); }
.done-chip::after { background: var(--ak-accent-2); border: 3px solid var(--ak-ink); border-radius: 4px 14px 4px 14px; }
.done-chip::before { background: var(--ak-accent); border-radius: 4px 14px 4px 14px; }
.done-chip svg { stroke-width: 4; }

.chip[aria-disabled="true"] { cursor: default; }
.undo-chip[aria-disabled="true"] { color: var(--ak-ink-muted); }
.undo-chip[aria-disabled="true"]::before { background: transparent; }
.undo-chip[aria-disabled="true"]::after { border-color: var(--ak-ink-muted); }

/* Sizes and colours: inline when the bar is wide, a tray above the colour chip when it is not. */
.palette {
  display: none;
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  z-index: 6;
  box-sizing: border-box;
  width: min(100%, 300px);
  padding: 12px;
  background: var(--ak-bg);
  border-radius: var(--wobble);
  rotate: -0.8deg;
}

.palette::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2.5px solid var(--ak-accent);
  border-radius: inherit;
  translate: var(--reg) var(--reg);
  pointer-events: none;
}

.palette.is-open { display: grid; gap: 10px; }

.sizes,
.swatches {
  display: grid;
  gap: 6px;
  justify-content: center;
}

.sizes { grid-template-columns: repeat(3, 52px); }
.swatches { grid-template-columns: repeat(4, 52px); }

.size-dot,
.swatch {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
}

.size-dot::after {
  content: '';
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: var(--ak-accent);
}

.size-dot::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid var(--ak-accent);
  background: var(--ak-surface);
  z-index: -1;
}

.size-dot { isolation: isolate; }
.size-dot[aria-pressed="true"]::before { background: var(--ak-accent-2); border-width: 3px; border-color: var(--ak-ink); }

.swatch span {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid var(--ak-ink);
  box-sizing: border-box;
  display: grid;
  place-items: center;
}

.swatch.is-paper span { border-style: dashed; }

.swatch svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.swatch[aria-pressed="true"] span {
  width: 44px;
  height: 44px;
  border-width: 3px;
  outline: 3px solid var(--ak-accent-2);
  outline-offset: 1px;
}

.swatch[aria-pressed="true"] svg { opacity: 1; }

@container (min-width: 820px) {
  .pen-chip { display: none; }
  .palette,
  .palette.is-open {
    position: static;
    display: flex;
    gap: 6px;
    width: auto;
    padding: 0;
    background: none;
    rotate: 0deg;
  }
  .palette::after { display: none; }
  .sizes,
  .swatches { display: flex; gap: 2px; }
  .tools { gap: 10px; }
}

/* After the ring closes: the name bar in the tools' place. */
.name-bar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "label label" "input keep" "note note";
  gap: 4px 8px;
  padding: 8px 10px 6px;
  background: var(--ak-bg);
  border-radius: var(--wobble);
  transform-origin: 50% 100%;
}

.name-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2.5px solid var(--ak-accent);
  border-radius: inherit;
  translate: var(--reg) var(--reg);
  pointer-events: none;
}

.name-label {
  grid-area: label;
  color: var(--ak-ink);
  font-weight: 600;
  font-size: 15px;
}

.name-input {
  grid-area: input;
  min-width: 0;
  min-height: 50px;
  box-sizing: border-box;
  padding: 0 12px;
  border: 0;
  border-bottom: 3px solid var(--ak-accent);
  border-radius: 0;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: 19px;
  user-select: text;
  -webkit-user-select: text;
}

.name-input::placeholder { color: var(--ak-ink-muted); }

.keep-btn {
  grid-area: keep;
  position: relative;
  isolation: isolate;
  min-height: 50px;
  min-width: 96px;
  padding: 0 16px;
  border: 0;
  background: none;
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 15px;
}

.keep-btn::after,
.keep-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 4px 14px 5px 12px / 12px 4px 14px 5px;
}

.keep-btn::after { background: var(--ak-btn-fill); }
.keep-btn::before { background: var(--ak-accent-2); translate: var(--reg) var(--reg); }

.name-note:empty { display: none; }

.name-note {
  grid-area: note;
  margin: 0;
  color: var(--ak-ink);
  font-size: 14px;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: 12px;
  row-gap: 2px;
  margin-top: 4px;
}

.saveline {
  margin: 0;
  color: var(--ak-ink-muted);
  font-size: 12px;
  text-align: center;
  min-height: 1.2em;
}

/* The café card: seven stamp badges, each a different mark; earned ones are inked in sunflower. */
.card-row {
  display: flex;
  gap: 3px;
}

.card-badge {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px dotted var(--ak-ink-muted);
  color: var(--ak-ink-muted);
}

.card-badge svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-badge.is-earned {
  border: 1.5px solid var(--ak-ink);
  background: var(--ak-accent-2);
  color: var(--ak-ink);
}

/* ---------- Teaching: ring, arrow and caption, never on top of what they point at ---------- */

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

.guide-ring {
  position: absolute;
  border: 4px solid var(--ak-accent-2);
  outline: 3px solid var(--ak-accent);
  outline-offset: 2px;
  border-radius: 50%;
}

.guide-arrow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.guide-arrow path {
  fill: none;
  stroke: var(--ak-accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.guide-caption {
  position: absolute;
  box-sizing: border-box;
  max-width: min(330px, calc(100vw - 32px));
  margin: 0;
  padding: 10px 14px;
  background: var(--ak-accent);
  color: var(--ak-btn-ink);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  border-radius: var(--wobble-2);
}

/* ---------- Between stains: the full-screen poster flash ---------- */

.flash {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: grid;
  place-content: center;
  justify-items: center;
  overflow: hidden;
  background: var(--ak-accent);
  pointer-events: none;
}

.flash-word,
.flash-num {
  margin: 0;
  color: var(--ak-accent-2);
  font-family: var(--ak-font-display);
  line-height: 0.9;
}

.flash-word { font-size: min(14vw, 11vh); letter-spacing: 0.04em; text-transform: uppercase; }
.flash-num { font-size: min(70vw, 52vh); }

.flash-sub {
  margin: 2.5vh 0 0;
  padding: 8px 18px;
  max-width: 86vw;
  background: var(--ak-bg);
  color: var(--ak-accent);
  font-size: clamp(18px, 4.6vmin, 28px);
  font-weight: 600;
  text-align: center;
  rotate: -1.5deg;
}

.flash-sub:empty { display: none; }

.flash-special {
  margin: 1.6vh 0 0;
  padding: 6px 16px;
  max-width: 86vw;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  font-size: clamp(16px, 4vmin, 24px);
  font-weight: 600;
  text-align: center;
  rotate: 1deg;
}

.flash-special:empty { display: none; }

.flash-pal {
  position: absolute;
  right: 6vw;
  bottom: 5vh;
  width: min(30vw, 24vh);
}

/* ---------- The end of a sitting: five napkins pinned up like a print ---------- */

.wall {
  position: fixed;
  inset: 0;
  z-index: 31;
  overflow: hidden;
  background: var(--ak-accent);
  display: grid;
  place-items: center;
}

.wall-num {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  color: var(--ak-accent-2);
  font-family: var(--ak-font-display);
  font-size: min(110vw, 92vh);
  line-height: 1;
}

.wall-why {
  position: absolute;
  z-index: 2;
  top: max(18px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  max-width: calc(100vw - 110px);
  margin: 0;
  padding: 8px 16px;
  background: var(--ak-bg);
  color: var(--ak-accent);
  font-family: var(--ak-font-display);
  font-size: clamp(16px, 3.4vmin, 26px);
  line-height: 1.2;
  rotate: -1.5deg;
}

.wall-ring {
  position: absolute;
  left: -8vmin;
  top: -6vmin;
  width: 40vmin;
  opacity: 0.9;
}

.wall-tiles {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3vmin;
  width: min(94vw, 112dvh - 40px);
  padding: 4vmin;
  padding-top: max(4vmin, 64px);
  box-sizing: border-box;
}

.wall-tile {
  position: relative;
  grid-column: span 2;
  margin: 0;
  aspect-ratio: 377 / 384;
}

.wall-tile:nth-child(4) { grid-column: 2 / span 2; }
.wall-tile:nth-child(odd) { rotate: -3deg; }
.wall-tile:nth-child(even) { rotate: 2.5deg; translate: 0 2vmin; }

.wall-tile img,
.reel-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.wall-tile canvas,
.reel-tile canvas {
  position: absolute;
  left: 15%;
  top: 13%;
  width: 70%;
  height: 62%;
}

.wall-tile figcaption {
  position: absolute;
  left: 50%;
  top: 98%;
  translate: -50% 0;
  max-width: 110%;
  padding: 2px 8px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-weight: 600;
  font-size: clamp(11px, 1.8vmin, 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wall-pal {
  position: absolute;
  right: 3vmin;
  bottom: 2vmin;
  width: 24vmin;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 31;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -40px;
  display: block;
}

/* ---------- In-page asks: clear and delete, never a browser dialog ---------- */

.ask {
  position: fixed;
  inset: 0;
  z-index: 37;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--ak-accent) 82%, var(--ak-ink));
}

.ask-note {
  position: relative;
  max-width: 340px;
  padding: 28px 22px 20px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  border-radius: var(--wobble);
  rotate: -1.5deg;
}

.ask-note::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  width: 90px;
  height: 24px;
  translate: -50% 0;
  rotate: 3deg;
  background: var(--tape);
}

.ask-title {
  margin: 0 0 6px;
  color: var(--ak-accent);
  font-family: var(--ak-font-display);
  font-size: 22px;
  line-height: 1.15;
}

.ask-body {
  margin: 0 0 18px;
  font-size: 17px;
  line-height: 1.4;
}

.ask-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ask-yes,
.ask-no {
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  font-weight: 600;
  font-size: 16px;
  border-radius: 4px 14px 5px 12px / 12px 4px 14px 5px;
}

.ask-yes { background: var(--ak-btn-fill); color: var(--ak-btn-ink); }
.ask-no { background: var(--ak-choice-bg); color: var(--ak-choice-ink); outline: 2.5px solid var(--ak-choice-border); outline-offset: -2.5px; }

/* ---------- The reel: kept doodles on napkin tiles ---------- */

.reel {
  position: fixed;
  inset: 0;
  z-index: 37;
  overflow-y: auto;
  background: var(--ak-accent);
  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));
  box-sizing: border-box;
}

.reel-board,
.reel-open {
  max-width: 820px;
  margin: 0 auto;
}

.reel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 64px;
}

.reel-title {
  margin: 0;
  color: var(--ak-accent-2);
  font-family: var(--ak-font-display);
  font-size: clamp(24px, 7vw, 40px);
  line-height: 1;
}

.reel-close,
.reel-back,
.reel-delete,
.reel-rename button {
  min-height: 50px;
  padding: 0 16px;
  border: 0;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-weight: 600;
  font-size: 16px;
  border-radius: 4px 14px 5px 12px / 12px 4px 14px 5px;
}

.reel-where {
  margin: 10px 0 16px;
  color: var(--ak-btn-ink);
  font-size: 14px;
}

.reel-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 26px 18px;
  padding-bottom: 24px;
}

.reel-tile {
  position: relative;
  aspect-ratio: 377 / 384;
  margin-bottom: 22px;
  padding: 0;
  border: 0;
  background: none;
}

.reel-tile:nth-child(odd) { rotate: -2deg; }
.reel-tile:nth-child(even) { rotate: 1.6deg; }

.reel-tile .tile-name {
  position: absolute;
  left: 50%;
  top: 100%;
  translate: -50% 4px;
  max-width: 100%;
  padding: 3px 8px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reel-empty {
  color: var(--ak-btn-ink);
  font-size: 18px;
}

.reel-open {
  display: grid;
  gap: 12px;
  justify-items: center;
  padding-top: 8px;
}

.reel-big {
  position: relative;
  width: min(84vw, 52vh, 420px);
  aspect-ratio: 377 / 384;
  margin: 0;
}

.reel-big img { position: absolute; inset: 0; width: 100%; height: 100%; }
.reel-big canvas { position: absolute; left: 15%; top: 13%; width: 70%; height: 62%; }

.reel-rename {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(100%, 460px);
  padding: 10px 12px;
  background: var(--ak-bg);
  border-radius: var(--wobble);
  box-sizing: border-box;
}

.reel-rename label { font-weight: 600; }

.reel-rename input {
  flex: 1 1 160px;
  min-height: 48px;
  padding: 0 10px;
  border: 0;
  border-bottom: 3px solid var(--ak-accent);
  background: var(--ak-surface);
  font-size: 18px;
}

.reel-rename button { background: var(--ak-btn-fill); color: var(--ak-btn-ink); }

.reel-day,
.reel-msg {
  margin: 0;
  color: var(--ak-btn-ink);
  font-size: 15px;
  min-height: 1.2em;
}

.reel-actions {
  display: flex;
  gap: 12px;
}

.reel-delete { background: var(--ak-accent-2); }

.reel-confirm {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: var(--ak-bg);
  border-radius: var(--wobble-2);
}

.reel-confirm p { margin: 0; width: 100%; text-align: center; font-weight: 600; font-size: 17px; }

/* ---------- Short portrait phones: the corner goes into one row ---------- */

@media (orientation: portrait) and (max-height: 720px) {
  .corner {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-template-areas: none;
    align-items: center;
  }
  .corner .clock,
  .corner .hint,
  .corner .reel-btn { grid-area: auto; }
  .corner:not(:has(.hint:not([hidden]))) { grid-template-areas: none; }
  .clock { width: 52px; height: 52px; }
  .corner-chip { width: 52px; min-height: 50px; }
  .strip { min-height: clamp(64px, 11dvh, 96px); }
  .numeral { font-size: min(28dvh, calc((100dvw - 196px) * 1.2)); }
  .chip { min-height: 54px; }
  .nudge { font-size: 15px; }
  .how { font-size: 15px; }
  .question { font-size: 18px; }
  .nudge:empty { display: none; }
}

/* ---------- Landscape: board on one side, status and tools on the other ---------- */

@media (orientation: landscape) {
  .play {
    max-width: 1280px;
    --side-w: clamp(230px, 34vw, 400px);
    grid-template-columns: var(--side-w) 78px minmax(0, 1fr) var(--gutter-w);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      "strip toolbar sheet corner"
      "question toolbar sheet corner"
      ". toolbar sheet corner"
      "dock toolbar sheet corner";
    column-gap: 12px;
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .strip {
    margin-top: var(--ac-status-h, 64px);
    min-height: clamp(56px, 20dvh, 200px);
  }

  .numeral {
    left: auto;
    right: -0.2em;
    font-size: min(34dvh, 22dvw);
  }

  .numeral span { left: auto; right: 0; bottom: -0.2em; }

  .corner {
    grid-template-columns: 58px;
    grid-template-areas: none;
    grid-auto-flow: row;
    align-content: start;
    justify-content: center;
    justify-items: center;
    padding-top: 70px;
    gap: 10px;
  }

  .corner .clock,
  .corner .hint,
  .corner .reel-btn { grid-area: auto; }
  .corner:not(:has(.hint:not([hidden]))) { grid-template-areas: none; }

  .question-strip { margin: 0 0 8px; }
  .question { font-size: clamp(17px, 2.4dvw, 22px); }

  .sheet-wrap { align-self: stretch; justify-items: start; }

  /* The tools stand in their own column beside the sheet: still one row along one edge, with room. */
  .toolbar {
    display: flex;
    align-items: center;
    padding-top: 0;
  }

  .tools {
    flex-direction: column;
    width: 100%;
    gap: 8px;
    transform-origin: 50% 50%;
  }

  .chip {
    flex: 0 0 auto;
    width: 76px;
    max-width: none;
    min-height: 62px;
    font-size: 13px;
  }

  .palette {
    left: calc(100% + 12px);
    bottom: auto;
    top: 0;
    width: 260px;
  }

  .corner .clock { margin-bottom: 14px; }
  .how { font-size: 15px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .strip { min-height: 40px; }
  .numeral { font-size: min(36dvh, 20dvw); }
  .nudge { font-size: 15px; }
  .chip { min-height: 58px; font-size: 13px; }
  .tools { gap: 6px; }
  .saveline { margin-top: 2px; }
  .corner { padding-top: 66px; gap: 6px; }
  .corner .clock { margin-bottom: 16px; }
  .clock { width: 52px; height: 52px; }
  .corner-chip { min-height: 50px; }
  .question-strip { padding: 5px 10px 4px; }
  .question { font-size: 16px; }
  .how { font-size: 14px; }
  .logo { height: 28px; }
  .next-btn { min-height: 52px; font-size: 15px; }
  .name-bar { grid-template-areas: "input keep" "note note"; padding: 6px 8px; }
  .name-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .name-input { font-size: 17px; }
  .keep-btn { min-width: 84px; padding: 0 10px; font-size: 14px; }
}

/* The status bar keeps to the side column when the phone lies down, so the sheet gets the full height. */
@media (orientation: landscape) {
  html body #activity-chrome-status {
    right: auto;
    max-width: calc(var(--side-w) - 4px);
  }
}

@media (orientation: landscape) and (min-width: 1300px) {
  html body #activity-chrome-status { left: max(12px, calc(50vw - 640px + 12px)); }
}

/* ---------- Motion, only when it is welcome ---------- */

@media (hover: hover) {
  .chip:hover:not([aria-disabled="true"]),
  .corner-chip:hover,
  .clock:hover:not([aria-disabled="true"]) { translate: 0 -2px; }
  .chip:hover::before,
  .corner-chip:hover::before { translate: calc(var(--reg) + 1px) calc(var(--reg) + 2px); }
}

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .chip,
  :root:not(.ac-still) .corner-chip,
  :root:not(.ac-still) .clock,
  :root:not(.ac-still) .size-dot,
  :root:not(.ac-still) .swatch { transition: translate 160ms var(--ease-out); }

  :root:not(.ac-still) .chip::before,
  :root:not(.ac-still) .corner-chip::before { transition: translate 160ms var(--ease-out); }

  :root:not(.ac-still) .is-tapped { animation: chip-wobble 380ms var(--spring); }
  :root:not(.ac-still) .is-tapped::before { animation: chip-lift 380ms var(--ease-out); }

  :root:not(.ac-still) .numeral-y { animation: off-register 6.5s ease-in-out infinite alternate; }

  :root:not(.ac-still) .clock.is-last-call { animation: last-call 1s var(--spring) infinite; }

  :root:not(.ac-still) .guide-ring { animation: guide-pulse 1.3s ease-in-out infinite; }
  :root:not(.ac-still) .guide-caption { animation: caption-in 360ms var(--spring) both; }

  :root:not(.ac-still) .palette.is-open { animation: tray-in 260ms var(--spring) both; }

  :root:not(.ac-still) .tools.is-folding { animation: napkin-fold 420ms cubic-bezier(0.5, 0, 0.75, 0) both; }
  :root:not(.ac-still) .name-bar.is-unfolding { animation: napkin-unfold 460ms var(--spring) both; }
  :root:not(.ac-still) .tools.is-unfolding { animation: napkin-unfold 460ms var(--spring) both; }

  :root:not(.ac-still) .stamp.is-stamping { animation: stamp-down 520ms cubic-bezier(0.5, 0, 0.6, 1.4) both; }
  :root:not(.ac-still) .pal.is-hopping { animation: pal-hop 900ms var(--spring) both; }

  :root:not(.ac-still) .flash.is-in { animation: flash-in 1150ms var(--ease-out) both; }
  :root:not(.ac-still) .flash.is-in .flash-num { animation: flash-num 1150ms var(--spring) both; }
  :root:not(.ac-still) .flash.is-in .flash-sub {
  margin: 2.5vh 0 0;
  padding: 8px 18px;
  max-width: 86vw;
  background: var(--ak-bg);
  color: var(--ak-accent);
  font-size: clamp(18px, 4.6vmin, 28px);
  font-weight: 600;
  text-align: center;
  rotate: -1.5deg;
}

.flash-sub:empty { display: none; }

.flash-special {
  margin: 1.6vh 0 0;
  padding: 6px 16px;
  max-width: 86vw;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  font-size: clamp(16px, 4vmin, 24px);
  font-weight: 600;
  text-align: center;
  rotate: 1deg;
}

.flash-special:empty { display: none; }

.flash-pal { animation: pal-pop 1150ms var(--spring) both; }

  :root:not(.ac-still) .wall.is-in { animation: wall-in 520ms var(--ease-out) both; }
  :root:not(.ac-still) .wall.is-in .wall-num { animation: wall-num 900ms var(--spring) both; }
  :root:not(.ac-still) .wall.is-in .wall-tile { animation: pin-up 560ms var(--spring) both; animation-delay: calc(240ms + var(--i) * 140ms); }
  :root:not(.ac-still) .wall.is-in .wall-pal { animation: pal-pop 900ms var(--spring) 900ms both, pal-bob 2.4s ease-in-out 1.8s infinite alternate; }

  :root:not(.ac-still) .nudge.is-new { animation: nudge-in 600ms var(--ease-out) both; }
}

@keyframes chip-wobble {
  0% { scale: 1; rotate: 0deg; }
  30% { scale: 1.08 0.9; rotate: -5deg; }
  60% { scale: 0.96 1.05; rotate: 3deg; }
  100% { scale: 1; rotate: 0deg; }
}

@keyframes chip-lift {
  0%, 100% { translate: var(--reg) var(--reg); }
  40% { translate: calc(var(--reg) + 4px) calc(var(--reg) + 4px); }
}

@keyframes off-register {
  0% { translate: 0.035em 0.025em; }
  100% { translate: 0.05em 0.012em; }
}

@keyframes last-call {
  0%, 100% { scale: 1; background: var(--ak-surface); }
  35% { scale: 1.14; background: var(--ak-accent-2); }
}

@keyframes guide-pulse {
  0%, 100% { scale: 1; opacity: 1; }
  50% { scale: 1.08; opacity: 0.75; }
}

@keyframes caption-in {
  from { opacity: 0; translate: 0 8px; }
  to { opacity: 1; translate: 0 0; }
}

@keyframes tray-in {
  from { opacity: 0; scale: 0.9 0.6; translate: 0 12px; }
  to { opacity: 1; scale: 1; translate: 0 0; }
}

@keyframes napkin-fold {
  0% { scale: 1 1; }
  45% { scale: 1.02 0.5; }
  100% { scale: 0.96 0; opacity: 0.4; }
}

@keyframes napkin-unfold {
  0% { scale: 0.96 0; }
  60% { scale: 1.01 1.08; }
  100% { scale: 1 1; }
}

@keyframes stamp-down {
  0% { scale: 1.5; opacity: 0; rotate: -10deg; }
  60% { scale: 0.94 0.9; opacity: 1; rotate: -3deg; }
  80% { scale: 1.03 1.05; }
  100% { scale: 1; rotate: -3deg; }
}

@keyframes pal-hop {
  0% { translate: 0 60%; opacity: 0; }
  35% { translate: 0 -28%; opacity: 1; scale: 0.92 1.08; }
  60% { translate: 0 0; scale: 1.1 0.88; }
  80% { translate: 0 -8%; scale: 0.98 1.02; }
  100% { translate: 0 0; scale: 1; }
}

@keyframes flash-in {
  0% { opacity: 0; clip-path: circle(0% at 50% 50%); }
  22% { opacity: 1; clip-path: circle(80% at 50% 50%); }
  80% { opacity: 1; clip-path: circle(80% at 50% 50%); }
  100% { opacity: 0; clip-path: circle(80% at 50% 50%); }
}

@keyframes flash-num {
  0% { scale: 0.3; rotate: -12deg; }
  35% { scale: 1.08 0.92; rotate: 2deg; }
  55% { scale: 0.97 1.03; rotate: 0deg; }
  100% { scale: 1; }
}

@keyframes pal-pop {
  0% { translate: 0 120%; }
  40% { translate: 0 -12%; }
  65% { translate: 0 4%; }
  100% { translate: 0 0; }
}

@keyframes pal-bob {
  from { translate: 0 0; rotate: -2deg; }
  to { translate: 0 -6px; rotate: 2deg; }
}

@keyframes wall-in {
  from { clip-path: inset(100% 0 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

@keyframes wall-num {
  0% { scale: 0.4 1.6; }
  55% { scale: 1.06 0.94; }
  100% { scale: 1; }
}

@keyframes pin-up {
  0% { scale: 1.4; opacity: 0; }
  70% { scale: 0.95; opacity: 1; }
  100% { scale: 1; }
}

@keyframes nudge-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- The start screen's reel: kept doodles on napkin tiles, under the brief ---------- */

#activity-start .start-reel {
  margin: 32px auto 8px;
  text-align: center;
}

#activity-start .start-reel-title {
  margin: 0 0 14px;
  color: var(--ak-accent);
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: var(--ak-title-weight, 400);
}

#activity-start .start-reel-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 30px 14px;
}

#activity-start .start-reel-tile {
  position: relative;
  margin: 0;
  aspect-ratio: 377 / 384;
}

#activity-start .start-reel-tile:nth-child(odd) { rotate: -2deg; }
#activity-start .start-reel-tile:nth-child(even) { rotate: 1.5deg; }

#activity-start .start-reel-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#activity-start .start-reel-tile canvas {
  position: absolute;
  left: 15%;
  top: 13%;
  width: 70%;
  height: 62%;
}

#activity-start .start-reel-tile figcaption {
  position: absolute;
  left: 50%;
  top: 100%;
  translate: -50% 3px;
  max-width: 110%;
  padding: 2px 8px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#activity-start .start-reel-card {
  margin: 40px auto 0;
  max-width: 34ch;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 16px;
  line-height: 1.4;
}

#activity-start .start-reel-where {
  margin: 10px 0 0;
  color: var(--ak-ink-muted);
  font-family: var(--ak-font-body);
  font-size: 13px;
}

/* ---------- The pinned print, fitted: its next step always on screen ---------- */

/* A tall card scrolls from its top instead of losing it. */
html body #activity-chrome-ending { justify-content: safe center; }

@media (orientation: portrait) {
  html body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: 34dvh; width: auto; }
  html body #activity-chrome-ending.site-inspicacity { padding-top: 20px; padding-bottom: 20px; }
  html body #activity-chrome-ending.site-inspicacity .ac-card { padding-top: 26px; gap: 8px; }
  html body #activity-chrome-ending.site-inspicacity .ac-lines { font-size: 15px; }
}

/* Sideways on a phone: the words and the button on the left, the print beside them. */
@media (orientation: landscape) and (max-height: 560px) {
  html body #activity-chrome-ending.site-inspicacity { padding: 14px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left)); }
  html body #activity-chrome-ending.site-inspicacity .ac-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "number work" "verdict work" "lines work" "actions work";
    align-content: center;
    align-items: center;
    column-gap: 24px;
    row-gap: 6px;
    width: min(100%, 880px);
    padding: 16px 22px 14px;
  }
  html body #activity-chrome-ending.site-inspicacity .ac-rule,
  html body #activity-chrome-ending.site-inspicacity .ac-fill { display: none; }
  html body #activity-chrome-ending.site-inspicacity .ac-number { grid-area: number; }
  html body #activity-chrome-ending.site-inspicacity .ac-verdict { grid-area: verdict; font-size: clamp(18px, 3vw, 26px); }
  html body #activity-chrome-ending.site-inspicacity .ac-lines { grid-area: lines; font-size: 14px; line-height: 1.35; }
  html body #activity-chrome-ending.site-inspicacity .ac-actions { grid-area: actions; }
  html body #activity-chrome-ending.site-inspicacity .ac-work { grid-area: work; }
  html body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: calc(100dvh - 110px); width: auto; }
}

@media (orientation: portrait) and (max-height: 720px) {
  html body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: 22dvh; }
  html body #activity-chrome-ending.site-inspicacity .ac-verdict { font-size: 20px; }
  html body #activity-chrome-ending.site-inspicacity .ac-number { font-size: 15px; }
  html body #activity-chrome-ending.site-inspicacity .ac-lines { font-size: 14px; line-height: 1.35; }
  html body #activity-chrome-ending.site-inspicacity .ac-card { padding: 22px 16px 14px; gap: 6px; }
}

/* ---------- The table under the paper: a riso-blue field, so the sheet's edge is plain to see ---------- */

.sheet {
  outline: 3px solid var(--ak-accent);
  outline-offset: 0;
}

.sheet-wrap::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(min(100cqw, 100cqh * 5 / 6, 100dvw - 24px) + 28px);
  aspect-ratio: 5 / 6;
  translate: -50% -50%;
  background-color: color-mix(in srgb, var(--ak-accent) 22%, var(--ak-bg));
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
  border-radius: 10px 4px 12px 5px / 5px 11px 4px 10px;
  pointer-events: none;
}

@media (orientation: landscape) {
  /* A strip of table on the tool side, so a drag that starts just off the paper still lands on it. */
  .sheet-wrap { padding-left: 18px; }
  .sheet-wrap::before { left: calc(18px + min(100cqw, 100cqh * 5 / 6, 100dvw - 24px) / 2); max-height: 100%; }
}

@keyframes badge-stamp {
  0% { scale: 2.2; rotate: -18deg; opacity: 0; }
  55% { scale: 0.85 1.1; rotate: 4deg; opacity: 1; }
  100% { scale: 1; rotate: 0deg; }
}

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .card-badge.is-new { animation: badge-stamp 620ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
}

/* Short screens on their side: the side column must hold the prompt and the name field whole. */
@media (orientation: landscape) and (max-height: 500px) {
  .strip { min-height: 22px; }
  .how { font-size: 15px; }
  .special { font-size: 14px; }
  .question-strip { margin-bottom: 8px; }
  .dock > .name-bar,
  .dock > .next-bar { margin-top: 4px; }
  .name-input { min-height: 48px; }
  .keep-btn { min-height: 48px; }
  .chip { min-height: 50px; }
  .tools { gap: 5px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .strip { min-height: 0; }
  .play.is-resting .saveline { display: none; }
  .question { font-size: 17px; }
  /* Never taller than the screen: the side stays inside it rather than stretching the tool column. */
  .play { grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; }
}

/* Short portrait phones: the prompt band and the tools give room back so the sheet stays the biggest thing. */
@media (orientation: portrait) and (max-height: 720px) {
  .question-strip { padding: 6px 12px; margin-bottom: 7px; }
  .logo { height: 24px; }
  .question { font-size: 17px; }
  .how { font-size: 15px; margin-top: 2px; }
  .special { font-size: 14px; padding: 2px 8px; margin-top: 4px; }
  .chip { min-height: 50px; gap: 1px; }
  .toolbar { padding-top: 6px; }
  .card-badge { width: 18px; height: 18px; }
  .card-badge svg { width: 12px; height: 12px; }
  .card-row { gap: 2px; }
  .saveline { font-size: 11px; }
  .foot { margin-top: 2px; }
}

/* No empty row held for a nudge: it takes its line only once there is one. */
.question-strip .nudge:empty { display: none; }

/* ---------- Drawing feedback: a brush-sized ring under the mouse, a quick ring where a finger lands ---------- */

.brush {
  position: absolute;
  z-index: 4;
  box-sizing: border-box;
  border: 2px solid var(--brush-ink, var(--ak-ink));
  border-radius: 50%;
  translate: -50% -50%;
  pointer-events: none;
}

.brush::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 1.5px solid var(--ak-surface);
  border-radius: 50%;
}

.brush.is-eraser { border-style: dashed; }

.touch-ring {
  position: absolute;
  z-index: 4;
  width: 36px;
  height: 36px;
  border: 3px solid var(--brush-ink, var(--ak-ink));
  border-radius: 50%;
  translate: -50% -50%;
  pointer-events: none;
  opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .touch-ring { animation: touch-ring 520ms ease-out both; }
}

@keyframes touch-ring {
  0% { scale: 0.3; opacity: 0.9; }
  100% { scale: 1.6; opacity: 0; }
}

/* ---------- Done in the corner (sideways only), beside the timer that also finishes ---------- */

.done-corner { display: none; color: var(--ak-ink); }
.done-corner::after { background: var(--ak-accent-2); border: 3px solid var(--ak-ink); border-radius: 4px 14px 4px 14px; }
.done-corner::before { background: var(--ak-accent); border-radius: 4px 14px 4px 14px; }
.done-corner svg { stroke-width: 4; }

/* ---------- The poster band between stains: only around the sheet, never over it ---------- */

.flash {
  inset: auto;
  container-type: size;
  align-content: center;
  gap: 0;
  padding: 8px 12px;
  box-sizing: border-box;
}

.flash-word { font-size: min(13cqh, 12cqw); }
.flash-num { font-size: min(46cqh, 48cqw); }
.flash-sub { margin-top: 1cqh; font-size: clamp(13px, min(7cqh, 6cqw), 24px); padding: 4px 12px; }
.flash-special { margin-top: 1cqh; font-size: clamp(13px, min(6.5cqh, 5.6cqw), 22px); padding: 4px 12px; }
.flash-pal { right: 3cqw; bottom: 3cqh; width: min(26cqh, 20cqw); }

/* ---------- Sideways: the side column holds only words; the numeral tucks under the sheet's far edge ---------- */

@media (orientation: landscape) {
  .play {
    --side-w: clamp(210px, 32vw, 400px);
    grid-template-columns: var(--side-w) 90px minmax(0, 1fr) var(--gutter-w);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "question toolbar sheet corner"
      ". toolbar sheet corner"
      "dock toolbar sheet corner";
    column-gap: 16px;
  }

  .strip {
    grid-area: sheet;
    align-self: stretch;
    margin-top: 0;
    min-height: 0;
    overflow: hidden;
    pointer-events: none;
  }

  .numeral {
    left: auto;
    right: 0;
    bottom: 0;
    font-size: min(80dvh, 34dvw);
  }

  .numeral span { left: auto; right: -0.02em; bottom: -0.1em; }

  .question-strip { margin-top: var(--ac-status-h, 64px); }

  /* Five big tool chips in their column, with clear air between them and the paper. */
  .done-chip { display: none; }
  .done-corner { display: flex; }

  .chip {
    width: 88px;
    min-height: 60px;
    font-size: 14px;
  }

  .chip svg { width: 30px; height: 26px; }
  .tools { gap: 9px; }
  .pen-dot { --dot: 24px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .chip { min-height: 58px; font-size: 14px; }
  .tools { gap: 8px; }
  .corner .clock { margin-bottom: 14px; }
  .corner { gap: 6px; }
  .question { font-size: 17px; }
  .how { font-size: 15px; }
}

.flash-pal { left: 3cqw; right: auto; top: 3cqh; bottom: auto; width: min(24cqh, 15cqw); }

@media (orientation: landscape) {
  /* The numeral spans the sheet's height only, so nothing peeks out above or below the paper. */
  .strip { align-self: center; height: var(--sheet-h, 100%); }
  .numeral { font-size: calc(var(--sheet-h, 300px) * 1.15); }
  .numeral span { bottom: -0.12em; }
  .play.no-numeral .strip { visibility: hidden; }
}

/* ======================================================================================
   Craft pass: the opening scene in focus, a smaller numeral, a slim note, the gap tag.
   ====================================================================================== */

/* ---------- The opening scene: a taped note, a strong button, a finished doodle beside it ---------- */

html body #activity-start.is-scene .ak-scene {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "preview" "lines" "actions";
  justify-items: center;
  align-content: center;
  gap: 18px;
  width: min(100%, 1000px);
}

html body #activity-start.is-scene .ak-head { grid-area: head; }
html body #activity-start.is-scene .ak-head .ak-logo { max-height: 96px; }
html body #activity-start.is-scene .ak-scene-actions { grid-area: actions; gap: 10px; }

/* The opening lines as one taped note on the table, not loose words on an empty page. */
html body #activity-start.is-scene .ak-scene-lines {
  grid-area: lines;
  position: relative;
  gap: 10px;
  max-width: 34ch;
  padding: 26px 22px 20px;
  background: var(--ak-surface);
  border: 2px solid var(--ak-ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  rotate: -1deg;
}

html body #activity-start.is-scene .ak-scene-lines::before {
  content: '';
  position: absolute;
  top: -12px;
  left: 50%;
  width: 96px;
  height: 24px;
  translate: -50% 0;
  rotate: 3deg;
  background: var(--tape);
}

html body #activity-start.is-scene .ak-scene-line {
  font-size: clamp(17px, 2.2vw, 24px);
  line-height: 1.3;
  color: var(--ak-ink);
}

html body #activity-start.is-scene .ak-scene .ak-go {
  min-height: 60px;
  padding: 0 32px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-size: 20px;
}

html body #activity-start.is-scene .ak-jump {
  min-height: 48px;
  color: var(--ak-ink);
  font-size: 17px;
  font-weight: 600;
}

/* A finished doodle on its napkin: what the page will ask of you, shown before you start. */
.scene-preview {
  grid-area: preview;
  position: relative;
  width: min(44vw, 22dvh, 260px);
  aspect-ratio: 377 / 384;
  margin: 0 0 22px;
  rotate: 3deg;
}

.scene-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-preview canvas {
  position: absolute;
  left: 15%;
  top: 13%;
  width: 70%;
  height: 62%;
}

.scene-preview figcaption {
  position: absolute;
  left: 50%;
  top: 100%;
  translate: -50% 4px;
  padding: 2px 10px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  rotate: -2deg;
}

@media (min-width: 760px) and (min-aspect-ratio: 1/1) {
  html body #activity-start.is-scene .ak-scene {
    grid-template-columns: minmax(0, 1fr) minmax(240px, 0.8fr);
    grid-template-areas: "head preview" "lines preview" "actions preview";
    column-gap: 56px;
    align-items: center;
  }
  .scene-preview { width: min(34vw, 60dvh, 400px); margin: 0; }
}

@media (orientation: landscape) and (max-height: 500px) {
  html body #activity-start.is-scene .ak-scene {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "head preview" "lines preview" "actions preview";
    column-gap: 28px;
    gap: 10px;
    min-height: 0;
  }
  html body #activity-start.is-scene .ak-head .ak-logo { max-height: 52px; }
  html body #activity-start.is-scene .ak-scene-lines { padding: 16px 16px 12px; gap: 6px; }
  html body #activity-start.is-scene .ak-scene-line { font-size: 15px; }
  html body #activity-start.is-scene .ak-scene .ak-go { min-height: 52px; font-size: 17px; }
  .scene-preview { width: min(30vw, 62dvh); margin: 0; }
}

@media (orientation: portrait) and (max-height: 740px) {
  html body #activity-start.is-scene .ak-scene { gap: 12px; }
  html body #activity-start.is-scene .ak-head .ak-logo { max-height: 64px; }
  html body #activity-start.is-scene .ak-scene-line { font-size: 15px; }
  .scene-preview { width: min(40vw, 18dvh); }
}

/* ---------- The play screen: a smaller numeral and a slim note at the edge ---------- */

.strip { min-height: clamp(52px, 8.5dvh, 86px); }
.numeral { font-size: min(21dvh, calc((100dvw - 150px) * 0.9)); }
.numeral span { bottom: -0.3em; }

.question-strip {
  margin-bottom: 6px;
  padding: 5px 12px 6px;
  column-gap: 8px;
  rotate: -0.5deg;
}

.question-strip::after { height: 3px; bottom: -3px; }
.logo { height: 26px; }
.question { font-size: 18px; }
.how { margin-top: 1px; font-size: 15px; font-weight: 500; }
.special { margin-top: 3px; padding: 1px 8px; font-size: 14px; border-left-width: 4px; }

@media (orientation: portrait) and (max-height: 720px) {
  .strip { min-height: 46px; }
  .numeral { font-size: min(17dvh, calc((100dvw - 196px) * 0.9)); }
}

@media (orientation: landscape) {
  .numeral { font-size: calc(var(--sheet-h, 300px) * 0.55); }
  .question-strip { margin-top: var(--ac-status-h, 64px); }
}

/* ---------- The gap tag: the one hint the rings themselves give ---------- */

.gap-tag {
  position: absolute;
  z-index: 4;
  max-width: 13em;
  margin: 0;
  padding: 5px 10px;
  background: var(--ak-bg);
  border: 2px solid var(--ak-accent);
  border-radius: 4px 12px 5px 10px / 10px 4px 12px 5px;
  color: var(--ak-ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  pointer-events: none;
  rotate: -1.5deg;
}

.gap-tick {
  position: absolute;
  height: 0;
  border-top: 2.5px dashed var(--ak-accent);
  transform-origin: 0 50%;
}

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .gap-tag:not([hidden]) { animation: gap-in 420ms cubic-bezier(0.34, 1.56, 0.64, 1) both; }
}

@keyframes gap-in {
  from { opacity: 0; scale: 0.85; }
  to { opacity: 1; scale: 1; }
}

/* ---------- The final wall: why it ended, and a line about the last doodle ---------- */

.wall-why {
  display: grid;
  gap: 4px;
  max-width: min(560px, calc(100vw - 110px));
  white-space: normal;
}

.wall-why strong { font-weight: inherit; }

.wall-why span {
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: clamp(14px, 2.2vmin, 17px);
  font-weight: 500;
  line-height: 1.35;
}

.wall .confetti { z-index: 1; }
.wall-why { z-index: 3; }

@media (orientation: portrait) {
  .wall-tiles {
    grid-template-columns: repeat(4, 1fr);
    width: min(94vw, 62dvh);
    padding-top: max(13vh, 110px);
    row-gap: 7vmin;
  }
  .wall-tile:nth-child(4) { grid-column: auto / span 2; }
  .wall-tile:nth-child(5) { grid-column: 2 / span 2; }
}

/* The five land inside the first second, so the reason beat shows them all pinned. */
@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .wall.is-in .wall-tile { animation: pin-up 400ms var(--spring) both; animation-delay: calc(80ms + var(--i) * 90ms); }
}

html body #activity-start.is-scene .ak-scene .ak-go { margin: 0; }

@media (orientation: landscape) and (max-height: 500px) {
  html body #activity-start.is-scene { padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
  html body #activity-start.is-scene .ak-scene { min-height: calc(100dvh - 24px); row-gap: 14px; }
  html body #activity-start.is-scene .ak-head .ak-logo { max-height: 44px; }
  html body #activity-start.is-scene .ak-scene-actions { gap: 2px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  html body #activity-start.is-scene .ak-scene-actions { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 14px; }
  html body #activity-start.is-scene .ak-scene .ak-go { margin: 0; min-height: 52px; }
  html body #activity-start.is-scene .ak-jump { margin: 0; }
}

@media (orientation: landscape) and (max-height: 500px) {
  html body #activity-start#activity-start.is-scene .ak-scene .ak-go { margin: 0; order: 0; min-height: 50px; padding: 0 22px; font-size: 16px; }
  html body #activity-start#activity-start.is-scene .ak-jump { order: 1; }
}

@media (orientation: landscape) and (max-height: 500px) {
  .gap-tag { font-size: 13px; max-width: 10em; padding: 3px 8px; }
}

/* Sized from the sheet, so it can always find clear paper beside the rings. */
.gap-tag {
  max-width: calc(var(--sw, 300px) * 0.36);
  font-size: clamp(12px, calc(var(--sw, 300px) * 0.04), 16px);
  padding: 3px 7px;
}
@media (orientation: landscape) and (max-height: 500px) {
  .gap-tag { font-size: 12px; max-width: calc(var(--sw, 300px) * 0.36); padding: 3px 7px; }
}

@media (orientation: portrait) {
  .wall-tiles {
    padding-top: calc(var(--why-h, 120px) + 14px);
    width: min(94vw, calc((100dvh - var(--why-h, 120px) - 40px) * 0.62));
  }
}
@media (orientation: landscape) {
  .wall-tiles { padding-top: calc(var(--why-h, 90px) + 6px); width: min(94vw, calc((100dvh - var(--why-h, 90px) - 20px) * 1.7)); }
}

@media (orientation: landscape) {
  .wall-tiles { width: min(94vw, calc((100dvh - var(--why-h, 90px) - 30px) * 1.15)); padding-bottom: 8px; }
}
