/* Tape Line Faces: studio kit cut into comic panels. White gesso panels with thick hand-cut charcoal
   borders, gutters of washed cobalt wall between them, cadmium caption boxes, white word bubbles,
   tools as paper chips along the bottom gutter. Kit colours and fonts only. */

:root {
  --gutter: 10px;
  --line: 3px;
  --cut: 3px 10px 4px 12px / 11px 4px 10px 3px;
  --cut-b: 9px 3px 12px 4px / 4px 12px 3px 9px;
  /* One scale for the whole tool row: the chips, their art and the row's height grow together on
     screens with room to spare (see the landscape rules). */
  --k: 1;
  --chip-h: calc(64px * var(--k));
  --tools-h: calc(76px * var(--k));
  --tape-ink: color-mix(in srgb, var(--ak-accent) 24%, var(--ak-surface));
  --paper-tooth: color-mix(in srgb, var(--ak-outline) 55%, transparent);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

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

button { font: inherit; color: inherit; }

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

[hidden] { display: none !important; }

/* Nothing of the play screen shows until the start screen hands over; meanwhile the page is
   already the sketchbook's graph paper, never a blank sheet. */
body.tlf-waiting .play { visibility: hidden; }

body.tlf-waiting {
  background-image:
    linear-gradient(color-mix(in srgb, var(--ak-outline) 45%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ak-outline) 45%, transparent) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* The start screen's graph paper sits under the washed wall picture; lay the grid on top of the
   wash so the sketchbook opening reads as graph paper, as the site frame intends. */
html body #activity-start.site-inspicacity.has-backdrop::after {
  background-image:
    linear-gradient(color-mix(in srgb, var(--ak-outline) 45%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ak-outline) 45%, transparent) 1px, transparent 1px),
    var(--ak-bg-art, none);
  background-size: 28px 28px, 28px 28px, var(--ak-bg-size, auto);
}

/* ---------- The page of panels ---------- */

.play {
  position: fixed;
  inset: 0;
  touch-action: manipulation;
}

.panels {
  --status: var(--ac-status-h, 64px);
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto var(--tools-h);
  grid-template-areas:
    "logo ask ring"
    "note note note"
    "stage stage stage"
    "shelf shelf shelf"
    "tools tools tools";
  gap: var(--gutter);
  width: min(100%, 720px);
  margin: 0 auto;
  padding:
    calc(var(--status) + 6px)
    max(12px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.panel,
.logo-panel,
.sheet,
.shelf-panel,
.finale {
  background: var(--ak-surface);
  border: var(--line) solid var(--ak-ink);
  border-radius: var(--cut);
}

/* ---------- Top strip: logo, caption box, the ring ---------- */

.logo-panel {
  grid-area: logo;
  align-self: center;
  display: flex;
  align-items: center;
  padding: 2px 6px;
  rotate: -3deg;
}

/* The logo and the question are paper chips like the site's own status chips: a wobbly
   hand-cut edge, a hard ink shadow, a tilt and a strip of tape across the top. */
.logo-panel,
.caption {
  position: relative;
  border-width: 2px;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  box-shadow: 3px 3px 0 var(--ak-ink);
}

.logo-panel::before,
.caption::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 50%;
  width: 44px;
  height: 14px;
  background: color-mix(in srgb, var(--ak-accent-2) 55%, transparent);
  rotate: -4deg;
  translate: -50% 0;
}

.logo {
  display: block;
  height: 44px;
  width: auto;
}

.caption {
  margin: 0;
  padding: 6px 16px 6px;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  border: 2px solid var(--ak-ink);
  font-family: var(--ak-font-display);
  font-weight: 700;
  line-height: 1.05;
}

.ask {
  grid-area: ask;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-self: center;
  justify-self: start;
  max-width: 100%;
  min-width: 0;
  padding: 4px 10px 6px;
  rotate: -1.2deg;
}

.ask p { margin: 0; }

.ask-title { font-size: clamp(19px, 5.4vw, 30px); }

/* The how-to note, its own caption box across the page under the question: how drawing works,
   then this face's twist, brief or example. Two layers share one cell: the lines showing now, over
   an unseen copy of the tallest this face's note gets, which holds the height steady so the sheet
   never changes size during a face. */
.ask-note {
  grid-area: note;
  display: grid;
  justify-self: stretch;
  min-width: 0;
  padding: 4px 12px 5px;
  rotate: 0.5deg;
  font-family: var(--ak-font-body);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.ask-note::before { left: 18%; }

.ask-layer {
  grid-area: 1 / 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 10px;
}

.ask-sizer { visibility: hidden; }

/* How drawing works: up for the whole face, in plain caption type. */
.ask-line { display: block; }

/* This face's own ask (a twist, the brief, or the example) on a white slip inside the caption. */
.ask-twist {
  padding: 1px 7px 2px;
  background: var(--ak-surface);
  border: 2px solid var(--ak-ink);
  border-radius: var(--cut-b);
  rotate: -0.6deg;
}

/* The word inside the ring while a face is being drawn: the ring is the finish button. */
.ring-word {
  display: grid;
  place-items: center;
  padding: 6% 4% 0 0;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
}

.ring.is-live .ring-word { opacity: 1; }

/* Before the first line the ring is full and paler: it is waiting for the pen, not counting. */
.ring.is-waiting .ring-left { stroke: color-mix(in srgb, var(--ak-accent) 45%, var(--ak-surface)); }

.stamp {
  position: absolute;
  width: 9%;
  aspect-ratio: 1;
  translate: -50% 0;
  rotate: 8deg;
}

.stamp circle { fill: var(--ak-accent); stroke: var(--ak-ink); stroke-width: 2; }
.stamp path { fill: none; stroke: var(--ak-ink); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

.ring {
  grid-area: ring;
  position: relative;
  align-self: center;
  width: 64px;
  height: 67px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}

.ring > * {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ring-paper { fill: none; stroke: var(--ak-surface); stroke-width: 34; }
.ring-left { fill: none; stroke: var(--ak-accent); stroke-width: 30; stroke-linecap: round; }
.ring-tab { clip-path: inset(0 43% 84% 40%); }
.ring[aria-disabled="true"] { cursor: default; }

/* ---------- The big panel: the drawing sheet ---------- */

.stage {
  grid-area: stage;
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  container-type: size;
}

.sheet {
  position: relative;
  width: min(92dvw, calc((100dvh - var(--status) - 300px) * 0.75));
  aspect-ratio: 3 / 4;
  touch-action: none;
  cursor: crosshair;
  background-color: var(--ak-surface);
  background-image:
    radial-gradient(circle at 30% 40%, var(--paper-tooth) 0.6px, transparent 1.2px),
    radial-gradient(circle at 70% 80%, var(--paper-tooth) 0.5px, transparent 1.1px);
  background-size: 7px 9px, 11px 7px;
  border-width: 4px;
  -webkit-user-select: none;
  user-select: none;
}

@supports (width: 1cqw) {
  .sheet { width: min(100cqw, 75cqh); }
}

/* After naming: the face hangs on the wall as a print, tilted on its pins, its name on tape. */
.sheet.is-hung {
  rotate: -1.4deg;
  border-width: 3px;
  box-shadow: 0 10px 18px color-mix(in srgb, var(--ak-ink) 28%, transparent);
  cursor: default;
}

/* The sheet's face number, on a strip of cream tape across the top edge between the pins. */
.face-tag {
  position: absolute;
  top: -13px;
  left: 50%;
  z-index: 3;
  margin: 0;
  padding: 3px 14px 4px;
  translate: -50% 0;
  rotate: -1.5deg;
  background: var(--tape-ink);
  color: var(--ak-ink);
  clip-path: polygon(0 10%, 4% 0, 8% 12%, 12% 0, 88% 0, 92% 10%, 96% 0, 100% 12%, 100% 90%, 96% 100%, 92% 88%, 88% 100%, 12% 100%, 8% 90%, 4% 100%, 0 88%);
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

.hung-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -16px;
  z-index: 3;
  width: fit-content;
  max-width: 94%;
  margin: 0 auto;
  padding: 5px 20px 6px;
  rotate: 1.6deg;
  background: var(--tape-ink);
  color: var(--ak-ink);
  clip-path: polygon(0 10%, 3% 0, 7% 12%, 11% 0, 89% 0, 93% 10%, 97% 0, 100% 12%, 100% 90%, 96% 100%, 92% 88%, 88% 100%, 12% 100%, 8% 90%, 4% 100%, 0 88%);
  font-family: var(--ak-font-display);
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: break-word;
}

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

.guide,
.guide-tags { pointer-events: none; }

.pin {
  position: absolute;
  top: -9px;
  width: 16px;
  height: 16px;
  border: 2px solid var(--ak-ink);
  border-radius: 50%;
  background: var(--ak-accent-2);
  z-index: 2;
}

.pin::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ak-surface);
}

.pin-l { left: 14px; }
.pin-r { right: 14px; }

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

.pen.is-down { background: color-mix(in srgb, var(--ak-accent-2) 30%, transparent); }

.guide-eye {
  fill: none;
  stroke: var(--ak-accent-2);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 5 4;
}

.guide-pupil { fill: var(--ak-accent-2); }

.guide-arrow {
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.guide.is-faint { opacity: 0.45; }

.guide-tag {
  position: absolute;
  padding: 2px 10px 3px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  border: 2px solid var(--ak-ink);
  border-radius: 2px;
  font-family: var(--ak-font-display);
  /* In step with the sheet (stage units, as the sheet is sized), so a small sheet keeps its tape
     in view rather than under its labels. */
  font-size: clamp(13px, calc(min(100cqw, 75cqh) * 0.075), 22px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  translate: -50% -50%;
}

/* ---------- Word bubbles ---------- */

.bubble {
  grid-area: tools;
  position: relative;
  z-index: 5;
  align-self: start;
  justify-self: center;
  width: min(100%, 520px);
  margin: 14px 0 0;
  padding: 14px 18px 14px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  border: var(--line) solid var(--ak-ink);
  border-radius: 28px 34px 30px 26px;
  text-align: center;
}

.bubble::before,
.bubble::after {
  content: '';
  position: absolute;
  left: 30%;
  width: 0;
  height: 0;
  border-style: solid;
}

.bubble::before {
  top: -22px;
  border-width: 0 4px 22px 18px;
  border-color: transparent transparent var(--ak-ink) transparent;
}

.bubble::after {
  top: -15px;
  margin-left: 4px;
  border-width: 0 2px 16px 11px;
  border-color: transparent transparent var(--ak-surface) transparent;
}

/* While the bubble speaks it takes the tool row's place and the room it needs. */
.panels.is-talking { grid-template-rows: auto auto minmax(0, 1fr) auto auto; }

.panels.is-talking .bubble { padding: 10px 16px 12px; }
.panels.is-talking .bubble-main { font-size: clamp(20px, 5vw, 25px); }
.panels.is-talking .bubble-aside { margin-top: 6px; font-size: 15px; }
.panels.is-talking .bubble .ink-btn { margin-top: 10px; min-height: 50px; }

/* Short screens: the bubble keeps its line and its button; the reflection waits for more room. */
@media (max-height: 700px) {
  .panels.is-talking .bubble-aside { display: none; }
  .panels.is-talking .shelf-panel { height: 56px; }
  .panels.is-talking .kept { display: none; }
}

.bubble-main {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: clamp(22px, 5.4vw, 27px);
  font-weight: 700;
  line-height: 1.12;
}

.bubble-aside {
  margin: 8px 0 0;
  font-size: 17px;
  line-height: 1.35;
  color: var(--ak-ink);
}

/* What is still to come: the next face, the brief, the best to beat. Never hidden for room. */
.bubble-next {
  margin: 8px auto 0;
  width: fit-content;
  max-width: 100%;
  padding: 3px 10px 4px;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  border: 2px solid var(--ak-ink);
  border-radius: var(--cut-b);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.bubble .ink-btn { margin-top: 12px; }

/* The bubble's one button (Tape me up, Next face) gets room to breathe, never a tight squeeze. */
.bubble .ink-btn { min-width: min(100%, 240px); padding: 0 34px; }

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

.ink-btn,
.paper-btn {
  min-height: 52px;
  min-width: 48px;
  padding: 0 22px;
  border: var(--line) solid var(--ak-ink);
  border-radius: var(--cut-b);
  font-family: var(--ak-font-display);
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.ink-btn { background: var(--ak-btn-fill); color: var(--ak-btn-ink); }
.paper-btn { background: var(--ak-choice-bg); color: var(--ak-choice-ink); }
.ink-btn:active { background: var(--ak-btn-active); }

@media (hover: hover) {
  .ink-btn:hover { background: var(--ak-btn-hover); }
}

/* ---------- The shelf panel ---------- */

.shelf-panel {
  grid-area: shelf;
  display: flex;
  align-items: center;
  gap: 10px;
  height: clamp(68px, 13dvh, 118px);
  padding: 4px 12px 4px 6px;
  rotate: 0.4deg;
  container-type: size;
}

.shelf-host {
  height: 100%;
  flex: 0 0 auto;
  width: min(66cqw, calc(100cqh * 2.0105));
  display: flex;
  align-items: center;
}

.shelf-text {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shelf-note {
  margin: 0;
  color: var(--ak-ink);
  font-size: 13px;
  line-height: 1.3;
}

.shelf-note-tag {
  font-family: var(--ak-font-display);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}

/* Too little room for the note and the save line together: the goal stays, the save line waits. */
@container (max-height: 74px) {
  .kept { display: none; }

  .shelf-note {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.25;
  }

  .shelf-note-tag { font-size: 15px; }
}

.kept {
  margin: 0;
  min-width: 0;
  color: var(--ak-ink-muted);
  font-size: 13px;
  line-height: 1.3;
}

.kept.is-trouble { color: var(--ak-ink); font-weight: 700; }

.shelf {
  position: relative;
  width: 100%;
  aspect-ratio: 384 / 191;
  container-type: inline-size;
}

.shelf-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.frame {
  position: absolute;
  overflow: hidden;
  background: var(--ak-surface);
}

.frame.is-round { border-radius: 50%; }

.frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.tape-label {
  position: absolute;
  top: 59%;
  width: 22%;
  padding: 1px 4px;
  translate: -50% 0;
  background: var(--tape-ink);
  color: var(--ak-ink);
  clip-path: polygon(0 8%, 4% 0, 9% 10%, 14% 0, 86% 0, 91% 9%, 96% 0, 100% 10%, 100% 92%, 95% 100%, 90% 90%, 85% 100%, 14% 100%, 9% 90%, 4% 100%, 0 90%);
  font-family: var(--ak-font-display);
  font-size: clamp(9px, 4.4cqw, 26px);
  font-weight: 700;
  line-height: 1;
  text-align: center;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tape-label:empty { visibility: hidden; }

@container (max-width: 280px) {
  .tape-label { visibility: hidden; }
}

/* ---------- Tools: paper chips along the bottom gutter ---------- */

.toolbelt {
  grid-area: tools;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
  height: var(--tools-h);
}

/* Done sits at the end of the tool row, where the hands already are; the ring says it too. */
.finish {
  flex: 0 0 auto;
  align-self: center;
  min-height: calc(54px * min(var(--k), 1.2));
  padding: 0 12px;
  font-size: calc(22px * min(var(--k), 1.2));
  white-space: nowrap;
}

.tools {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  min-width: 0;
  height: var(--tools-h);
  padding: 6px 4px 2px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.tools.more-right { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent); }
.tools.more-left { -webkit-mask-image: linear-gradient(90deg, transparent, #000 44px); mask-image: linear-gradient(90deg, transparent, #000 44px); }
.tools.more-left.more-right { -webkit-mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent); mask-image: linear-gradient(90deg, transparent, #000 44px, #000 calc(100% - 44px), transparent); }

.chip {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: end center;
  width: calc(48px * var(--k));
  height: var(--chip-h);
  padding: 0 0 4px;
  border: 0;
  background: none;
  cursor: pointer;
  scroll-snap-align: start;
  touch-action: manipulation;
  rotate: var(--tilt, 0deg);
  transform-origin: 50% 100%;
  transition: translate 0.18s var(--spring);
}

.chip-art {
  display: block;
  width: calc(var(--w) * 1.2px * var(--k));
  height: calc(55px * var(--k));
  background-image: url("art/tool-chips.png");
  background-repeat: no-repeat;
  background-size: calc(460.8px * var(--k)) auto;
  background-position: calc(var(--x) * -1.2px * var(--k)) calc(-81.6px * var(--k));
}

.chip-paper {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(30px * var(--k));
  height: calc(46px * var(--k));
  margin-bottom: 1px;
  background: var(--ak-surface);
  border: 2px solid var(--ak-ink);
  border-radius: 4px 2px 5px 3px / 2px 5px 3px 4px;
}

.chip-paper::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  width: 16px;
  height: 9px;
  translate: -50% 0;
  background: var(--tape-ink);
  border: 1px solid color-mix(in srgb, var(--ak-ink) 35%, transparent);
}

.dab {
  width: calc(20px * var(--k));
  height: calc(20px * var(--k));
  border: 2px solid var(--ak-ink);
  border-radius: 54% 46% 50% 50% / 48% 56% 44% 52%;
  background: var(--dab);
}

.chip[aria-pressed="true"] { translate: 0 -7px; }

.chip[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -5px;
  height: 6px;
  border: 2px solid var(--ak-ink);
  border-radius: 3px;
  background: var(--ak-accent);
}

.chip[aria-disabled="true"] { opacity: 0.4; filter: grayscale(1); }

.chip-gap { flex: 0 0 8px; }

/* ---------- The name panel ---------- */

/* While a face is being named, the name panel lies over the shelf and the tool row together. The
   grid keeps its rows, so the sheet does not change size when Done is pressed. */
.panels.is-naming .shelf-panel { visibility: hidden; }

.namebar {
  /* It also spans the sheet's flexible row, so the grid never grows a row to fit it: on the
     smallest phones it may overlap the sheet's foot by a few pixels rather than shrink the sheet. */
  grid-row: 3 / 6;
  grid-column: 1 / -1;
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 10px 14px 12px;
  background: var(--ak-surface);
  border: var(--line) solid var(--ak-ink);
  border-radius: var(--cut);
  z-index: 4;
}

/* The title is the field's own label: it says what to do and that typing is wanted. */
.name-title {
  margin: 0;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.name-label-aside {
  font-family: var(--ak-font-body);
  font-size: 15px;
  font-weight: 400;
  white-space: nowrap;
}

.name-hint {
  margin: 0;
  color: var(--ak-ink);
  font-size: 15px;
  line-height: 1.3;
}

.name-error {
  margin: 0;
  padding: 3px 10px;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  border: 2px solid var(--ak-ink);
  border-radius: var(--cut-b);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.name-field {
  width: 100%;
  min-width: 0;
  height: 56px;
  padding: 0 14px;
  border: var(--line) solid var(--ak-ink);
  border-radius: var(--cut);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 28px;
  font-weight: 700;
}

/* An example to type over, in plain body type, so it never looks like a name already filled in. */
.name-field::placeholder {
  color: var(--ak-ink-muted);
  opacity: 1;
  font-family: var(--ak-font-body);
  font-size: 18px;
  font-style: italic;
  font-weight: 400;
}

.name-actions {
  display: flex;
  gap: 10px;
  min-width: 0;
}

.name-actions > button { min-height: 54px; }

.spark { flex: 0 1 auto; padding: 0 12px; font-size: 22px; }

.name-go { flex: 1 1 auto; padding: 0 12px; font-size: 23px; }

/* ---------- The last panel ---------- */

.finale {
  grid-row: 2 / -1;
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
  padding: 18px 14px;
  container-type: size;
}

.finale-cap {
  align-self: flex-start;
  font-size: clamp(22px, 5.5vw, 32px);
  rotate: -1.2deg;
}

.finale-shelf {
  width: min(100%, calc((100cqh - 90px) * 1.9));
}

/* ---------- In-page sheets ---------- */

.tlf-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: color-mix(in srgb, var(--ak-bg) 78%, transparent);
}

.tlf-dialog-panel {
  width: min(100%, 420px);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 20px 18px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  border: var(--line) solid var(--ak-ink);
  border-radius: var(--cut);
  rotate: -0.8deg;
}

.tlf-dialog-title {
  margin: 0 0 8px;
  font-family: var(--ak-font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.05;
}

.tlf-dialog-text { margin: 0 0 16px; font-size: 17px; line-height: 1.4; }

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

.viewer-face {
  display: block;
  width: min(100%, 260px, 42dvh);
  aspect-ratio: 3 / 4;
  margin: 0 auto 12px;
  border: var(--line) solid var(--ak-ink);
  background: var(--ak-surface);
}

/* ---------- The reel on the start screen ---------- */

.tlf-reel {
  position: relative;
  margin: 18px 0 8px;
  padding: 16px 14px 12px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  border: 2px solid var(--ak-ink);
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  rotate: 0.6deg;
  text-align: left;
}

.tlf-reel::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  width: 70px;
  height: 18px;
  translate: -50% 0;
  rotate: -3deg;
  background: var(--tape-ink);
  border: 1px solid color-mix(in srgb, var(--ak-ink) 30%, transparent);
}

.tlf-reel-title {
  margin: 0 0 8px;
  font-family: var(--ak-font-display);
  font-size: 26px;
  font-weight: 700;
}

.tlf-reel-row {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scroll-snap-type: x proximity;
}

.tlf-reel-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 84px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  scroll-snap-align: start;
  rotate: var(--tilt, 0deg);
}

.tlf-reel-item canvas {
  display: block;
  width: 72px;
  height: 96px;
  border: 2px solid var(--ak-ink);
  background: var(--ak-surface);
}

.tlf-reel-name {
  width: 100%;
  font-family: var(--ak-font-display);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  overflow-wrap: anywhere;
}

.tlf-reel-empty,
.tlf-reel-kept {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--ak-ink-muted);
}

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

/* ---------- The status bar keeps one shape ---------- */

/* The label chip has one width all through play, so a longer or shorter label never re-wraps the
   bar and shifts the sheet. Every label the game sends fits it. */
body:not(.tlf-waiting) #activity-chrome-status .ac-label {
  width: 128px;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
}

/* ---------- Toasts ride above the tool row ---------- */

body #activity-chrome-toast[data-at="bottom-left"] {
  bottom: calc(var(--tools-h) + max(14px, env(safe-area-inset-bottom)));
}

/* ---------- The pinned print: always reachable, and pinned to a wall of its own ---------- */

/* The print hangs on the studio wall itself, so the play screen does not show round its edges. */
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));
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, var(--ak-bg-art));
  background-size: cover;
  background-position: center;
}

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

/* Short and wide: the print on the left, the words and buttons on the right, nothing clipped. */
@media (max-height: 520px) and (orientation: landscape) {
  body #activity-chrome-ending.site-inspicacity { padding-block: 12px; }

  body #activity-chrome-ending.site-inspicacity .ac-card {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    grid-auto-flow: row dense;
    align-items: center;
    column-gap: 22px;
    row-gap: 6px;
    width: min(100%, 860px);
    max-height: calc(100dvh - 24px);
    padding: 22px 22px 16px;
    text-align: left;
    transform: rotate(-1deg);
  }

  body #activity-chrome-ending.site-inspicacity .ac-card > * { grid-column: 2; }

  body #activity-chrome-ending.site-inspicacity .ac-card .ac-work {
    grid-column: 1;
    grid-row: 1 / span 6;
    justify-self: center;
    margin: 8px 0;
  }

  body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: calc(100dvh - 120px); }

  body #activity-chrome-ending.site-inspicacity .ac-verdict { font-size: 26px; }

  body #activity-chrome-ending.site-inspicacity .ac-lines { font-size: 14px; line-height: 1.35; }

  body #activity-chrome-ending.site-inspicacity .ac-line { margin-bottom: 3px; }

  body #activity-chrome-ending.site-inspicacity .ac-actions { justify-content: flex-start; gap: 10px; }
}

/* Short and upright (a small phone): a smaller print, so the buttons stay on screen. */
@media (max-height: 700px) and (orientation: portrait) {
  body #activity-chrome-ending.site-inspicacity { padding-block: 10px; }
  body #activity-chrome-ending.site-inspicacity .ac-card { padding: 22px 16px 14px; gap: 6px; }
  body #activity-chrome-ending.site-inspicacity .ac-verdict { font-size: 26px; }
  body #activity-chrome-ending.site-inspicacity .ac-work img { max-height: 26vh; }
  body #activity-chrome-ending.site-inspicacity .ac-lines { font-size: 14px; line-height: 1.35; }
  body #activity-chrome-ending.site-inspicacity .ac-actions { gap: 8px; }
  body #activity-chrome-ending.site-inspicacity .ac-actions button { padding: 0 12px; font-size: 18px; }
}

/* ---------- Landscape: the sheet on one side, everything else on the other ---------- */

@media (orientation: landscape) {
  /* The sheet takes the right-hand side at nearly full height, beside the status bar rather than
     under it; the left side holds the status, caption, ring, shelf and tools. */
  .panels {
    --top: max(12px, env(safe-area-inset-top));
    --sheet-col: min(calc((100dvh - var(--top) - max(10px, env(safe-area-inset-bottom))) * 0.75), 56vw);
    grid-template-columns: auto minmax(0, 1fr) auto var(--sheet-col);
    grid-template-rows: max(0px, calc(var(--status) - var(--top) - 4px)) auto auto minmax(0, 1fr) var(--tools-h);
    grid-template-areas:
      ". . . stage"
      "logo ask ring stage"
      "logo note ring stage"
      "shelf shelf shelf stage"
      "tools tools tools stage";
    width: min(100%, 1240px);
    padding-top: var(--top);
    padding-right: calc(72px + env(safe-area-inset-right));
  }

  .stage { place-items: start end; }

  /* While the bubble speaks, sideways, it takes the top of the left column, where the question and
     the ring were (neither is in play then); the shelf sits under it with whatever room is left, so
     the bubble, its words and its button are never pushed off the bottom. */
  .panels.is-talking {
    grid-template-rows: max(0px, calc(var(--status) - var(--top) - 4px)) auto minmax(0, 1fr);
    grid-template-areas:
      ". . . stage"
      "tools tools tools stage"
      "shelf shelf shelf stage";
  }

  .panels.is-talking .logo-panel,
  .panels.is-talking .ask,
  .panels.is-talking .ask-note,
  .panels.is-naming .ask-note,
  .panels.is-talking .ring,
  .panels.is-naming .logo-panel,
  .panels.is-naming .ask,
  .panels.is-naming .ring { display: none; }

  .panels.is-talking .shelf-panel { height: 100%; min-height: 0; max-height: 150px; align-self: start; }
  .panels.is-talking .kept { display: none; }

  .panels.is-talking .bubble-main { font-size: 22px; }
  .panels.is-talking .bubble-aside { font-size: 15px; }

  .bubble { align-self: start; margin: 0; }

  /* The name tape hangs inside the sheet's foot, since sideways the sheet reaches the screen edge. */
  .hung-name { bottom: 10px; }

  .bubble::before,
  .bubble::after { left: auto; right: -22px; top: 40%; }

  .bubble::before { border-width: 4px 0 18px 22px; border-color: transparent transparent transparent var(--ak-ink); }

  .bubble::after { right: -15px; margin: 4px 0 0; border-width: 2px 0 11px 16px; border-color: transparent transparent transparent var(--ak-surface); }

  /* The site status bar stays over the left-hand column, so it never runs across the sheet. */
  body #activity-chrome-status { right: var(--tlf-status-right, 72px); }

  .sheet { width: var(--sheet-col); }

  @supports (width: 1cqw) {
    .sheet { width: min(100cqw, 75cqh); }
  }

  .shelf-panel { height: 100%; max-height: 240px; align-self: center; }

  .shelf-host { width: min(64cqw, calc(100cqh * 2.0105)); }

  .ring { width: 72px; height: 75px; }


  /* Naming, sideways: the name panel takes the whole left column under the status bar; its title
     asks the question, so the caption and the closed ring step aside for the room. */
  .panels.is-naming {
    grid-template-rows: max(0px, calc(var(--status) - var(--top) - 4px)) minmax(0, 1fr);
    grid-template-areas:
      ". . . stage"
      "tools tools tools stage";
  }

  .namebar { grid-row: tools; grid-column: 1 / 4; align-self: center; justify-content: center; }

  /* Sideways the sheet has a column of its own, so the shelf can leave the grid while naming. */
  .panels.is-naming .shelf-panel { display: none; }

  .finale { grid-row: 2 / -1; grid-column: 2 / -1; padding: 12px; gap: 8px; }

  .finale-cap { font-size: 22px; }

  .finale-shelf { width: min(100%, calc((100cqh - 56px) * 1.9)); }

  .bubble { width: 100%; }

  body #activity-chrome-toast[data-at="bottom-left"] { bottom: calc(var(--tools-h) + max(14px, env(safe-area-inset-bottom))); }
}

/* Sideways with room to spare (a tablet, a laptop): the controls grow with the screen, so they stay
   comfortable beside a big sheet rather than shrinking to a strip along the bottom. */
@media (orientation: landscape) and (min-height: 431px) {
  :root { --k: 1.25; }
  .ring { width: 84px; height: 88px; }
  .ring-word { font-size: 22px; }
  .panels.is-talking .bubble .ink-btn { min-height: 60px; font-size: 28px; }
}

@media (orientation: landscape) and (min-height: 600px) {
  :root { --k: 1.5; }
  .ring { width: 100px; height: 104px; }
  .ring-word { font-size: 26px; }
  .shelf-panel { max-height: 200px; }
}

@media (orientation: landscape) and (max-height: 430px) {
  /* A phone on its side: the chips a little bigger than upright, in the room the shelf leaves. */
  :root { --k: 1.12; }
  /* Too short for the shelf beside the how-to note while drawing: it steps out (the status bar's
     Shelf meter still counts the faces) and comes back for the hop and the comment. */
  .panels:not(.is-talking) .shelf-panel { display: none; }
  .name-title { font-size: 25px; }
  .name-hint { display: none; }
  .name-field { height: 56px; font-size: 26px; }
  .name-actions > button { min-height: 56px; }
  .logo { height: 36px; }
  .ask-title { font-size: 22px; }
  .ring { width: 62px; height: 65px; }
  .bubble { padding: 10px 14px; }
  .bubble-main { font-size: 21px; }
  .bubble-aside { font-size: 15px; }
  .panels.is-talking .bubble-main { font-size: 20px; }
  .panels.is-talking .bubble-next { margin-top: 6px; font-size: 14px; }
  .panels.is-talking .bubble .ink-btn { margin-top: 8px; min-height: 48px; }
  .name-error { font-size: 15px; padding: 3px 10px; }
}

/* A shelf squeezed this low keeps just its frames. */
@container (max-height: 50px) {
  .shelf-text { display: none; }
}

/* A small upright phone: the shelf keeps just its frames and the how-to note sets tighter, so the
   sheet keeps as much room as it can. */
@media (orientation: portrait) and (max-height: 700px) {
  .namebar { gap: 6px; padding: 8px 12px 10px; }
  .name-title { font-size: 23px; }
  .name-field { height: 44px; font-size: 24px; }
  .name-actions > button { min-height: 44px; font-size: 20px; }
  .shelf-text { display: none; }
  .logo { height: 36px; }
  .shelf-panel { height: 54px; }
  .ring { width: 58px; height: 60px; }
  .ask-title { font-size: 21px; }
  .ask-note { padding: 3px 10px 4px; font-size: 13px; line-height: 1.2; }
  .ask-twist { padding: 0 6px 1px; }
}

@media (min-width: 900px) and (min-height: 700px) {
  .logo { height: 56px; }
  .ring { width: 92px; height: 96px; }
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .chip:active,
  :root:not(.ac-still) .ink-btn:active,
  :root:not(.ac-still) .paper-btn:active,
  :root:not(.ac-still) .spark:active,
  :root:not(.ac-still) .tlf-reel-item:active { animation: squash 0.22s var(--spring); }

  :root:not(.ac-still) .ring:active { animation: squash 0.22s var(--spring); }

  :root:not(.ac-still) .ask-title { animation: breathe 4.6s ease-in-out infinite; }

  :root:not(.ac-still) .ask-note.is-bumped { animation: squash 0.34s var(--spring); }

  :root:not(.ac-still) .ring-word { transition: opacity 0.25s ease-out; }

  :root:not(.ac-still) .pin-l { animation: bob 5s ease-in-out infinite; }
  :root:not(.ac-still) .pin-r { animation: bob 5s ease-in-out -2.5s infinite; }

  :root:not(.ac-still) .ring.is-low { animation: tremble 0.9s ease-in-out infinite; }

  :root:not(.ac-still) .ring.is-waiting .ring-left { animation: ring-wait 2.4s ease-in-out infinite; }

  :root:not(.ac-still) .ring.is-turn { animation: turn-cue 0.6s var(--spring); }

  :root:not(.ac-still) .guide-eye { animation: draw-in 1.4s var(--ease-out) both, dash-walk 2.4s linear 1.4s infinite; }

  :root:not(.ac-still) .bubble.is-in { animation: bubble-pop 0.42s var(--spring) both; }

  :root:not(.ac-still) .spark.is-in { animation: bubble-pop 0.42s var(--spring) 0.3s both; }

  :root:not(.ac-still) .namebar.is-in { animation: slide-up 0.38s var(--ease-out) both; }


  :root:not(.ac-still) .tools.is-folding .chip {
    animation: fold-down 0.22s ease-in both;
    animation-delay: calc(var(--i) * 30ms);
  }

  :root:not(.ac-still) .tools.is-unfolding .chip {
    animation: fold-up 0.32s var(--spring) both;
    animation-delay: calc(var(--i) * 25ms);
  }

  :root:not(.ac-still) .frame.is-landed { animation: wobble 0.6s var(--spring); }

  :root:not(.ac-still) .finale.is-in { animation: panel-in 0.55s var(--spring) both; }

  :root:not(.ac-still) .finale.is-in .finale-cap { animation: bubble-pop 0.42s var(--spring) 0.35s both; }

  :root:not(.ac-still) .tlf-dialog:not([hidden]) .tlf-dialog-panel { animation: bubble-pop 0.36s var(--spring) both; }

  :root:not(.ac-still) .tlf-reel-item:nth-child(odd) { --tilt: -2deg; }
  :root:not(.ac-still) .tlf-reel-item:nth-child(even) { --tilt: 1.5deg; }
}

@keyframes squash {
  0% { scale: 1 1; }
  40% { scale: 1.12 0.86; }
  70% { scale: 0.95 1.06; }
  100% { scale: 1 1; }
}

@keyframes breathe {
  0%, 100% { scale: 1; }
  50% { scale: 1.025; }
}

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -1.5px; }
}

@keyframes ring-wait {
  0%, 100% { stroke-opacity: 1; }
  50% { stroke-opacity: 0.55; }
}

@keyframes tremble {
  0%, 100% { rotate: 0deg; }
  25% { rotate: -5deg; }
  75% { rotate: 5deg; }
}

@keyframes turn-cue {
  0% { scale: 0.6; rotate: -30deg; }
  100% { scale: 1; rotate: 0deg; }
}

@keyframes draw-in {
  from { stroke-dashoffset: 120; opacity: 0; }
  to { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes dash-walk {
  to { stroke-dashoffset: -18; }
}

@keyframes bubble-pop {
  0% { opacity: 0; scale: 0.4; }
  70% { opacity: 1; scale: 1.06; }
  100% { opacity: 1; scale: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(70%); }
  to { opacity: 1; transform: none; }
}

@keyframes fold-down {
  from { transform: none; opacity: 1; }
  to { transform: scaleY(0.05); opacity: 0; }
}

@keyframes fold-up {
  from { transform: scaleY(0.05); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes wobble {
  0% { rotate: 0deg; scale: 1.15; }
  30% { rotate: -7deg; }
  55% { rotate: 5deg; scale: 0.97; }
  80% { rotate: -2deg; }
  100% { rotate: 0deg; scale: 1; }
}

@keyframes panel-in {
  from { transform: translateX(110%) rotate(3deg); }
  to { transform: none; }
}
