/* Potting Room Escape: a painted room laid flat on a dark table, paper pinned around it. */

:root {
  --status-h: var(--ac-status-h, 76px);
  --paper:
    radial-gradient(circle at 12% 20%, color-mix(in srgb, var(--ak-accent) 9%, transparent) 0 14px, transparent 30px),
    radial-gradient(circle at 88% 82%, color-mix(in srgb, var(--ak-accent-2) 12%, transparent) 0 10px, transparent 26px),
    radial-gradient(circle at 70% 12%, color-mix(in srgb, var(--ak-accent) 6%, transparent) 0 6px, transparent 16px),
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--ak-ink) 6%, transparent), transparent 70%),
    var(--ak-surface);
  --lift: 0 14px 30px rgba(0, 0, 0, 0.6);
  --pin: 0 2px 3px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  min-height: 100dvh;
  background-color: var(--ak-bg);
  background-image:
    var(--ak-bg-art),
    var(--ak-backdrop-layer, linear-gradient(color-mix(in srgb, var(--ak-bg) 78%, transparent), color-mix(in srgb, var(--ak-bg) 78%, transparent)), url("art/potting-room.jpg"));
  background-size: var(--ak-bg-size), cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 17px;
  -webkit-tap-highlight-color: transparent;
}
:root.ac-lights-up body { background-image: var(--ak-bg-art), linear-gradient(color-mix(in srgb, var(--ak-bg) 45%, transparent), color-mix(in srgb, var(--ak-bg) 45%, transparent)), url("art/potting-room.jpg"); }

button { font: inherit; color: inherit; }
/* Nothing in the room, on its cards or on the closing page is for selecting: a long press or a drag
   should never paint the words as picked. */
.play,
.sheet,
#activity-chrome-ending { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

/* The chrome's note clears itself on the next tap; that tap still reaches the tray beneath it. */
#activity-chrome-toast { pointer-events: none; }
button:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: 2px; }

/* ---------- The play screen: the room above, the table below ---------- */

.play {
  height: 100dvh;
  padding:
    var(--status-h)
    max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 10px;
  touch-action: manipulation;
  overflow: hidden;
}

.board {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  height: 100%;
  min-height: 0;
  container-type: size;
}

.room {
  position: relative;
  /* The table takes what it needs; the room fills the rest, edge to edge when it can. */
  width: min(100cqw, 100cqh * 3 / 4);
  aspect-ratio: 3 / 4;
  border: 1px solid color-mix(in srgb, var(--ak-ink) 22%, transparent);
  border-radius: var(--ak-radius);
  box-shadow: 0 26px 50px rgba(0, 0, 0, 0.7), 0 0 0 6px color-mix(in srgb, var(--ak-bg) 70%, transparent);
  overflow: hidden;
  container-type: inline-size;
  user-select: none;
  -webkit-user-select: none;
}
.room-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
:root.ac-lights-up .room-art { filter: brightness(1.5) contrast(1.05); }
.room.is-dim .room-art { filter: brightness(0.45); }
/* Out through the door: the room goes dark and the fog comes in after you. The places are done with. */
.room.is-out .room-art { filter: brightness(0.3) saturate(0.6); }
.room.is-out .spots,
.room.is-out .candle,
.room.is-out .teach { display: none; }
.room::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 4;
  background:
    radial-gradient(ellipse at 10% 50%, color-mix(in srgb, var(--ak-ink) 30%, transparent), transparent 60%),
    linear-gradient(to top, color-mix(in srgb, var(--ak-ink-muted) 30%, transparent), transparent 55%);
  opacity: 0;
  pointer-events: none;
}
.room.is-out::after { opacity: 1; }

.room-logo {
  position: absolute;
  top: 1.5%;
  left: 2%;
  height: 11%;
  width: auto;
  pointer-events: none;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.8));
}

/* ---------- Hot spots and their pinned labels ---------- */

.spots { position: absolute; inset: 0; }

.spot {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: max(48px, var(--w));
  height: max(48px, var(--h));
  padding: 0;
  /* Only a faint edge: the pinned label marks the place, the painting does the rest. */
  border: 1px dashed color-mix(in srgb, var(--ak-ink) 12%, transparent);
  border-radius: var(--ak-radius);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.spot:active { background: color-mix(in srgb, var(--ak-accent) 10%, transparent); }
.spot.is-target {
  border: 2px solid var(--ak-accent);
  background: color-mix(in srgb, var(--ak-accent) 8%, transparent);
}
.spot.is-over { background: color-mix(in srgb, var(--ak-accent) 26%, transparent); border-width: 3px; }
/* While an item is held, every place it could go wears a wax-yellow label. */
.room.is-holding .spot-label { border-color: var(--ak-accent); color: var(--ak-ink); }

/* What the player is holding, said on the table just above the tray, where the room stays uncovered. */
.holding {
  grid-area: best;
  margin: 0 4px;
  padding: 6px 10px;
  border: 1px solid var(--ak-accent);
  border-left-width: 4px;
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: var(--lift);
  font-size: 18px;
  line-height: 1.25;
}

/* An item dragged from the tray rides under the finger. */
.drag-ghost {
  position: fixed;
  z-index: 60;
  width: auto;
  height: 64px;
  translate: -50% -60%;
  pointer-events: none;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.7));
}
.drag-ghost.drag-trowel { rotate: -48deg; }

.spot-label {
  position: absolute;
  bottom: 0;
  left: 50%;
  translate: -50% 55%;
  padding: 2px 9px 3px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--paper);
  color: var(--ak-ink);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6);
  font-size: 16px;
  font-style: italic;
  line-height: 1.2;
  white-space: nowrap;
  rotate: -2deg;
  /* The label is part of its place: a tap or a drop on it counts. */
  cursor: pointer;
}
.spot[data-align="end"] .spot-label { left: auto; right: 4px; translate: 0 55%; rotate: 2deg; }
.spot[data-align="start"] .spot-label { left: 4px; translate: 0 55%; }
.spot[data-spot="drawer"] .spot-label { bottom: auto; top: 100%; translate: -50% 4px; }
/* Pinned at the top of the rack, clear of the candle below it */
.spot[data-spot="rack"] .spot-label { bottom: auto; top: 0; translate: 0 -60%; }

/* ---------- Things the room keeps: the open drawer, the peat, the fog ---------- */

.drawer-gap {
  position: absolute;
  left: 61.2%;
  top: 61.6%;
  width: 23.6%;
  height: 2.2%;
  border-top: 1px solid color-mix(in srgb, var(--ak-accent) 45%, var(--ak-bg));
  background: linear-gradient(to bottom, var(--ak-bg), color-mix(in srgb, var(--ak-bg) 60%, transparent));
  pointer-events: none;
}

.peat {
  transform-origin: 50% 100%;
  scale: var(--heap, 1);
  position: absolute;
  left: 54%;
  top: 49%;
  width: 11.5%;
  height: auto;
  overflow: visible;
  pointer-events: none;
}
.peat-shadow { fill: rgba(0, 0, 0, 0.55); }
.peat-mound { fill: color-mix(in srgb, var(--ak-bg) 86%, var(--ak-accent)); stroke: color-mix(in srgb, var(--ak-accent) 40%, var(--ak-bg)); stroke-width: 0.9; }
.peat-lump { fill: color-mix(in srgb, var(--ak-ink-muted) 22%, var(--ak-bg)); }
.peat-crumb { fill: color-mix(in srgb, var(--ak-bg) 80%, var(--ak-accent)); }
.peat-grit { fill: color-mix(in srgb, var(--ak-ink-muted) 45%, var(--ak-bg)); }

.fog {
  position: absolute;
  left: 0;
  top: 13.7%;
  width: 20%;
  height: 60.5%;
  border-right: 3px solid color-mix(in srgb, var(--ak-accent) 22%, var(--ak-bg));
  box-shadow: inset -10px 0 18px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
/* The open doorway in the room is drawn with the open door's card parts, so the two read as one place. */
.fog svg { width: 100%; height: 100%; display: block; }
/* Pale fog spills a little way onto the floor in front of the open door. */
.fog::after {
  content: '';
  position: absolute;
  left: 0;
  top: 100%;
  width: 150%;
  height: 14%;
  background: radial-gradient(ellipse at 0% 0%, color-mix(in srgb, var(--ak-ink) 22%, transparent), transparent 70%);
}

/* ---------- Guided first steps ---------- */

.teach { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.teach-ring {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: max(48px, var(--w));
  height: max(48px, var(--h));
  border: 3px solid var(--ak-accent);
  border-radius: var(--ak-radius);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.55);
}
.teach-arrow {
  position: absolute;
  width: 24px;
  overflow: visible;
}
.teach-arrow path {
  fill: none;
  stroke: var(--ak-accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.teach-caption {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 3%;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--ak-accent);
  border-left-width: 4px;
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: var(--lift);
  font-size: 19px;
  line-height: 1.3;
}

.teach-main,
.teach-more { display: block; }
.teach-more { margin-top: 6px; font-size: 18px; color: var(--ak-ink-muted); }

.reason {
  position: absolute;
  left: 24%;
  right: 4%;
  /* Over the bench, clear of the open door and of the ending card that lies over the table. */
  top: 44%;
  z-index: 6;
  margin: 0;
  padding: 14px 16px 12px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--paper);
  color: var(--ak-ink);
  box-shadow: var(--lift);
  font-size: 19px;
  font-style: italic;
  line-height: 1.3;
  rotate: -1.5deg;
}
.reason::before,
.note::before,
.card::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ak-accent);
  box-shadow: var(--pin);
  translate: -50% 0;
}

/* ---------- Paper tags: Hint, Lights up, Leave for now ---------- */

.tags { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.table-tags { grid-area: tags; display: flex; padding-left: 2px; }

/* The candle on the bench breathes: a slow, low glow that draws the eye to the bench and the painting above it. */
.candle {
  position: absolute;
  left: 68%;
  top: 42.9%;
  width: 30%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--ak-accent) 85%, transparent) 0%, color-mix(in srgb, var(--ak-accent) 30%, transparent) 26%, transparent 66%);
  mix-blend-mode: screen;
  opacity: 0.7;
  pointer-events: none;
}

.tag {
  position: relative;
  min-width: 48px;
  min-height: 48px;
  padding: 0 14px 0 22px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--paper);
  color: var(--ak-ink);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.55);
  font-size: 17px;
  font-style: italic;
  cursor: pointer;
  touch-action: manipulation;
  rotate: -2deg;
}
.tag + .tag { rotate: 1.5deg; }
.tag::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  width: 7px;
  height: 7px;
  border: 1px solid var(--ak-ink-muted);
  border-radius: 50%;
  translate: 0 -50%;
}
.tag:active { background: var(--ak-choice-bg); }
.tag[aria-pressed="true"] { border-color: var(--ak-accent); }
.tag[aria-pressed="true"]::before { background: var(--ak-accent); border-color: var(--ak-accent); }
.tag:disabled { opacity: 0.55; cursor: default; }

/* The Hint tag wears its ladder: three small rungs, filled as each step is read for the lock at hand */
.rungs { display: inline-grid; gap: 2px; margin-left: 6px; vertical-align: middle; }
.rung { display: block; width: 14px; height: 3px; border: 1px solid var(--ak-ink-muted); border-radius: 1px; }
.rung.is-read { border-color: var(--ak-accent); background: var(--ak-accent); }

/* ---------- The table: the ledger card and the tray ---------- */

.table {
  width: min(100%, 520px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "note note" "best best" "tags tags" "tray kept";
  gap: 6px 14px;
  align-content: start;
  padding: 4px 4px 0;
}
.note { grid-area: note; }
.tray-row { grid-area: tray; }
.kept { grid-area: kept; align-self: center; }
.table > .note-best { grid-area: best; margin: 0 4px; font-size: 16px; }

.note {
  position: relative;
  margin: 0;
  padding: 14px 14px 8px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--paper);
  color: var(--ak-ink);
  box-shadow: var(--lift);
  rotate: -0.6deg;
}
.note-title {
  margin: 0 0 4px;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 18px;
  letter-spacing: 0.04em;
  color: var(--ak-ink-muted);
}
.note-torn { font-family: var(--ak-font-body); font-size: 13px; font-style: italic; letter-spacing: 0; }
.note-best { margin: 6px 0 0; padding-left: 8px; border-left: 3px solid var(--ak-accent); font-size: 16px; font-style: italic; line-height: 1.3; color: var(--ak-ink); }

/* The chain of three steps: an empty box until a step is done, then a ticked one and the caretaker's line */
.steps { margin: 2px 0 0; padding: 0; list-style: none; display: grid; gap: 3px; }
.step {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  column-gap: 8px;
  align-items: baseline;
  font-size: 16px;
  line-height: 1.3;
}
.step-box {
  position: relative;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--ak-ink-muted);
  border-radius: 1px;
  translate: 0 2px;
}
.step.is-done .step-box { border-color: var(--ak-accent); background: var(--ak-accent); }
.step.is-done .step-box::after {
  content: '';
  position: absolute;
  left: 3.5px;
  top: 0;
  width: 4px;
  height: 8px;
  border: solid var(--ak-btn-ink);
  border-width: 0 2px 2px 0;
  rotate: 45deg;
}
.step.is-done .step-name { color: var(--ak-ink-muted); }
.step-sub { grid-column: 2; font-size: 15px; color: var(--ak-ink); }
.step-ledger { font-style: italic; }
/* The next move, once its item is in the tray: set apart in wax yellow so it reads first */
.step.is-next .step-box { border-color: var(--ak-accent); }
.step-next { padding-left: 6px; border-left: 3px solid var(--ak-accent); }

/* The time to beat: a small candle at the head of the line that burns down to your quickest way out */
.note-best { display: flex; align-items: center; gap: 8px; }
.burn-candle { flex: 0 0 auto; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; width: 12px; height: 34px; }
.burn-wax { display: block; width: 8px; height: calc(4px + 22px * var(--left, 1)); border-radius: 1px 1px 0 0; background: var(--ak-ink); }
.burn-flame { display: block; width: 6px; height: 8px; margin-bottom: 1px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: var(--ak-accent); box-shadow: 0 0 6px var(--ak-accent); }
.burn.is-out .burn-flame { background: transparent; box-shadow: none; border: 1px solid var(--ak-ink-muted); }

.tray-row { display: flex; align-items: center; gap: 10px; }
.tray {
  position: relative;
  flex: 1 1 auto;
  padding: 14px 10px 6px;
  border: 1px solid color-mix(in srgb, var(--ak-accent) 18%, var(--ak-outline));
  border-radius: var(--ak-radius);
  background:
    repeating-linear-gradient(90deg, transparent 0 22px, color-mix(in srgb, var(--ak-accent) 5%, transparent) 22px 24px, transparent 24px 41px),
    linear-gradient(color-mix(in srgb, var(--ak-accent) 9%, var(--ak-surface)), color-mix(in srgb, var(--ak-accent) 4%, var(--ak-surface)));
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.7), 0 10px 20px rgba(0, 0, 0, 0.5);
}
.tray-caption {
  position: absolute;
  top: -11px;
  left: 12px;
  margin: 0;
  padding: 1px 8px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink-muted);
  font-size: 16px;
  font-style: italic;
  white-space: nowrap;
  max-width: calc(100% - 24px);
}
.tray-caption.is-holding { color: var(--ak-btn-ink); border-color: var(--ak-accent); background: var(--ak-accent); font-style: normal; }
.tray-slots { display: flex; gap: 8px; }

.slot,
.item {
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  border-radius: var(--ak-radius);
}
.slot { border: 1px dashed color-mix(in srgb, var(--ak-ink) 18%, transparent); }
.item {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--ak-outline);
  background: color-mix(in srgb, var(--ak-ink) 14%, var(--ak-surface));
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.6);
  cursor: grab;
  /* A press can become a drag, so the tray item keeps the finger to itself. */
  touch-action: none;
  overflow: hidden;
}
.item img { pointer-events: none; }
/* The item the next lock wants: a wax-yellow ring until it is picked up */
.item.is-waiting { border: 2px solid var(--ak-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ak-accent) 35%, transparent), 0 3px 6px rgba(0, 0, 0, 0.6); }
.item[data-item="trowel"] img { height: 64px; width: auto; rotate: -48deg; }
.item[data-item="key"] img { width: 52px; height: auto; }
.item[aria-pressed="true"] {
  border: 3px solid var(--ak-accent);
  background: color-mix(in srgb, var(--ak-accent) 34%, var(--ak-surface));
  translate: 0 -6px;
  box-shadow: 0 0 0 3px var(--ak-bg), 0 0 0 5px var(--ak-accent), 0 12px 16px rgba(0, 0, 0, 0.7);
}

.tag-leave { flex: 0 0 auto; }

.kept {
  margin: 0;
  min-height: 18px;
  font-size: 15px;
  font-style: italic;
  color: var(--ak-ink-muted);
  text-align: left;
}
.kept.is-trouble { color: var(--ak-ink); }

/* ---------- Close-up cards: foxed paper over the dimmed room ---------- */

.sheet {
  position: fixed;
  inset: var(--status-h) 0 0 0;
  z-index: 20;
  /* The dimmed room behind a card still takes taps: another place opens at once, the tray still works. */
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--ak-bg) 72%, transparent);
  touch-action: manipulation;
}
.card {
  position: relative;
  pointer-events: auto;
  width: min(100%, 400px);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 18px 12px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--paper);
  color: var(--ak-ink);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.7);
  display: grid;
  gap: 10px;
  rotate: 0.6deg;
}
.card-title {
  margin: 0;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 24px;
  text-align: center;
  border-bottom: 3px double var(--ak-outline);
  padding-bottom: 6px;
}
.card-media { display: grid; justify-items: center; }
.card-side { display: grid; gap: 10px; align-content: center; }
.card-words { display: grid; gap: 8px; justify-items: center; }
.card-text { margin: 0; font-size: 17px; line-height: 1.35; text-align: center; }
.card-say { margin: 0; min-height: 0; font-size: 17px; line-height: 1.35; text-align: center; font-style: italic; }
.card-say:empty { display: none; }
.card-say.is-wrong {
  padding: 8px 10px;
  border-left: 4px solid var(--ak-accent-2);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-style: normal;
  text-align: left;
}
.card-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 14px; }

.act {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid color-mix(in srgb, var(--ak-accent) 60%, var(--ak-outline));
  border-radius: var(--ak-radius);
  background: color-mix(in srgb, var(--ak-accent) 14%, var(--ak-surface));
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 18px;
  letter-spacing: 0.03em;
  cursor: pointer;
  touch-action: manipulation;
}
.act:active { background: var(--ak-choice-bg); }
.act-quiet {
  border: 0;
  border-bottom: 1px solid var(--ak-outline);
  background: none;
  font-family: var(--ak-font-body);
  font-style: italic;
  font-size: 17px;
  padding: 0 8px;
}

/* The painting, cut from the room itself */
.plate-wrap { width: min(100%, 340px); }
.plate {
  width: 100%;
  aspect-ratio: 338 / 247;
  background-image: url("art/potting-room.jpg");
  background-size: 227.2% auto;
  background-position: 58.6% 21.6%;
  border: 1px solid var(--ak-outline);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
}
.crop {
  border: 1px solid var(--ak-outline);
  background-image: url("art/potting-room.jpg");
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
}
.crop-pot { height: 180px; aspect-ratio: 153 / 300; background-size: 502% auto; background-position: 100% 87%; }
.crop-lock { width: 130px; aspect-ratio: 120 / 140; background-size: 640% auto; background-position: 9.4% 40.9%; }

.names {
  display: grid;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
  text-align: center;
  line-height: 1.15;
}
.names li {
  padding: 3px 1px;
  border-top: 1px solid var(--ak-outline);
}
.names-plate { grid-template-columns: 25% 25% 22% 28%; }
.names-packets { grid-template-columns: repeat(4, 1fr); gap: 4px; }
.clue-box {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--ak-accent) 55%, var(--ak-outline));
  border-radius: var(--ak-radius);
  background: var(--ak-bg);
  text-align: left;
}
.clue-box-head { margin: 0 0 4px; font-size: 13px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ak-ink-muted); }
.clue-box-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 14px;
  font-size: 20px;
  line-height: 1.3;
  color: var(--ak-ink);
}
/* The room's other places along the foot of a card: small paper tags, one tap each */
.card-places { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; padding-top: 8px; border-top: 1px dashed var(--ak-outline); }
.places-head { font-size: 15px; font-style: italic; color: var(--ak-ink-muted); }
.place {
  min-width: 48px;
  min-height: 48px;
  padding: 0 10px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}
.place:active { border-color: var(--ak-accent); }
/* Upright the row is the width of a thumb's reach: the four places fit on one line without their lead-in. */
@media (orientation: portrait) {
  .places-head { display: none; }
  .place { padding: 0 8px; }
}

.packets { width: min(100%, 340px); }
.packets img { display: block; width: 100%; height: auto; }

/* The brass lock: the painted body, four turning dials laid over its windows */
.lock { width: min(100%, 320px); display: grid; gap: 8px; justify-items: center; }
.lock-plate { width: 100%; }
.lock-plate { position: relative; container-type: inline-size; }
.lock-plate > img { display: block; width: 100%; height: auto; }
.dial {
  position: absolute;
  left: calc(var(--c) - 5.73%);
  top: 29.9%;
  width: 11.46%;
  height: 41.6%;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 2px;
  background: linear-gradient(to bottom,
    color-mix(in srgb, var(--ak-accent) 35%, var(--ak-bg)) 0%,
    color-mix(in srgb, var(--ak-accent) 85%, var(--ak-bg)) 22%,
    color-mix(in srgb, var(--ak-accent) 78%, var(--ak-ink)) 50%,
    color-mix(in srgb, var(--ak-accent) 85%, var(--ak-bg)) 78%,
    color-mix(in srgb, var(--ak-accent) 35%, var(--ak-bg)) 100%);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-body);
  font-weight: 600;
  font-size: 13cqw;
  line-height: 1;
  pointer-events: none;
}
.dial-digit { display: block; }
.dial.is-wrong { box-shadow: inset 0 0 0 2px var(--ak-accent-2); }
.dial.is-wrong::after {
  content: '';
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 6%;
  height: 4px;
  background: var(--ak-accent-2);
}
.dial.is-right { box-shadow: inset 0 0 0 2px var(--ak-ink); }
.dial.is-chosen { outline: 3px solid var(--ak-ink); outline-offset: 2px; }

/* The chosen dial also wears a bone-white pointer under it: a shape as well as a ring. */
.dial-mark {
  position: absolute;
  left: calc(var(--c) - 9px);
  top: 76%;
  width: 18px;
  height: 12px;
  background: var(--ak-ink);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  pointer-events: none;
}

/* Each dial's tap area is its whole column of the lock, wider than the brass face. */
.dial-hit {
  position: absolute;
  left: calc(var(--c) - max(24px, 9.35%));
  top: 18%;
  width: max(48px, 18.7%);
  height: 64%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.dial-hit:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: -3px; }

.keypad {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  gap: 8px;
}
.key {
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--ak-accent) 45%, var(--ak-outline));
  border-radius: var(--ak-radius);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  font-weight: 600;
  font-size: 22px;
  cursor: pointer;
  touch-action: manipulation;
}
.key:active { background: var(--ak-choice-bg); border-color: var(--ak-accent); }
.card-how { font-size: 17px; }

.names-packets li { display: grid; gap: 0; }
.packet-name { font-size: 15px; }
.packet-number { font-size: 24px; font-weight: 600; line-height: 1.1; color: var(--ak-ink); }

/* What a clue means, set apart on the card */
.clue-line {
  margin: 0;
  padding: 6px 10px;
  border-left: 3px solid var(--ak-accent);
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-size: 17px;
  line-height: 1.3;
}
.names-plate li { display: grid; font-size: 15px; }
.plate-place { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ak-ink-muted); }

/* The open garden door on its card: fog and the marsh path where the boards were */
.door-view {
  width: min(100%, 300px);
  aspect-ratio: 4 / 3;
  border: 1px solid var(--ak-outline);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.6);
}
.door-view svg { display: block; width: 100%; height: 100%; }
.ds-wall { fill: color-mix(in srgb, var(--ak-accent) 8%, var(--ak-bg)); }
.ds-sky-dark { stop-color: color-mix(in srgb, var(--ak-ink-muted) 30%, var(--ak-bg)); }
/* The fog is brightest at the horizon, where the marsh path starts. */
.ds-sky-light { stop-color: color-mix(in srgb, var(--ak-ink) 52%, var(--ak-bg)); }
.ds-path { fill: color-mix(in srgb, var(--ak-ink) 55%, var(--ak-bg)); opacity: 0.8; }
.ds-reeds { fill: none; stroke: color-mix(in srgb, var(--ak-bg) 75%, var(--ak-ink-muted)); stroke-width: 1.2; stroke-linecap: round; }
.ds-frame { fill: color-mix(in srgb, var(--ak-accent) 22%, var(--ak-bg)); }
.ds-leaf { fill: color-mix(in srgb, var(--ak-accent) 16%, var(--ak-bg)); stroke: color-mix(in srgb, var(--ak-accent) 35%, var(--ak-bg)); stroke-width: 0.8; }
.ds-plank { fill: none; stroke: var(--ak-bg); stroke-width: 0.8; }
.ds-hasp { fill: color-mix(in srgb, var(--ak-accent) 45%, var(--ak-bg)); }
.ds-shackle { fill: none; stroke: var(--ak-accent); stroke-width: 1.8; }
.ds-padlock { fill: var(--ak-accent); }
.ds-bench { fill: color-mix(in srgb, var(--ak-accent) 20%, var(--ak-bg)); }
.ds-glow { fill: var(--ak-accent); opacity: 0.16; }
.ds-candle { fill: var(--ak-ink); }
.ds-flame { fill: var(--ak-accent); }

/* The player's notes beside the lock: what the painting and the packets said */
.clues {
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-bg);
  text-align: left;
}
.clues-head { margin: 0; font-size: 15px; font-style: italic; color: var(--ak-ink-muted); }
.clues-how { display: none; color: var(--ak-ink); font-style: normal; }
.clue { margin: 0; line-height: 1.3; }
.clue-label {
  display: block;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ak-ink-muted);
}
.clue-text { display: block; font-size: 17px; color: var(--ak-ink); }

.drawer-inside {
  position: relative;
  width: min(100%, 300px);
  height: 104px;
  border: 1px solid var(--ak-outline);
  border-top: 3px solid color-mix(in srgb, var(--ak-accent) 40%, var(--ak-surface));
  background:
    repeating-linear-gradient(90deg, transparent 0 18px, color-mix(in srgb, var(--ak-accent) 6%, transparent) 18px 20px),
    color-mix(in srgb, var(--ak-bg) 70%, var(--ak-surface));
  box-shadow: inset 0 10px 20px rgba(0, 0, 0, 0.75);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.drawer-inside img { position: absolute; left: 50%; top: 50%; height: 220px; width: auto; translate: -50% -50%; rotate: 90deg; }

.find {
  width: 150px;
  padding: 10px;
  background: color-mix(in srgb, var(--ak-ink) 12%, var(--ak-surface));
  border: 1px solid var(--ak-outline);
}
.find img { display: block; width: 100%; height: auto; }

.hints { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; width: 100%; }
.hints-head { margin: 0; font-size: 16px; font-style: italic; color: var(--ak-ink-muted); line-height: 1.3; }
/* The ladder: every rung in view, the read ones open, the next one a button, the rest folded shut */
.hints li { padding: 8px 10px; border-left: 3px solid var(--ak-outline); background: var(--ak-bg); }
.hints li.is-read { border-left-color: var(--ak-accent); }
.hints li.is-shut { border-left-style: dashed; }
.hint-folded { font-size: 16px; font-style: italic; color: var(--ak-ink-muted); }
.hint-climb { margin-top: 4px; }
.hint-step { display: block; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ak-ink-muted); }
.hint-text { display: block; font-size: 18px; line-height: 1.3; }

/* ---------- The drawer's lock, docked on the bench in the scene ---------- */

.sheet.is-docked {
  inset: var(--dock-top, 45%) 0 0 0;
  align-items: flex-end;
  padding: 0;
  background: transparent;
  pointer-events: none;
}
.sheet.is-docked .card {
  pointer-events: auto;
  width: min(100%, 520px);
  max-height: 100%;
  padding: 40px 14px max(10px, env(safe-area-inset-bottom));
  gap: 8px;
  rotate: 0deg;
  border: 0;
  border-top: 3px solid color-mix(in srgb, var(--ak-accent) 45%, var(--ak-bg));
  border-radius: 0;
  /* Oiled wood: the front of the bench the lock is fitted to */
  background:
    repeating-linear-gradient(180deg, transparent 0 9px, color-mix(in srgb, var(--ak-accent) 5%, transparent) 9px 10px),
    linear-gradient(color-mix(in srgb, var(--ak-accent) 9%, var(--ak-surface)), var(--ak-surface) 40%);
  box-shadow: 0 -18px 30px rgba(0, 0, 0, 0.55);
}
.sheet.is-docked .card::before { display: none; }
/* The title becomes a paper tag pinned to the bench edge */
.sheet.is-docked .card-title {
  position: absolute;
  top: 6px;
  left: 14px;
  z-index: 1;
  padding: 2px 12px 3px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--paper);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.6);
  font-size: 17px;
  rotate: -2deg;
}
.sheet.is-docked .card-actions { flex-wrap: nowrap; gap: 6px 12px; }
.sheet.is-docked .card-how { display: none; }
.sheet.is-docked .clues-how { display: inline; }
.sheet.is-docked .clues { padding: 6px 10px; gap: 3px; }
.sheet.is-docked .clue-label { display: inline; margin-right: 6px; }
.sheet.is-docked .clue-label::after { content: ':'; }
.sheet.is-docked .clue-text { display: inline; font-size: 16px; }
.sheet.is-docked .lock { width: min(100%, 260px); gap: 6px; }
.sheet.is-docked .card-say.is-wrong { padding: 6px 10px; font-size: 16px; line-height: 1.3; }
.sheet.is-docked .clues { background: color-mix(in srgb, var(--ak-bg) 80%, transparent); }

/* The number keys: brass studs set in the wood, engraved with their numerals */
.key {
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ak-accent) 70%, var(--ak-bg));
  background: radial-gradient(circle at 38% 32%, color-mix(in srgb, var(--ak-accent) 26%, var(--ak-bg)) 0%, var(--ak-bg) 72%);
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, 0.6), 0 2px 3px rgba(0, 0, 0, 0.5);
  font-family: var(--ak-font-body);
  font-weight: 600;
  font-size: 22px;
  font-variant-numeric: lining-nums;
}
.key:active { translate: 0 1px; box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.7); }

/* ---------- The ending: a card left on the table, the room and its open door still in view ---------- */

body #activity-chrome-ending.site-shriversify {
  justify-content: flex-end;
  padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 34%, rgba(0, 0, 0, 0.8) 58%);
}
/* The case-file page, turned over: foxed paper on a short stack of pages, punched for the binder at its
   left edge (the edge it turns on), a pin at the top, the corner dog-eared, and Case closed stamped in. */
body #activity-chrome-ending.site-shriversify .ac-card {
  position: relative;
  flex: 0 0 auto;
  max-height: 100%;
  overflow-y: auto;
  padding: 26px 22px 14px 44px;
  background:
    radial-gradient(circle at 18px 22%, var(--ak-bg) 0 5px, color-mix(in srgb, var(--ak-outline) 80%, transparent) 5px 6px, transparent 6.5px),
    radial-gradient(circle at 18px 50%, var(--ak-bg) 0 5px, color-mix(in srgb, var(--ak-outline) 80%, transparent) 5px 6px, transparent 6.5px),
    radial-gradient(circle at 18px 78%, var(--ak-bg) 0 5px, color-mix(in srgb, var(--ak-outline) 80%, transparent) 5px 6px, transparent 6.5px),
    linear-gradient(225deg, var(--ak-bg) 0 15px, color-mix(in srgb, var(--ak-ink-muted) 30%, var(--ak-surface)) 15px 22px, transparent 22px),
    linear-gradient(to right, rgba(0, 0, 0, 0.35), transparent 34px),
    var(--paper);
  box-shadow:
    5px 5px 0 -1px color-mix(in srgb, var(--ak-surface) 80%, var(--ak-bg)),
    5px 5px 0 0 var(--ak-outline),
    10px 10px 0 -1px color-mix(in srgb, var(--ak-surface) 60%, var(--ak-bg)),
    10px 10px 0 0 var(--ak-outline),
    0 30px 60px rgba(0, 0, 0, 0.6);
  rotate: -0.6deg;
}
body #activity-chrome-ending.site-shriversify .ac-card::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ak-accent);
  box-shadow: var(--pin);
  translate: -50% 0;
}
body #activity-chrome-ending.site-shriversify .ac-number {
  display: inline-block;
  margin: 2px 0 8px;
  padding: 2px 10px;
  border: 2px solid var(--ak-ink-muted);
  border-radius: 2px;
  color: var(--ak-ink);
  rotate: -3deg;
}
/* Upright the page sits low and compact, so the line about why it ended stays in view above it. */
@media (orientation: portrait) {
  body #activity-chrome-ending.site-shriversify .ac-card { padding: 20px 18px 8px 40px; }
  body #activity-chrome-ending.site-shriversify .ac-number { margin-bottom: 4px; }
  body #activity-chrome-ending.site-shriversify .ac-verdict { margin-bottom: 8px; padding-bottom: 8px; font-size: 22px; }
  body #activity-chrome-ending.site-shriversify .ac-lines { font-size: 15px; line-height: 1.3; }
  body #activity-chrome-ending.site-shriversify .ac-line { margin-bottom: 3px; }
  body #activity-chrome-ending.site-shriversify .ac-actions { margin-top: 6px; }
}
/* The way back in is a real button: wax-yellow, full ink, big enough for a thumb. */
body #activity-chrome-ending.site-shriversify .ac-replay {
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--ak-btn-active);
  border-radius: var(--ak-radius);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
  font-style: normal;
  cursor: pointer;
}
/* The closing line is the page's one line in full ink; the count of the visit sits under it, smaller. */
body #activity-chrome-ending.site-shriversify .ac-line:first-child { color: var(--ak-ink); font-size: 1.08em; }
body #activity-chrome-ending.site-shriversify .ac-line:nth-child(2) { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--ak-outline); }

/* ---------- Turned sideways: the room on one side, the table on the other ---------- */

@media (orientation: landscape) {
  .play {
    padding-top: max(0px, env(safe-area-inset-top));
    /* Clear of the round help button at the top right, so the rack's label is never under it. */
    padding-right: max(64px, env(safe-area-inset-right));
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: minmax(0, 460px) auto;
    justify-content: center;
    align-items: stretch;
    column-gap: 18px;
  }
  .board { order: 2; height: 100%; align-items: center; width: auto; container-type: normal; }
  .room {
    width: auto;
    height: min(100%, calc(60vw * 4 / 3));
  }
  .table {
    order: 1;
    width: 100%;
    padding-top: calc(var(--status-h) + 4px);
    align-content: center;
    max-height: 100%;
    overflow-y: auto;
  }
  .table {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "note note" "tags tags" "tray best" "tray kept";
    column-gap: 14px;
  }

  .table { align-content: safe center; row-gap: 6px; }
  .slot,
  .item { width: 52px; height: 52px; }
  .item[data-item="trowel"] img { height: 58px; }
  .item[data-item="key"] img { width: 46px; }
  .table > .note-best,
  .table > .kept { font-size: 15px; }
  .note { padding-top: 10px; padding-bottom: 6px; }
  .steps { gap: 1px; }
  /* Sideways the table has the width, so its words get the size. */
  .note-title { font-size: 19px; }
  .step { font-size: 17px; }
  .step-sub { font-size: 16px; }
  .tag { font-size: 17px; }
  .tray-caption,
  .kept { font-size: 16px; }
  .spot-label { font-size: 15px; padding: 3px 9px; }
  /* Sideways the lock takes the table half, and the whole room stays in view beside it. */
  /* The card runs the full height; its notes start at the top, right of the status label, and the lock below it. */
  .sheet.is-docked { inset: 0 var(--dock-right, 50%) 0 0; align-items: stretch; justify-content: flex-end; }
  .sheet.is-docked .card {
    width: 100%;
    max-width: 620px;
    padding: max(12px, env(safe-area-inset-top)) 14px 8px;
    border-top: 0;
    border-right: 3px solid color-mix(in srgb, var(--ak-accent) 45%, var(--ak-bg));
    box-shadow: 18px 0 30px rgba(0, 0, 0, 0.55);
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: calc(var(--status-h) + 8px) auto 1fr auto;
    grid-template-areas: ". words" "media words" "media say" "acts acts";
    gap: 6px 14px;
    align-items: start;
  }
  .sheet.is-docked .card-title { top: calc(var(--status-h) - 8px); }
  /* The open door's card takes the table half; the room and its open doorway stay clear beside it. */
  .sheet.is-beside { inset: 0 var(--dock-right, 50%) 0 0; padding-top: calc(var(--status-h) + 6px); background: color-mix(in srgb, var(--ak-bg) 82%, transparent); }
  .sheet.is-beside .card { width: 100%; max-width: 560px; rotate: 0deg; }
  /* Its title runs across the top, so the doorway and the words share the height under it. */
  .sheet.is-beside .card.has-media { grid-template-areas: "title title" "media side"; grid-template-rows: auto auto; align-items: start; }
  .sheet.is-beside .card.has-media .card-title { align-self: start; }
  .sheet.is-beside .door-view { height: min(170px, calc(100dvh - var(--status-h) - 130px)); }
  .sheet.is-beside .card-text { font-size: 16px; line-height: 1.3; text-align: left; }
  .sheet.is-docked .card-media { grid-area: media; }
  .sheet.is-docked .card-side { display: contents; }
  .sheet.is-docked .card-words { grid-area: words; }
  .sheet.is-docked .card-say { grid-area: say; text-align: left; }
  .sheet.is-docked .card-actions { grid-area: acts; justify-content: flex-start; }
  .sheet.is-docked .lock { width: auto; min-width: 0; }
  .sheet.is-docked .lock-plate { max-width: 210px; justify-self: center; }
  .sheet.is-docked .keypad { grid-template-columns: repeat(5, 48px); gap: 4px; }
  .sheet.is-docked .clue-text { font-size: 15px; }
  .sheet.is-docked .clues-head { font-size: 14px; }
  .sheet.is-docked .clues-note { display: none; }
  .sheet.is-docked .card-say { align-self: end; }
  .sheet.is-docked .card-say.is-wrong { font-size: 15px; }
  body #activity-chrome-ending.site-shriversify .ac-card { padding: 16px 22px 8px 42px; }
  body #activity-chrome-ending.site-shriversify .ac-number { margin-bottom: 4px; }
  body #activity-chrome-ending.site-shriversify .ac-verdict { margin-bottom: 8px; padding-bottom: 8px; font-size: 22px; }
  body #activity-chrome-ending.site-shriversify .ac-lines { font-size: 15px; line-height: 1.3; }
  body #activity-chrome-ending.site-shriversify .ac-line { margin-bottom: 3px; }
  body #activity-chrome-ending.site-shriversify .ac-line:nth-child(2) { margin-top: 6px; padding-top: 5px; }
  body #activity-chrome-ending.site-shriversify .ac-actions { margin-top: 6px; }
  /* The ending card lies over the table half; the room and its open door stay clear on the right. */
  body #activity-chrome-ending.site-shriversify {
    --room-w: min(60vw, (100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 3 / 4);
    justify-content: center;
    padding-right: calc(var(--room-w) + 24px);
    background: linear-gradient(to right, rgba(0, 0, 0, 0.8) 0, rgba(0, 0, 0, 0.7) calc(100% - var(--room-w) - 40px), rgba(0, 0, 0, 0) calc(100% - var(--room-w) - 8px));
  }
  /* Sideways the doorway keeps its shape: as tall as the card allows, and as wide as that height wants. */
  .door-view { width: auto; height: min(210px, calc(100dvh - 120px)); }
  /* The narrow room keeps only the first move in its caption; the briefing and the letter carry the rest. */
  .teach-more { display: none; }
  .card { width: min(100%, 820px); padding: 12px 16px 10px; gap: 8px; }
  .card-title { font-size: 22px; padding-bottom: 4px; }
  .card-side { gap: 8px; }
  .clue-label { display: inline; margin-right: 6px; }
  .clue-label::after { content: ':'; }
  .clue-text { display: inline; }
  .card-say.is-wrong { padding: 6px 10px; font-size: 16px; line-height: 1.3; }
  .clue-box { padding: 6px 10px; }
  .clue-box-list { grid-template-columns: repeat(4, auto); justify-content: start; font-size: 18px; }
  /* Sideways the hint ladder lies flat: its three rungs side by side, so the whole ladder fits the height. */
  .hints { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
  .hints-head { text-align: left; }
  .card-how { display: none; }
  .clues-how { display: inline; }
  .card.has-media {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "media title" "media side";
    grid-template-rows: auto 1fr;
    column-gap: 18px;
    align-items: center;
  }
  .card.has-media .card-title { grid-area: title; align-self: end; }
  .card.has-media .card-media { grid-area: media; }
  .card.has-media .card-side { grid-area: side; align-self: start; }
  /* Sideways the lock and its numbers share the left of the card; the notes and buttons take the right. */
  .lock { width: min(400px, calc((100dvh - var(--status-h) - 156px) * 1.737)); min-width: 272px; }
  .plate-wrap { width: min(340px, calc((100dvh - var(--status-h) - 80px) * 1.368)); }
  .packets { width: min(340px, calc((100dvh - var(--status-h) - 80px) * 1.417)); }
  .crop-pot { height: min(180px, calc(100dvh - var(--status-h) - 60px)); }
}

/* A shorter upright phone gives the room the height: the ledger keeps its steps and lines, and the clue
   notes live on the lock, where they are used. */
@media (orientation: portrait) and (max-height: 780px) {
  .step-sub:not(.step-ledger) { display: none; }
  .sheet.is-docked .card { padding-top: 10px; gap: 4px; }
  /* No room for the tag: the lock says what it is, and the name stays for screen readers */
  .sheet.is-docked .card-title { clip-path: inset(50%); width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; white-space: nowrap; }
  .sheet.is-docked .card .lock { gap: 4px; }
  .sheet.is-docked .card .lock-plate { max-width: 200px; justify-self: center; }
  .sheet.is-docked .keypad { gap: 4px 8px; }
  .sheet.is-docked .clues-head .clues-note { display: none; }
  .sheet.is-docked .clue-text { font-size: 15px; }
  .sheet.is-docked .card-say.is-wrong { font-size: 15px; }
}

/* A tall, narrow phone keeps the table compact */
@media (orientation: portrait) and (max-height: 700px) {
  .step { font-size: 15px; }
  .step-sub { font-size: 14px; }
}

/* A shorter upright phone: the lock card tightens so its notes and its message both fit */
@media (orientation: portrait) and (max-height: 800px) {
  .card { padding: 16px 14px 8px; gap: 8px; }
  .card-title { font-size: 21px; padding-bottom: 4px; }
  .card-side { gap: 8px; }
  .lock { width: min(100%, 258px); }
  .clue-label { display: inline; margin-right: 6px; }
  .clue-label::after { content: ':'; }
  .clue-text { display: inline; }
  .card-say { font-size: 16px; }
  .card-say.is-wrong { padding: 6px 10px; }
  .card-how { display: none; }
  .clues-how { display: inline; }
  .card-actions { flex-wrap: nowrap; gap: 8px; }
  .act { padding: 0 12px; font-size: 17px; }
  .act-quiet { padding: 0 6px; font-size: 16px; }
  .clue-text { font-size: 16px; }
  .clues { padding: 6px 10px; gap: 4px; }
  .keypad { gap: 6px; }
  .card-say { line-height: 1.25; }
}

/* ---------- Motion: slow fades, a soft turn, nothing that bounces ---------- */

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .play.is-in { animation: fade-in 900ms ease-in-out both; }
  /* A close-up is readable from its first frame; it only settles in. */
  :root:not(.ac-still) .card { animation: card-in 320ms ease-out both; }
  :root:not(.ac-still) .teach-ring { animation: breathe 2400ms ease-in-out infinite; }
  :root:not(.ac-still) .item.is-waiting { animation: waiting 2400ms ease-in-out infinite; }
  :root:not(.ac-still) .room.is-holding .spot.is-target { animation: target-edge 2400ms ease-in-out infinite; }
  :root:not(.ac-still) .burn-wax { transition: height 1000ms linear; }
  :root:not(.ac-still) .candle { animation: candle 5200ms ease-in-out infinite alternate; }
  :root:not(.ac-still) .teach-caption,
  :root:not(.ac-still) .teach-arrow { animation: fade-in 900ms ease-in-out both; }
  :root:not(.ac-still) .dial-digit.is-turning { animation: turn-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both; }
  :root:not(.ac-still) .lock.is-wiggle .lock-plate { animation: wiggle 520ms ease-in-out both; }
  :root:not(.ac-still) .dial.is-right { animation: settle-glow 900ms ease-out both; animation-delay: calc(var(--i) * 200ms); }
  :root:not(.ac-still) .is-opening { animation: fade-in 1600ms ease-in-out both; }
  :root:not(.ac-still) .step-ledger.is-new { animation: fade-in 1600ms ease-in-out both; }
  :root:not(.ac-still) .item.is-new { animation: set-down 1200ms ease-out both; }
  :root:not(.ac-still) .peat.is-new { animation: heap 1800ms cubic-bezier(0.22, 1, 0.36, 1) both; }
  :root:not(.ac-still) .fog.is-new { animation: fade-in 2400ms ease-in-out both; }
  :root:not(.ac-still) .drawer-gap.is-new { animation: fade-in 1600ms ease-in-out both; }
  :root:not(.ac-still) .reason { animation: fade-in 700ms ease-in-out both; }
  :root:not(.ac-still) .room-art { transition: filter 1400ms ease-in-out; }
  :root:not(.ac-still) .room::after { transition: opacity 2400ms ease-in-out; }
  :root:not(.ac-still) .item { transition: translate 300ms ease-out, opacity 900ms ease-in-out, transform 900ms ease-in-out; }

  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes card-in { from { opacity: 0.85; } to { opacity: 1; } }
  @keyframes candle {
    0% { opacity: 0.5; scale: 0.92; }
    55% { opacity: 0.9; scale: 1.05; }
    100% { opacity: 0.68; scale: 1; }
  }
  @keyframes waiting { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ak-accent) 35%, transparent), 0 3px 6px rgba(0, 0, 0, 0.6); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--ak-accent) 15%, transparent), 0 3px 6px rgba(0, 0, 0, 0.6); } }
  @keyframes target-edge { 0%, 100% { border-color: var(--ak-accent); } 50% { border-color: color-mix(in srgb, var(--ak-accent) 35%, transparent); } }
  @keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
  /* The new number slides into the window; it is never faded, so it can be read at once. */
  @keyframes turn-in { from { transform: translateY(35%); } to { transform: none; } }
  @keyframes wiggle {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    45% { transform: translateX(5px); }
    70% { transform: translateX(-3px); }
    88% { transform: translateX(2px); }
  }
  @keyframes settle-glow {
    0% { box-shadow: inset 0 0 0 0 var(--ak-ink), 0 0 0 0 transparent; }
    50% { box-shadow: inset 0 0 0 2px var(--ak-ink), 0 0 16px 2px color-mix(in srgb, var(--ak-glow) 70%, transparent); }
    100% { box-shadow: inset 0 0 0 2px var(--ak-ink), 0 0 6px 0 color-mix(in srgb, var(--ak-glow) 40%, transparent); }
  }
  @keyframes set-down { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
  @keyframes heap { from { opacity: 0; transform: translateY(-40%) scale(0.7); } to { opacity: 1; transform: none; } }
}

/* The ending: the tray's objects swept to the table's edge */
.item.is-swept { opacity: 0; transform: translateX(160%) rotate(8deg); pointer-events: none; }
.item.is-swept:nth-child(2) { transition-delay: 160ms; }
.item.is-swept:nth-child(3) { transition-delay: 320ms; }

/* ---------- The opening: start.js's cold open, laid out here as the case file's letter ---------- */
/* start.js draws it; these rules only dress its scene in the frame: a foxed sheet pinned in the dark,
   the lines written on it, and the wax seal in plain view from the first moment. */

#activity-start#activity-start.site-shriversify.is-scene .ak-scene {
  position: relative;
  box-sizing: border-box;
  width: min(100%, 560px);
  min-height: 0;
  margin: max(2vh, 8px) auto 0;
  padding: 48px 32px 28px;
  gap: 20px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--paper);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  rotate: -0.8deg;
}
#activity-start#activity-start.site-shriversify.is-scene .ak-scene::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ak-accent);
  box-shadow: var(--pin);
  translate: -50% 0;
}
#activity-start#activity-start.site-shriversify.is-scene .ak-head {
  width: 100%;
  padding-bottom: 16px;
  border-bottom: 3px double var(--ak-outline);
}
#activity-start#activity-start.site-shriversify.is-scene .ak-logo { max-height: 120px; }
#activity-start#activity-start.site-shriversify.is-scene .ak-scene-lines { max-width: 40ch; gap: 12px; text-align: left; }
#activity-start#activity-start.site-shriversify.is-scene .ak-scene-line {
  font-family: var(--ak-font-body);
  font-size: 20px;
  font-style: italic;
  line-height: 1.4;
  text-shadow: none;
}
#activity-start#activity-start.site-shriversify.is-scene .ak-scene-line:first-child::first-letter {
  float: left;
  margin: 4px 1px 0 0;
  font-family: var(--ak-font-display);
  font-size: 46px;
  font-style: normal;
  line-height: 0.8;
}
#activity-start#activity-start.site-shriversify.is-scene .ak-scene-actions {
  width: 100%;
  padding-top: 16px;
  border-top: 1px dashed var(--ak-outline);
  gap: 8px;
}
/* The seal: wax pressed with a ring, the way a letter is closed */
#activity-start#activity-start.site-shriversify .ak-go {
  box-shadow:
    inset 0 0 0 6px var(--ak-btn-fill),
    inset 0 0 0 7px var(--ak-btn-active),
    0 6px 14px rgba(0, 0, 0, 0.6);
}
#activity-start#activity-start.site-shriversify.is-scene .ak-go { width: 112px; height: 112px; }
#activity-start#activity-start.site-shriversify.is-scene .ak-jump { margin: 0; font-size: 16px; }

/* Sideways the letter opens flat: the heading on the left, the lines and the seal on the right. */
@media (orientation: landscape) and (max-height: 600px) {
  #activity-start#activity-start.site-shriversify.is-scene .ak-scene {
    display: grid;
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
    grid-template-areas: "head lines" "head actions";
    align-items: center;
    width: min(100%, 780px);
    margin-top: 0;
    padding: 32px 24px 16px;
    gap: 8px 24px;
  }
  #activity-start#activity-start.site-shriversify.is-scene .ak-head { grid-area: head; padding: 0 20px 0 0; border-bottom: 0; border-right: 3px double var(--ak-outline); }
  #activity-start#activity-start.site-shriversify.is-scene .ak-scene-lines { grid-area: lines; gap: 6px; }
  #activity-start#activity-start.site-shriversify.is-scene .ak-scene-line { font-size: 18px; line-height: 1.3; }
  #activity-start#activity-start.site-shriversify.is-scene .ak-scene-actions { grid-area: actions; flex-direction: row-reverse; justify-content: center; gap: 24px; padding-top: 8px; }
  #activity-start#activity-start.site-shriversify.is-scene .ak-scene::before { left: 20%; }
  #activity-start#activity-start.site-shriversify.is-scene .ak-go { width: 88px; height: 88px; font-size: 13px; }
}

/* No tilted crawl and no wait: the letter fades up slowly and the seal is there with it. */
#activity-start#activity-start.site-shriversify .scene-crawl .ak-scene-lines,
#activity-start#activity-start.site-shriversify .scene-crawl .ak-scene-actions { animation: none; transform: none; opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  #activity-start#activity-start.site-shriversify.is-scene .ak-scene { animation: letter-in 1400ms ease-in-out both; }
  @keyframes letter-in { from { opacity: 0; } to { opacity: 1; } }
}

/* Shorter than a phone on its side: the lock's card scrolls rather than let its parts overlap. */
@media (orientation: landscape) and (max-height: 385px) {
  .sheet.is-docked .card { grid-template-rows: calc(var(--status-h) + 8px) auto auto auto; overflow-y: auto; }
}
