/* Tide Pool Palettes: a bare gesso wall, one charcoal tide line, a taped board, a huge contrast number.
   Poster signature: big flat shapes, few colours, no drop shadows. The player's five colours are the loudest thing. */

:root {
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wobble-2: 15px 225px 15px 255px / 255px 15px 225px 15px;
  --gap: 8px;
  --c-background: #F4EFE6;
  --c-surface: #C9D8C5;
  --c-main: #3E7C8C;
  --c-accent: #E9C46A;
  --c-text: #1D2D3A;
  --edge-l: max(10px, env(safe-area-inset-left));
  --edge-r: max(10px, env(safe-area-inset-right));
  --edge-b: max(10px, env(safe-area-inset-bottom));
}

* { 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 bottom;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  -webkit-tap-highlight-color: transparent;
}

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

button:focus-visible,
input:focus-visible,
.stage:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

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

[hidden] { display: none !important; }

/* ---------- the wall: portrait first ---------- */

.play {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: "top" "words" "stage" "card" "pebbles" "tools";
  row-gap: var(--gap);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--ac-status-h, 60px) + 4px) var(--edge-r) var(--edge-b) var(--edge-l);
  touch-action: manipulation;
}

.play.card-open:not(.keep-words) .words { display: none; }

/* ---------- top row: logo, pictures, hint, done ---------- */

.top {
  grid-area: top;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 48px;
}

.logo {
  display: block;
  height: 34px;
  width: auto;
  flex: 0 0 auto;
}

.kept {
  position: absolute;
  bottom: -4px;
  left: 0;
  display: inline-block;
  width: 14px;
  height: 14px;
  opacity: 0;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 11 C6 13 7 15 8 16 C10 11 13 7 17 4' fill='none' stroke='%232A2A2A' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.kept.on { opacity: 1; }

.hint,
.done {
  min-width: 56px;
  min-height: 48px;
  padding: 0 12px;
  border-radius: var(--wobble);
  font-family: var(--ak-font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.hint {
  margin-left: auto;
  border: 2px solid var(--ak-ink);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  rotate: 1.5deg;
}

.done {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  rotate: -1.5deg;
}

/* ---------- sea words: eight words written on the wall with their seed strip ---------- */

.words {
  grid-area: words;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px 6px;
}

.word {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 48px;
  padding: 4px 6px;
  border-radius: var(--wobble-2);
  color: var(--ak-ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.05;
  text-align: left;
}

.words-say {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ak-ink-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

/* The brief: one small design idea on a strip of paper over the sea words. Tap it to load or get another. */
.brief {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 3px 4px 3px 10px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble-2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  text-align: left;
}

.brief-words {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.brief-tag {
  color: var(--ak-ink-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.brief-say {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
}

.brief-act {
  flex: 0 0 auto;
  max-width: 40%;
  padding: 8px 10px;
  border-radius: var(--wobble);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

/* A sea word with a palette on the shelf wears a small charcoal pebble in its corner. */
.word { position: relative; }

.word.on-shelf::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 5px;
  width: 11px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 55% 45% 50% 50% / 60% 55% 45% 40%;
  background: var(--ak-accent);
}

.word-strip {
  display: flex;
  height: 7px;
  outline: 1.5px solid var(--ak-ink);
}

.word-strip i { flex: 1 1 0; }

.word[aria-pressed="true"] {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.word[aria-pressed="true"] .word-strip { outline-color: var(--ak-btn-ink); }

/* ---------- the stage: the huge number behind, the taped gesso board in front ---------- */

.stage {
  grid-area: stage;
  position: relative;
  min-height: 0;
  container-type: size;
  container-name: stage;
  touch-action: pan-y;
  user-select: none;
}

.bignum {
  position: absolute;
  top: -0.04em;
  right: -0.08em;
  z-index: 0;
  margin: 0;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: min(32cqh, 46cqw);
  font-weight: 700;
  line-height: 0.8;
  letter-spacing: -0.02em;
  white-space: nowrap;
  pointer-events: none;
}

.stage { --tabs-h: 50px; }

.board {
  position: absolute;
  bottom: var(--tabs-h);
  left: 50%;
  z-index: 1;
  height: min(calc(82cqh - var(--tabs-h)), 125cqw);
  aspect-ratio: 4 / 5;
  translate: -50% 0;
  padding: 3.2%;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble);
  background: var(--ak-surface);
}

/* The picture switcher: three labelled paper tabs pinned under the board. */
.mock-tabs {
  position: absolute;
  bottom: 0;
  left: 50%;
  z-index: 2;
  display: flex;
  gap: 4px;
  translate: -50% 0;
}

.mock-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 46px;
  padding: 0 10px 0 6px;
  border: 2px solid var(--ak-ink);
  border-top: 0;
  border-radius: 0 0 14px 4px / 0 0 10px 6px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: 15px;
  font-weight: 700;
}

.mock-tab svg {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mock-tab[aria-pressed="true"] {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

@container stage (min-aspect-ratio: 1 / 1) {
  .board {
    top: 50%;
    right: 0;
    bottom: auto;
    left: auto;
    height: min(97cqh, 90cqw);
    translate: 0 -50%;
  }
  /* Sideways stage: the tabs stack in the wall space left of the board, under the number. */
  .mock-tabs {
    left: 0;
    flex-direction: column;
    align-items: flex-start;
    translate: none;
  }
  .mock-tab {
    border-top: 2px solid var(--ak-ink);
    border-left: 0;
    border-radius: 0 14px 4px 0 / 0 10px 6px 0;
  }
  .bignum {
    top: 0;
    right: auto;
    left: -0.06em;
    font-size: min(32cqh, 30cqw);
    writing-mode: vertical-rl;
    rotate: 180deg;
    translate: none;
  }
}

/* A short sideways stage (the smallest phones with the brief showing): the tabs lie in one row under the number. */
@container stage (min-aspect-ratio: 1 / 1) and (max-height: 240px) {
  .mock-tabs {
    flex-direction: row;
    align-items: flex-end;
    gap: 4px;
  }
  .mock-tab {
    justify-content: center;
    min-width: 48px;
    padding: 0 10px;
    border: 2px solid var(--ak-ink);
    border-bottom: 0;
    border-radius: 14px 4px 0 0 / 10px 6px 0 0;
  }
  .mock-tab span { display: none; }
}

.btape {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  width: 24%;
  height: 6.5%;
  background: var(--ak-accent-2);
}

.btape.tl { top: -2%; left: -6%; rotate: -38deg; }
.btape.tr { top: -2%; right: -6%; rotate: 38deg; }
.btape.bl { bottom: -2%; left: -6%; rotate: 38deg; }
.btape.br { bottom: -2%; right: -6%; rotate: -38deg; }

.mock {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.mock svg {
  display: block;
  width: 100%;
  height: 100%;
}

.f-background { fill: var(--c-background); }
.f-surface { fill: var(--c-surface); }
.f-main { fill: var(--c-main); }
.f-accent { fill: var(--c-accent); }
.f-text { fill: var(--c-text); }
.s-background { stroke: var(--c-background); }
.s-surface { stroke: var(--c-surface); }
.s-main { stroke: var(--c-main); }
.s-accent { stroke: var(--c-accent); }
.s-text { stroke: var(--c-text); }

.closing {
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 3;
  max-width: 86%;
  margin: 0;
  padding: 10px 18px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  translate: -50% 0;
  rotate: -3deg;
}

/* ---------- the slider card ---------- */

.card {
  grid-area: card;
  position: relative;
  z-index: 4;
  display: grid;
  gap: 2px;
  padding: 18px 60px 6px 12px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble-2);
  background: var(--ak-surface);
}

.card-tag {
  position: absolute;
  top: -14px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 90px);
  margin: 0;
  padding: 3px 10px;
  border: 2px solid var(--ak-ink);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  rotate: -2deg;
}

.card-tag i {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ak-ink);
  border-radius: 50%;
  background: var(--sw);
}

.card-close {
  position: absolute;
  top: -18px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50% 46% 52% 48%;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.card-close svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
}

.card-undo {
  position: absolute;
  right: 4px;
  bottom: 8px;
  width: 52px;
  min-height: 56px;
  padding: 2px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}

.dial {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  align-items: center;
  min-height: 46px;
}

.dial-track {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dial-ends {
  display: flex;
  justify-content: space-between;
  margin-top: -6px;
  color: var(--ak-ink-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.1;
}

.dial-ends i { font-style: normal; }

.dial-name {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
}

.dial-name b {
  display: block;
  color: var(--ak-ink-muted);
  font-size: 13px;
  font-weight: 600;
}

.dial input {
  width: 100%;
  height: 40px;
  margin: 0;
  background: transparent;
  touch-action: none;
  -webkit-appearance: none;
  appearance: none;
}

.dial input::-webkit-slider-runnable-track {
  height: 18px;
  border: 2px solid var(--ak-ink);
  border-radius: 10px 4px 12px 5px;
  background: var(--track);
}

.dial input::-webkit-slider-thumb {
  width: 40px;
  height: 34px;
  margin-top: -10px;
  border: 3px solid var(--ak-ink);
  border-radius: 55% 45% 52% 48% / 60% 55% 45% 40%;
  background: var(--thumb);
  -webkit-appearance: none;
  appearance: none;
}

.dial input::-moz-range-track {
  height: 14px;
  border: 2px solid var(--ak-ink);
  border-radius: 10px 4px 12px 5px;
  background: var(--track);
}

.dial input::-moz-range-thumb {
  width: 36px;
  height: 30px;
  border: 3px solid var(--ak-ink);
  border-radius: 55% 45% 52% 48% / 60% 55% 45% 40%;
  background: var(--thumb);
}

/* ---------- pebbles on the tide line ---------- */

.pebbles {
  grid-area: pebbles;
  position: relative;
  display: grid;
  grid-template-columns: 0.99fr 1.88fr 2.52fr 1.08fr 1.44fr;
  align-items: end;
  gap: 4px;
  width: 100%;
  max-width: 520px;
  justify-self: center;
  padding-top: 22px;
}

.peb-say {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  color: var(--ak-ink-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  pointer-events: none;
}

.tideline {
  position: absolute;
  left: -10px;
  right: -10px;
  bottom: 14px;
  width: calc(100% + 20px);
  height: 16px;
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 2.4;
  stroke-linecap: round;
  pointer-events: none;
}

.peb {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-height: 48px;
  padding: 2px 0 0;
  color: var(--ak-ink);
}

.peb-word {
  position: relative;
  padding: 0 4px;
  background: var(--ak-bg);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.15;
}

.peb[aria-pressed="true"] .peb-word {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.peb[aria-pressed="true"] .stone { translate: 0 -6px; }

/* A pebble: the white painted stone tinted by a colour layer under it, cut to its own outline. */
.stone {
  position: relative;
  display: block;
  width: 100%;
  max-height: 64px;
  isolation: isolate;
}

.stone::before,
.stone::after {
  content: '';
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
}

.stone::before {
  background-color: var(--sw, #fff);
  -webkit-mask-image: url("art/swatch-pebbles.png");
  mask-image: url("art/swatch-pebbles.png");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: var(--sz);
  mask-size: var(--sz);
  -webkit-mask-position: var(--pos);
  mask-position: var(--pos);
}

.stone::after {
  background-image: url("art/swatch-pebbles.png");
  background-size: var(--sz);
  background-position: var(--pos);
  mix-blend-mode: multiply;
}

.stone.round { aspect-ratio: 136 / 137; --sz: 280.9% 280.3%; --pos: 4.47% 0%; }
.stone.oval { aspect-ratio: 190 / 101; --sz: 201.05% 380.2%; --pos: 94.27% 7.42%; }
.stone.slab { aspect-ratio: 270 / 107; --sz: 141.48% 358.88%; --pos: 50% 49.82%; }
.stone.triangle { aspect-ratio: 153 / 142; --sz: 249.67% 270.42%; --pos: 0% 100%; }
.stone.bean { aspect-ratio: 183 / 127; --sz: 208.74% 302.36%; --pos: 100% 98.83%; }

/* The contrast warning: a strip of cadmium tape pressed across the text pebble. */
.tape-tag {
  position: absolute;
  top: 0;
  right: -4px;
  z-index: 3;
  display: flex;
  align-items: center;
  max-width: calc(100% + 8px);
  height: 44px;
  padding: 0 4px;
  border-style: solid;
  border-width: 0 12px 0 44px;
  border-image: url("art/tape-tag.png") 0 26 0 100 fill / 0 12px 0 44px stretch;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: clamp(16px, 4.8vw, 20px);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  rotate: -2.5deg;
  transform-origin: 90% 60%;
  pointer-events: none;
}

/* ---------- the tool chips along the bottom edge ---------- */

.tools {
  grid-area: tools;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.tool {
  display: grid;
  flex: 1 1 0;
  place-items: center;
  min-width: 48px;
  min-height: 52px;
  height: min(66px, 9dvh);
  padding: 0;
}

.chip {
  display: block;
  height: 100%;
  aspect-ratio: 125 / 138;
  background-image: url("art/tool-chips.png");
  background-repeat: no-repeat;
}

.chip-flip { background-size: 314.75% 261.15%; background-position: 2.29% 21.43%; }
.chip-name { background-size: 314.75% 259.29%; background-position: 50.38% 20.63%; }
.chip-save { background-size: 314.75% 259.29%; background-position: 98.47% 21.97%; }
.chip-clear { background-size: 297.67% 272.93%; background-position: 24.31% 82.61%; }
.chip-shelf { background-size: 297.67% 264.96%; background-position: 76.86% 83.63%; }

.tool:nth-child(1) .chip { rotate: -3deg; }
.tool:nth-child(2) .chip { rotate: 2deg; }
.tool:nth-child(3) .chip { rotate: -1deg; }
.tool:nth-child(4) .chip { rotate: 3deg; }
.tool:nth-child(5) .chip { rotate: -2deg; }

/* ---------- sideways: board on one side, controls on the other, tools down the far edge ---------- */

@media (orientation: landscape) {
  .play {
    max-width: 1180px;
    grid-template-columns: minmax(0, 1fr) minmax(300px, min(46%, 440px)) auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "stage top tools"
      "stage words tools"
      "stage pebbles tools";
    column-gap: 12px;
  }
  .card {
    grid-area: words;
    align-self: center;
  }
  .words { align-self: center; }
  .tools {
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    width: min(68px, 18dvh);
  }
  .tool {
    flex: 0 1 76px;
    width: 100%;
    height: auto;
    min-height: 48px;
  }
  .chip { max-width: 100%; }
}

/* ---------- teaching ---------- */

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

.guide-ring {
  position: absolute;
  border: 4px solid var(--ak-accent-2);
  border-radius: var(--wobble);
}

.guide-arrow {
  position: absolute;
  width: 24px;
  height: 40px;
  fill: none;
  stroke: var(--ak-accent-2);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.guide-say {
  position: absolute;
  max-width: min(340px, calc(100vw - 24px));
  margin: 0;
  padding: 10px 14px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble-2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
}

/* ---------- in-page sheets ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) var(--edge-r) var(--edge-b) var(--edge-l);
  background: color-mix(in srgb, var(--ak-bg) 86%, transparent);
}

.sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 460px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 24px 20px 16px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble);
  background: var(--ak-surface);
  color: var(--ak-ink);
  rotate: -0.6deg;
}

.ptape {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 72px;
  height: 18px;
  background: var(--ak-accent-2);
  translate: -50% 0;
  rotate: -3deg;
}

.sheet-title {
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 17px;
  line-height: 1.4;
}

.sheet-body p { margin: 0; }

.sheet-next {
  padding: 8px 12px;
  border-left: 5px solid var(--ak-accent-2);
  background: var(--ak-bg);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.sheet-list {
  margin: 0;
  padding-left: 20px;
  font-size: 16px;
  line-height: 1.4;
}

.sheet-list li + li { margin-top: 4px; }

.sheet-brief {
  font-family: var(--ak-font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
}

.sheet-quiet {
  color: var(--ak-ink-muted);
  font-size: 15px;
}

.sheet-problem {
  padding: 6px 10px;
  border-left: 5px solid var(--ak-ink);
  background: var(--ak-bg);
  font-weight: 700;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.btn {
  min-height: 48px;
  padding: 0 18px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  font-weight: 700;
  font-size: 17px;
}

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

.btn.save {
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  border-color: var(--ak-choice-selected-border);
}

.name-input {
  width: 100%;
  min-height: 52px;
  padding: 6px 12px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble-2);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 30px;
  font-weight: 700;
}

.name-count {
  align-self: flex-end;
  color: var(--ak-ink-muted);
  font-size: 14px;
}

.ideas {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.idea {
  min-height: 48px;
  padding: 0 14px;
  border: 2px dashed var(--ak-ink);
  border-radius: var(--wobble-2);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 24px;
  font-weight: 700;
}

.shelf-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shelf-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 4px solid var(--ak-ink);
  border-radius: 0 0 3px 6px;
}

.shelf-open {
  display: flex;
  flex: 1 1 auto;
  align-items: flex-end;
  gap: 10px;
  min-height: 60px;
  padding: 8px 4px 4px;
  text-align: left;
  user-select: none;
  -webkit-touch-callout: none;
}

.shelf-stones {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex: 0 0 auto;
}

.shelf-stones .stone { height: 26px; width: auto; }

.shelf-name {
  font-family: var(--ak-font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  overflow-wrap: anywhere;
}

.shelf-delete { flex: 0 0 auto; }

/* ---------- the pinned print: the saved palette takes the whole wall ---------- */

.print {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto auto;
  grid-template-areas: "name" "art" "shelf" "line" "next" "back";
  justify-items: center;
  gap: 10px;
  padding: max(66px, env(safe-area-inset-top)) var(--edge-r) var(--edge-b) var(--edge-l);
  background-color: var(--ak-bg);
  background-image: var(--ak-backdrop-layer, none);
  background-size: cover;
  background-position: center bottom;
  color: var(--ak-ink);
}

.print-name {
  grid-area: name;
  max-width: 100%;
  margin: 0;
  font-family: var(--ak-font-display);
  font-size: var(--name-size, 18dvh);
  font-weight: 700;
  line-height: 0.85;
  padding: 0 4px;
  text-align: center;
  overflow-wrap: anywhere;
}

.print-art {
  grid-area: art;
  position: relative;
  height: 100%;
  min-height: 0;
  max-width: 100%;
  aspect-ratio: 4 / 5;
  margin: 0;
  padding: 10px;
  border: 2px solid var(--ak-ink);
  background: var(--ak-surface);
  rotate: 1.5deg;
}

.print-art::before,
.print-art::after {
  content: '';
  position: absolute;
  top: -10px;
  width: 64px;
  height: 18px;
  background: var(--ak-accent-2);
}

.print-art::before { left: -18px; rotate: -35deg; }
.print-art::after { right: -18px; rotate: 35deg; }

.print-art svg {
  display: block;
  width: 100%;
  height: 100%;
}

.print-shelf {
  grid-area: shelf;
  position: relative;
  width: min(100%, 420px);
  padding-bottom: 6px;
}

.print-pebbles {
  display: grid;
  grid-template-columns: 0.99fr 1.88fr 2.52fr 1.08fr 1.44fr;
  align-items: end;
  gap: 6px;
  padding: 0 10px;
}

.plank {
  display: block;
  height: 10px;
  border: 2px solid var(--ak-ink);
  border-radius: 2px 6px 3px 5px;
  background: var(--ak-bg);
}

.print-line {
  grid-area: line;
  max-width: 34em;
  margin: 0;
  padding: 8px 14px;
  background: var(--ak-bg);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.print-back {
  grid-area: back;
  min-height: 52px;
  padding: 0 22px;
  border-radius: var(--wobble);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 26px;
  font-weight: 700;
}

@media (orientation: landscape) {
  .print {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas: "art name" "art shelf" "art line" "art next" "art back";
    align-items: center;
    padding-top: max(30px, env(safe-area-inset-top));
    padding-right: calc(var(--edge-r) + 60px);
  }
  .print-shelf { align-self: end; }
  .print-art {
    align-self: center;
    height: min(calc(100dvh - 56px - env(safe-area-inset-top) - env(safe-area-inset-bottom)), calc((45vw - 30px) * 1.25));
    max-height: calc(100dvh - 56px);
  }
}

@media (orientation: portrait) and (max-height: 700px) {
  .words-say,
  .peb-say { font-size: 12px; line-height: 1.1; }
  .brief { padding: 2px 3px 2px 8px; }
  .brief-tag { display: none; }
  .brief-say { font-size: 12.5px; line-height: 1.2; }
  .brief-act { padding: 6px 8px; font-size: 17px; }
  .tool { height: 52px; }
}

@media (max-width: 380px) {
  .top { gap: 4px; }
  .logo { height: 22px; }
  .hint,
  .done {
    min-width: 48px;
    padding: 0 8px;
    font-size: 22px;
  }
}

@media (orientation: landscape) {
  .dial { min-height: 42px; }
  .dial input { height: 40px; }
  .dial-ends { display: none; }
  .card { gap: 0; padding: 24px 60px 2px 12px; align-self: end; }
  .card-tag { top: -2px; }
  /* Sideways the close sits inside the card, so it never covers Done in the row above. */
  .card-close { top: 4px; right: 4px; }
}

/* ---------- the opening keeps the sketchbook: graph paper over the gesso wash, the lines as taped notes ---------- */

#activity-start#activity-start.has-backdrop::after {
  background-image:
    linear-gradient(color-mix(in srgb, var(--ak-outline) 60%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ak-outline) 60%, transparent) 1px, transparent 1px);
  background-size: 28px 28px;
}

#activity-start#activity-start .ak-scene-lines { gap: 22px; }

#activity-start#activity-start .ak-scene-line {
  position: relative;
  margin: 0;
  padding: 16px 18px 12px;
  border: 2px solid var(--ak-ink);
  border-radius: 2px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  rotate: -1.4deg;
}

#activity-start#activity-start .ak-scene-line:nth-child(even) { rotate: 1.2deg; }

#activity-start#activity-start .ak-scene-line::before {
  content: '';
  position: absolute;
  top: -11px;
  left: 50%;
  width: 78px;
  height: 20px;
  background: var(--ak-accent-2);
  translate: -50% 0;
  rotate: 3deg;
}

/* ---------- the warning points at the text pebble ---------- */

.tape-arrow {
  position: absolute;
  right: 6%;
  top: 30px;
  z-index: 3;
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.peb.warned .stone { outline: 3px dashed var(--ak-ink); outline-offset: 3px; border-radius: 40%; }

/* Sits over the lower right of the picture, clear of the lettering in all three pictures. */
.board-note {
  position: absolute;
  right: 3%;
  bottom: 17%;
  z-index: 3;
  max-width: 58%;
  margin: 0;
  padding: 6px 10px 5px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble-2);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.05;
  rotate: -2.5deg;
  pointer-events: none;
}

.board-note::before {
  content: '';
  position: absolute;
  top: -9px;
  left: 18px;
  width: 44px;
  height: 14px;
  background: var(--ak-accent-2);
  rotate: -6deg;
}

/* On a small board the note would crowd the picture; the tape and the ringed text pebble carry the warning there. */
@container stage (max-height: 280px) {
  .board-note { display: none !important; }
}

@media (orientation: landscape) {
  .print { gap: 6px; }
  .print-shelf { width: min(100%, 300px); }
  .print-line { padding: 4px 10px; font-size: 15px; line-height: 1.3; }
  .print-next { padding: 8px 12px 6px; }
  .print-next-tag { display: none; }
  .print-next-word { font-size: 28px; }
  .print-next-word::before { content: 'Next brief: '; font-family: var(--ak-font-body); font-size: 14px; }
  .print-next-say { font-size: 13px; }
  .print-back { min-height: 48px; }
}

/* While a colour's sliders are open on an upright phone, the editor gets compact so the picture stays big. */
@media (orientation: portrait) {
  .play.card-open .card { padding: 16px 60px 4px 10px; }
  .play.card-open .dial { grid-template-columns: 86px minmax(0, 1fr); min-height: 42px; }
  .play.card-open .dial input { height: 36px; }
  .play.card-open .dial-name { font-size: 15px; }
  .play.card-open .dial-ends { margin-top: -5px; font-size: 11px; }
  .play.card-open .pebbles { max-width: 360px; }
  .play.card-open .card-undo { min-height: 48px; bottom: 6px; }
}

/* ---------- the next brief on the print: a taped note of its own ---------- */

.print-next {
  grid-area: next;
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "tag tag" "word strip" "say say";
  align-items: center;
  column-gap: 12px;
  width: min(100%, 420px);
  padding: 12px 14px 10px;
  border: 2px solid var(--ak-ink);
  border-radius: var(--wobble-2);
  background: var(--ak-surface);
  color: var(--ak-ink);
  rotate: -1.5deg;
}

.print-next::before {
  content: '';
  position: absolute;
  top: -10px;
  right: 22px;
  width: 64px;
  height: 18px;
  background: var(--ak-accent);
  rotate: 4deg;
}

.print-next-tag { grid-area: tag; color: var(--ak-ink-muted); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.print-next-word { grid-area: word; font-family: var(--ak-font-display); font-size: 34px; font-weight: 700; line-height: 1; }
.print-next-strip { grid-area: strip; height: 12px; }
.print-next-say { grid-area: say; margin-top: 4px; font-size: 15px; font-weight: 700; line-height: 1.3; }

/* ---------- motion: slow and quiet, and only when it is wanted ---------- */

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .mock svg [data-role] { transition: fill 260ms ease, stroke 260ms ease; }
  :root:not(.ac-still) .mock[data-wash] svg [data-role] { animation: wash 700ms ease-out; }
  :root:not(.ac-still) .mock[data-wash="background"] svg [data-role]:not([data-role="background"]),
  :root:not(.ac-still) .mock[data-wash="surface"] svg [data-role]:not([data-role="surface"]),
  :root:not(.ac-still) .mock[data-wash="main"] svg [data-role]:not([data-role="main"]),
  :root:not(.ac-still) .mock[data-wash="accent"] svg [data-role]:not([data-role="accent"]),
  :root:not(.ac-still) .mock[data-wash="text"] svg [data-role]:not([data-role="text"]) { animation: none; }
  :root:not(.ac-still) .mock.swap { animation: mock-in 420ms ease-out; }
  :root:not(.ac-still) .stone,
  :root:not(.ac-still) .peb-word { transition: translate 300ms ease-out; }
  :root:not(.ac-still) .kept { transition: opacity 600ms ease; }
  :root:not(.ac-still) .kept.on { animation: settle 600ms ease-out; }
  :root:not(.ac-still) .tape-tag.press { animation: tape-press 420ms ease-out both; }
  :root:not(.ac-still) .tape-tag.peel { animation: tape-peel 360ms ease-in both; }
  :root:not(.ac-still) .card.lift { animation: card-lift 320ms ease-out; }
  :root:not(.ac-still) .guide-ring { animation: ring 1.6s ease-in-out infinite; }
  :root:not(.ac-still) .guide-arrow { animation: nudge 1.6s ease-in-out infinite; }
  :root:not(.ac-still) .print.in { animation: print-in 520ms ease-out both; }
  :root:not(.ac-still) .print.in .print-art { animation: pin 640ms ease-out both; }
  :root:not(.ac-still) .print.in .print-pebbles .stone { animation: drop 400ms ease-out both; animation-delay: calc(700ms + var(--i) * 260ms); }
  :root:not(.ac-still) .sheet.in .sheet-panel { animation: card-lift 300ms ease-out; }

  @keyframes wash { from { opacity: 0.55; } to { opacity: 1; } }
  @keyframes mock-in { from { opacity: 0; translate: var(--from, 0) 0; } to { opacity: 1; translate: 0 0; } }
  @keyframes settle { from { opacity: 0; translate: 0 -6px; } to { opacity: 1; translate: 0 0; } }
  @keyframes tape-press { from { opacity: 0; scale: 1.12; rotate: -7deg; } to { opacity: 1; scale: 1; rotate: -2.5deg; } }
  @keyframes tape-peel { from { opacity: 1; translate: 0 0; rotate: -2.5deg; } to { opacity: 0; translate: 10px -14px; rotate: 6deg; } }
  @keyframes card-lift { from { opacity: 0; translate: 0 14px; } to { opacity: 1; translate: 0 0; } }
  @keyframes ring { 0%, 100% { scale: 1; opacity: 1; } 50% { scale: 1.08; opacity: 0.55; } }
  @keyframes nudge { 0%, 100% { translate: 0 0; } 50% { translate: 0 5px; } }
  @keyframes print-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes pin { from { opacity: 0; translate: 0 -18px; rotate: -3deg; } to { opacity: 1; translate: 0 0; rotate: 1.5deg; } }
  @keyframes drop {
    0% { opacity: 0; translate: 0 -70px; }
    60% { opacity: 1; translate: 0 3px; }
    80% { translate: 0 -2px; }
    100% { opacity: 1; translate: 0 0; }
  }
}
