/* Mortimer's Empty Cage: a walnut table seen from straight above, lit by one candle.
   The brass cage is the board; the place cards lie across the top; the clues lie in a tray. */

*,
*::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, none), var(--ak-bg-art);
  background-size: cover, var(--ak-bg-size);
  background-position: center, center;
  background-repeat: no-repeat;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  -webkit-tap-highlight-color: transparent;
}

:root.ac-lights-up body {
  background-image: linear-gradient(rgba(13, 10, 11, 0.42), rgba(13, 10, 11, 0.42)), url("art/walnut-table.jpg");
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

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

[hidden] { display: none !important; }

/* ---------- The table ---------- */

.table {
  --edge: 8px;
  --gap: 6px;
  --pad-l: max(var(--edge), env(safe-area-inset-left));
  --pad-r: max(var(--edge), env(safe-area-inset-right));
  --pad-b: max(var(--edge), env(safe-area-inset-bottom));
  position: fixed;
  inset: 0;
  display: grid;
  gap: var(--gap);
  padding: calc(var(--ac-status-h, 76px) + 4px) var(--pad-r) var(--pad-b) var(--pad-l);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  /* Phone upright: the board above, the controls below. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas:
    "note"
    "suspects"
    "cage"
    "tray"
    "desk";
  max-width: 640px;
  margin: 0 auto;
}

.side,
.board-side { display: contents; }

.case-note { grid-area: note; }
.suspects { grid-area: suspects; }
.cage-room { grid-area: cage; }
.tray { grid-area: tray; }
.desk { grid-area: desk; }

/* ---------- The case note: logo, case title and the facts everyone agrees on ---------- */

.case-note {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.logo {
  flex: 0 0 auto;
  width: auto;
  height: 38px;
}

.case-words {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 8px 5px;
  background: var(--ak-surface);
  border-left: 2px solid var(--ak-outline);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.case-words { font-size: 12.5px; line-height: 1.2; }

.case-title {
  display: inline;
  margin: 0 4px 0 0;
  font-family: var(--ak-font-display);
  font-weight: var(--ak-title-weight);
  font-size: 1em;
  letter-spacing: 0.03em;
  color: var(--ak-accent);
}

.case-setup {
  display: inline;
  margin: 0;
  color: var(--ak-ink);
}

.case-goal {
  margin: 2px 0 0;
  color: var(--ak-ink-muted);
  font-style: italic;
}

/* ---------- Place cards across the top ---------- */

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

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  margin: 0;
  padding: 2px 0 0;
  border: 0;
  border-radius: 2px;
  background: none;
}

.card-art {
  display: block;
  height: var(--card-h, 64px);
  aspect-ratio: 74 / 112;
  background-image: url("art/suspect-cards.png");
  background-repeat: no-repeat;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.7));
}

.card-name {
  position: absolute;
  left: 50%;
  bottom: 0;
  translate: -50% 0;
  width: max-content;
  max-width: 100%;
  padding: 1px 4px 2px;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.05;
  text-align: center;
}

.card-back {
  position: absolute;
  inset: 2px 0 auto;
  height: var(--card-h, 64px);
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  background: var(--ak-surface);
  border: 1px solid var(--ak-outline);
  color: var(--ak-ink-muted);
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
}

.card-back b {
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: 12px;
  color: var(--ak-ink);
}

.card.is-cleared .card-back { display: flex; }
.card.is-cleared .card-name { color: var(--ak-ink-muted); }

.card.is-target .card-art { outline: 2px solid var(--ak-accent); outline-offset: 2px; }

.table.accusing .card:not(.is-cleared) .card-art {
  outline: 2px dashed var(--ak-accent);
  outline-offset: 3px;
}

/* ---------- The cage: the board ---------- */

.cage-room {
  container-type: size;
  min-height: 0;
  display: grid;
  place-items: center;
}

.cage {
  position: relative;
  width: min(100cqw, 100cqh * 363 / 384, 100dvw);
  aspect-ratio: 363 / 384;
  background: url("art/cage-board.png") center / 100% 100% no-repeat;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.75));
}

.door-glow {
  position: absolute;
  left: 50%;
  top: 94%;
  width: 34%;
  height: 16%;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(229, 166, 35, 0.62), rgba(229, 166, 35, 0) 70%);
  opacity: 0;
  pointer-events: none;
}

.table.solved .door-glow { opacity: 1; }

.slip {
  position: absolute;
  /* Sized to the whole table space around the cage, not the cage, so the slips can lie past its
     rim and keep a readable size on a phone. */
  width: min(47cqw, 220px);
  margin: 0;
  padding: 4px 7px 6px;
  border: 0;
  border-radius: 1px;
  background-color: var(--ak-choice-selected-bg);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(154, 142, 120, 0.2), transparent 30%),
    radial-gradient(circle at 88% 84%, rgba(154, 142, 120, 0.18), transparent 28%);
  color: var(--ak-choice-selected-ink);
  text-align: left;
  font-size: clamp(12.5px, 3.6cqw, 15px);
  line-height: 1.2;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.65);
  min-height: 48px;
}

.slip[data-slot="0"] { left: calc(50% - 50cqw + 2px); top: 31%; rotate: -1.2deg; }
.slip[data-slot="1"] { left: calc(50% - 50cqw + 2px); bottom: 2%; rotate: 1deg; }
.slip[data-slot="2"] { left: 50%; top: 1.5%; translate: -50% 0; rotate: 0.6deg; }
.slip[data-slot="3"] { right: calc(50% - 50cqw + 2px); bottom: 2%; rotate: -0.8deg; }
.slip[data-slot="4"] { right: calc(50% - 50cqw + 2px); top: 31%; rotate: 1.1deg; }

.slip-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 5px;
  margin-bottom: 1px;
}

.slip-name {
  font-family: var(--ak-font-display);
  font-size: 1.04em;
  letter-spacing: 0.02em;
}

.slip-role,
.slip-flag {
  font-style: italic;
  font-size: 0.86em;
}

.slip-flag { display: none; font-weight: 600; }
.slip.is-lie .slip-flag.lie,
.slip.is-cleared .slip-flag.clear { display: inline; }

.slip-says { display: block; font-style: italic; }

.slip-fact { display: none; font-size: 0.92em; line-height: 1.15; }
.slip { z-index: 1; }
/* A cleared slip lies under the others: the open statements are what the player still has to read. */
.slip.is-cleared { z-index: 0; }
.slip.is-cleared .slip-role { display: none; }
.slip.is-cleared .slip-says { display: none; }
.slip.is-cleared .slip-fact { display: block; }

.slip-seal {
  position: absolute;
  top: -9px;
  right: -7px;
  width: 26px;
  height: 22px;
  display: none;
  background: url("art/wax-pin.png") center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

.slip.is-lie .slip-seal { display: block; }
.slip.is-lie { box-shadow: 0 3px 8px rgba(0, 0, 0, 0.65), inset 0 0 0 2px var(--ak-accent-2); }
.slip.is-cleared {
  background-color: var(--ak-surface);
  background-image: none;
  color: var(--ak-ink);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.65), inset 0 0 0 1px var(--ak-outline);
}
.slip.is-target { outline: 2px solid var(--ak-accent); outline-offset: 2px; }
.table.accusing .slip:not(.is-cleared) { outline: 2px dashed var(--ak-accent); outline-offset: 2px; }

/* Pinned clues hang off the slip's lower edge, held by their wax, so they never cover its words. */
.slip-pins {
  position: absolute;
  left: 6px;
  bottom: -15px;
  z-index: 2;
  display: flex;
  gap: 3px;
}

.slip-pins:empty { display: none; }
.slip:has(.pin) { padding-bottom: 13px; }

.pin {
  position: relative;
  display: grid;
  place-items: center;
  width: 22px;
  height: 24px;
  padding-top: 3px;
  background: var(--ak-bg);
  border-radius: 1px;
}

.pin-art {
  display: block;
  height: 18px;
  max-width: 18px;
  background-image: url("art/clue-tokens.png");
  background-repeat: no-repeat;
}

.pin-wax {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 11px;
  height: 10px;
  translate: -50% 0;
  background: url("art/wax-pin.png") center / contain no-repeat;
}

.croak {
  position: absolute;
  padding: 1px 6px 2px;
  background: var(--ak-bg);
  color: var(--ak-ink-muted);
  font-style: italic;
  font-size: 12px;
  pointer-events: none;
  display: none;
}

.croak[data-corner] { display: block; }
.croak[data-corner="tl"] { left: 0; top: 0; }
.croak[data-corner="tr"] { right: 0; top: 0; }
.croak[data-corner="br"] { right: 0; bottom: 0; }
.croak[data-corner="bl"] { left: 0; bottom: 0; }

/* ---------- The clue tray ---------- */

.tray {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  background: var(--ak-bg);
  border: 1px solid var(--ak-outline);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.85), 0 6px 14px rgba(0, 0, 0, 0.55);
}

.clue {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-height: 48px;
  margin: 0;
  padding: 2px 5px 2px 3px;
  border: 1px solid transparent;
  border-radius: 1px;
  background: var(--ak-surface);
  text-align: left;
}

.clue-art-box {
  display: grid;
  place-items: center;
  width: 30px;
  height: 44px;
}

.clue-art {
  display: block;
  height: 44px;
  max-width: 30px;
  background-image: url("art/clue-tokens.png");
  background-repeat: no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.8));
}

.clue-words {
  min-width: 0;
  font-size: 12.5px;
  line-height: 1.14;
  color: var(--ak-ink-muted);
}

.clue-label {
  font-weight: 600;
  color: var(--ak-ink);
}

.clue-count {
  position: absolute;
  top: 2px;
  left: 2px;
  display: none;
  width: 12px;
  height: 11px;
  background: url("art/wax-pin.png") center / contain no-repeat;
}

.clue.is-pinned .clue-count { display: block; }

.clue[aria-pressed="true"] {
  border-color: var(--ak-accent);
  background: var(--ak-choice-bg);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.8);
  translate: 0 -2px;
}

/* The lens lies over the tray while a clue is in hand; the cards, statements and case note stay in view. */
.tray { position: relative; }

.lens {
  position: absolute;
  inset: 4px;
  z-index: 3;
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  padding: 14px 16px 10px;
  background-color: var(--ak-choice-selected-bg);
  background-image:
    radial-gradient(circle at 8% 14%, rgba(154, 142, 120, 0.26), transparent 26%),
    radial-gradient(circle at 92% 86%, rgba(154, 142, 120, 0.22), transparent 30%);
  color: var(--ak-choice-selected-ink);
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.8);
  rotate: -0.6deg;
}

.lens-art-box {
  display: grid;
  place-items: center;
  width: 64px;
  height: 96px;
  padding: 6px;
  background: var(--ak-bg);
}

.lens-art {
  display: block;
  height: 84px;
  max-width: 52px;
  background-image: url("art/clue-tokens.png");
  background-repeat: no-repeat;
}

.lens-words { min-width: 0; overflow-y: auto; max-height: 100%; }
.lens-label { margin: 0 0 4px; font-family: var(--ak-font-display); font-size: 20px; letter-spacing: 0.03em; }
.lens-text { margin: 0 0 8px; font-size: 18px; line-height: 1.3; font-style: italic; }
.lens-hint { margin: 0; font-size: 15px; line-height: 1.3; }

.lens-back {
  grid-column: 1 / -1;
  justify-self: end;
  min-height: 48px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid rgba(20, 15, 8, 0.45);
  background: none;
  color: var(--ak-choice-selected-ink);
  font-size: 17px;
  font-style: italic;
}

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .lens:not([hidden]) { animation: lens-lift 420ms ease-out both; }

  @keyframes lens-lift {
    from { opacity: 0; translate: 0 6px; }
    to { opacity: 1; translate: 0 0; }
  }
}

.goal-card {
  display: none;
  margin: 0;
  padding: 6px 8px;
  align-self: stretch;
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  font-style: italic;
  font-size: 12px;
  line-height: 1.2;
  rotate: -1deg;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6);
}

.clue.is-target { outline: 2px solid var(--ak-accent); outline-offset: 2px; }
.clue.is-proof { border-color: var(--ak-accent); }
.clue.is-proof .clue-label { color: var(--ak-accent); }

/* ---------- The desk: hint, goal, accuse ---------- */

.desk {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "hint kept accuse";
  align-items: center;
  gap: 8px;
}

.hint-btn { grid-area: hint; }
.accuse-btn { grid-area: accuse; }
.kept { grid-area: kept; }

.desk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0 12px;
  border: 1px solid var(--ak-outline);
  border-radius: 2px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 17px;
  letter-spacing: 0.05em;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
}

.desk-btn svg { width: 20px; height: 20px; color: var(--ak-accent); }

.accuse-btn { border-bottom: 2px solid var(--ak-accent); }

.accuse-btn .seal {
  width: 24px;
  height: 22px;
  background: url("art/wax-pin.png") center / contain no-repeat;
}

.accuse-btn[aria-pressed="true"] {
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
}

.kept {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 0;
  text-align: center;
  line-height: 1.2;
  color: var(--ak-ink-muted);
  font-size: 12px;
  font-style: italic;
}

#kept-line {
  padding: 0 4px;
  background: var(--ak-bg);
}

.kept.is-error #kept-line { color: var(--ak-ink); }

.clear-notes {
  min-height: 28px;
  margin: 0;
  padding: 0 4px;
  border: 0;
  border-bottom: 1px solid var(--ak-outline);
  background: var(--ak-bg);
  color: var(--ak-ink-muted);
  font-style: italic;
  font-size: 12px;
}

/* Keeps the small link a full tap target without growing the row. */
.clear-notes { position: relative; }
.clear-notes::after { content: ""; position: absolute; inset: -10px -6px; }

/* ---------- Teaching: a ring, an arrow and a caption that wait for the move ---------- */

.coach {
  position: fixed;
  inset: 0;
  z-index: 28;
  pointer-events: none;
}

.coach-ring {
  position: fixed;
  border: 3px solid var(--ak-accent);
  border-radius: 4px;
}

.coach-arrow {
  position: fixed;
  width: 26px;
  height: 26px;
  color: var(--ak-accent);
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.9));
}

.coach-words {
  position: fixed;
  margin: 0;
  width: min(340px, calc(100vw - 24px));
  padding: 10px 14px 11px;
  background: var(--ak-surface);
  border: 1px solid var(--ak-outline);
  border-top: 2px solid var(--ak-accent);
  color: var(--ak-ink);
  font-size: 18px;
  line-height: 1.3;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.7);
}

/* ---------- Sheets: hints and the clear-notes check ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.62);
}

.sheet-card {
  width: min(100%, 420px);
  max-height: 100%;
  overflow-y: auto;
  padding: 22px 24px 16px;
  background: var(--ak-surface);
  border: 1px solid var(--ak-outline);
  color: var(--ak-ink);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  rotate: 0.6deg;
}

.sheet-card h2 {
  margin: 0 0 10px;
  padding-bottom: 8px;
  border-bottom: 3px double var(--ak-outline);
  font-family: var(--ak-font-display);
  font-weight: 400;
  font-size: 24px;
  text-align: center;
}

.sheet-card p { font-size: 18px; line-height: 1.4; }

.ladder {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rung;
}

.ladder li {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  border-bottom: 1px dashed var(--ak-outline);
  font-size: 18px;
}

.ladder li::before {
  counter-increment: rung;
  content: counter(rung, lower-roman) ".";
  color: var(--ak-ink-muted);
  font-style: italic;
}

.ladder .rung-text { font-style: italic; line-height: 1.35; padding: 6px 0; }
.ladder .rung-name { display: block; color: var(--ak-ink-muted); font-size: 14px; font-style: normal; font-variant: small-caps; letter-spacing: 0.08em; }

.ladder button,
.sheet-go,
.sheet-close {
  min-height: 48px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--ak-outline);
  border-radius: 2px;
  background: none;
  color: var(--ak-ink);
  font-size: 18px;
  font-style: italic;
  text-align: left;
}

.ladder button:disabled { color: var(--ak-ink-muted); cursor: default; }

.sheet-close { display: block; margin: 12px auto 0; }

.sheet-row { display: flex; justify-content: center; gap: 20px; }
.sheet-row .sheet-close { margin: 0; }
.sheet-go { font-style: normal; font-variant: small-caps; letter-spacing: 0.08em; border-bottom-color: var(--ak-accent-2); }

/* Upright, the logo sits in the strip between the status label and the help button, so the case
   note has the full width for its words. */
@media (orientation: portrait) {
  .logo {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 20px);
    right: calc(env(safe-area-inset-right) + 74px);
    z-index: 29;
    height: 32px;
  }
}

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

@media (orientation: landscape) {
  .table {
    max-width: 1100px;
    padding-top: max(var(--edge), env(safe-area-inset-top));
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "side board";
    column-gap: 12px;
  }

  .side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    justify-content: safe center;
    gap: var(--gap);
    min-height: 0;
    padding-top: calc(var(--ac-status-h, 76px) - var(--edge) + 2px);
  }

  .board-side {
    grid-area: board;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    width: clamp(310px, 40vw, 560px);
  }

  .suspects { padding-right: 62px; }
  .card-art { height: var(--card-h-side, 58px); }
  .card-back { height: var(--card-h-side, 58px); }
  .cage-room { flex: 1 1 0; }
  .logo { height: 34px; }

  /* Sideways the goal is a note card lying in the tray beside the clues. */
  .tray { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .goal-card { display: block; }
  .case-goal { display: none; }
}

@media (orientation: landscape) and (max-height: 480px) {
  .clue { grid-template-columns: 28px minmax(0, 1fr); gap: 4px; padding: 2px 4px 2px 3px; }
  .clue-art-box { width: 28px; }
  .clue-art { max-width: 28px; }
  .clue-words { font-size: 11px; line-height: 1.14; }
  .clue-label { font-size: 11.5px; }
  .case-words { font-size: 12px; line-height: 1.16; }
  .goal-card { font-size: 11.5px; }
  .desk-btn { font-size: 16px; padding: 0 10px; }
}

@media (orientation: portrait) and (max-height: 760px) {
  .logo { height: 30px; }
  .table { --card-h: 50px; --gap: 4px; }
  .clue-words,
  .case-words { font-size: 12px; line-height: 1.13; }
}

@media (min-width: 900px) and (orientation: landscape) {
  .logo { height: 44px; }
  .clue-words { font-size: 13.5px; }
  .clue-label { font-size: 14px; }
  .case-setup { font-size: 14px; }
  .goal { font-size: 14px; }
  .card-art,
  .card-back { --card-h-side: 84px; }
}

/* ---------- Motion: slow, and only when wanted ---------- */

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .clue { transition: translate 260ms ease, box-shadow 260ms ease, border-color 260ms ease; }
  :root:not(.ac-still) .door-glow { transition: opacity 1400ms ease-in-out; }
  :root:not(.ac-still) .slip { transition: opacity 900ms ease-in-out, box-shadow 600ms ease; }
  :root:not(.ac-still) .coach-ring { animation: coach-pulse 2200ms ease-in-out infinite; }
  :root:not(.ac-still) .coach-words { animation: slow-in 700ms ease-out both; }
  :root:not(.ac-still) .card.turning,
  :root:not(.ac-still) .slip.turning { animation: card-turn 720ms ease-in-out both; }
  :root:not(.ac-still) .table .suspects,
  :root:not(.ac-still) .table .tray,
  :root:not(.ac-still) .table .case-note,
  :root:not(.ac-still) .table .desk {
    transition: transform 1600ms cubic-bezier(0.45, 0, 0.25, 1), opacity 1600ms ease-in-out;
  }
  :root:not(.ac-still) .table.solved .clue.is-proof { animation: proof-warm 1800ms ease-in-out both; }
  :root:not(.ac-still) .table.solved .slip.is-culprit { animation: proof-warm 1800ms ease-in-out both; }

  @keyframes coach-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 166, 35, 0.55); }
    50% { box-shadow: 0 0 0 8px rgba(229, 166, 35, 0); }
  }

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

  @keyframes card-turn {
    0% { transform: scaleX(1); }
    50% { transform: scaleX(0.04); }
    100% { transform: scaleX(1); }
  }

  @keyframes proof-warm {
    0% { box-shadow: 0 0 0 0 rgba(229, 166, 35, 0); }
    60% { box-shadow: 0 0 0 6px rgba(229, 166, 35, 0.35); }
    100% { box-shadow: 0 0 0 3px rgba(229, 166, 35, 0.3); }
  }
}

/* The ending: the cards and the tray are swept to the table's edge; the empty cage stays in the light. */
.table.swept .suspects { transform: translateY(-150%); opacity: 0; }
.table.swept .tray { transform: translateY(140%); opacity: 0; }
.table.swept .desk { transform: translateY(160%); opacity: 0; }
.table.swept .slip { opacity: 0; }

.table.solved .slip.is-culprit { box-shadow: 0 0 0 3px rgba(229, 166, 35, 0.45), 0 3px 8px rgba(0, 0, 0, 0.65); }

/* The toast closes on any tap anywhere; letting taps fall through means the buttons under it
   (it lies over the desk on a phone) still answer the first tap. */
#activity-chrome-toast { pointer-events: none; }

/* The ending page: the table is swept and dark behind it, and sideways the page runs wide and short
   so it fits the screen whole instead of sitting over a half-seen board. */
html #activity-chrome-ending.site-shriversify { background: rgba(0, 0, 0, 0.86); }

@media (orientation: landscape) and (max-height: 520px) {
  html #activity-chrome-ending.site-shriversify { padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); }
  html #activity-chrome-ending.site-shriversify .ac-card {
    width: min(100%, 700px);
    max-height: 100%;
    overflow-y: auto;
    padding: 14px 28px 8px;
  }
  html #activity-chrome-ending.site-shriversify .ac-number { margin-bottom: 2px; }
  html #activity-chrome-ending.site-shriversify .ac-verdict { margin-bottom: 6px; padding-bottom: 6px; font-size: 24px; }
  html #activity-chrome-ending.site-shriversify .ac-lines { font-size: 15px; line-height: 1.35; }
  html #activity-chrome-ending.site-shriversify .ac-line { margin-bottom: 4px; }
  html #activity-chrome-ending.site-shriversify .ac-actions { margin-top: 6px; }
}

/* ---------- The opening letter: start.js's scene, laid on a foxed sheet so it reads as a letter ---------- */

html #activity-start.site-shriversify .ak-scene { gap: var(--ak-space-5, 20px); }

html #activity-start.site-shriversify .ak-scene-lines {
  position: relative;
  width: min(100%, 470px);
  max-width: none;
  gap: 12px;
  padding: 26px 26px 40px;
  text-align: left;
  background-color: var(--ak-choice-selected-bg);
  background-image:
    radial-gradient(circle at 14% 12%, rgba(154, 142, 120, 0.28), transparent 26%),
    radial-gradient(circle at 86% 78%, rgba(154, 142, 120, 0.24), transparent 30%),
    radial-gradient(circle at 70% 18%, rgba(154, 142, 120, 0.14), transparent 18%),
    radial-gradient(ellipse at 50% 50%, transparent 60%, rgba(120, 92, 54, 0.32) 100%);
  color: var(--ak-choice-selected-ink);
  box-shadow: 0 26px 50px rgba(0, 0, 0, 0.75);
  rotate: -0.7deg;
}

html #activity-start.site-shriversify .ak-scene-lines::before {
  content: "To whoever takes the spiral stair next,";
  font-family: var(--ak-font-body);
  font-style: italic;
  font-size: 15px;
  color: var(--ak-choice-selected-ink);
}

/* The wax that sealed it, pressed at the foot of the page. */
html #activity-start.site-shriversify .ak-scene-lines::after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: -18px;
  width: 52px;
  height: 46px;
  background: url("art/wax-pin.png") center / contain no-repeat;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.6));
}

html #activity-start.site-shriversify .ak-scene-line {
  font-family: var(--ak-font-body);
  font-size: clamp(18px, 4.8vw, 22px);
  font-style: italic;
  font-variant: normal;
  line-height: 1.4;
  color: var(--ak-choice-selected-ink);
  text-shadow: none;
}

html #activity-start.site-shriversify .ak-scene-line:last-child { margin-top: 4px; padding-right: 64px; text-align: right; }

/* A phone on its side: a wider, shorter sheet so the letter and its seal fit the screen. */
@media (orientation: landscape) and (max-height: 520px) {
  html #activity-start.site-shriversify .ak-scene { gap: 10px; min-height: 0; }
  html #activity-start.site-shriversify .ak-scene .ak-logo { max-height: 56px; }
  html #activity-start.site-shriversify .ak-scene-lines { width: min(100%, 720px); gap: 4px; padding: 14px 24px 22px; }
  html #activity-start.site-shriversify .ak-scene-lines::before { font-size: 13px; }
  html #activity-start.site-shriversify .ak-scene-line { font-size: 16px; line-height: 1.35; }
  html #activity-start.site-shriversify .ak-scene-actions { flex-direction: row-reverse; align-items: center; gap: 28px; }
  html #activity-start.site-shriversify .ak-scene .ak-go { width: 88px; height: 88px; margin: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  /* The letter is laid down slowly, flat, instead of crawling up out of the dark. */
  html #activity-start.site-shriversify .scene-crawl .ak-scene-lines {
    transform: none;
    animation: mortimer-letter 1100ms ease-out both;
  }

  html #activity-start.site-shriversify .scene-crawl .ak-scene-actions { animation-delay: 900ms; }

  @keyframes mortimer-letter {
    from { opacity: 0; translate: 0 12px; }
    to { opacity: 1; translate: 0 0; }
  }
}

/* ---------- The ending: the next page of the case file, on the same foxed paper ---------- */

html #activity-chrome-ending.site-shriversify .ac-card {
  position: relative;
  border: 0;
  text-align: left;
  background-color: var(--ak-choice-selected-bg);
  background-image:
    radial-gradient(circle at 10% 8%, rgba(154, 142, 120, 0.3), transparent 24%),
    radial-gradient(circle at 92% 88%, rgba(154, 142, 120, 0.26), transparent 28%),
    radial-gradient(ellipse at 50% 50%, transparent 62%, rgba(120, 92, 54, 0.3) 100%);
  color: var(--ak-choice-selected-ink);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.75);
  rotate: -0.5deg;
}

html #activity-chrome-ending.site-shriversify .ac-card::after {
  content: "";
  position: absolute;
  top: -16px;
  right: 22px;
  width: 50px;
  height: 44px;
  background: url("art/wax-pin.png") center / contain no-repeat;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.55));
}

html #activity-chrome-ending.site-shriversify .ac-number,
html #activity-chrome-ending.site-shriversify .ac-verdict,
html #activity-chrome-ending.site-shriversify .ac-lines,
html #activity-chrome-ending.site-shriversify .ac-actions button { color: var(--ak-choice-selected-ink); }

html #activity-chrome-ending.site-shriversify .ac-verdict { border-bottom-color: rgba(20, 15, 8, 0.35); }

html #activity-chrome-ending.site-shriversify .ac-lines {
  font-family: var(--ak-font-body);
  font-size: 16px;
  font-variant: normal;
  line-height: 1.4;
}

/* The case's own dry conclusion closes the page. */
html #activity-chrome-ending.site-shriversify .ac-line:last-child {
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px dashed rgba(20, 15, 8, 0.4);
  font-size: 1.1em;
}

html #activity-chrome-ending.site-shriversify .ac-actions { justify-content: flex-start; }
html #activity-chrome-ending.site-shriversify .ac-actions button { border-bottom-color: rgba(20, 15, 8, 0.45); }

/* Sideways the page scrolls inside itself if it must, so its seal is pressed inside the edge. */
@media (orientation: landscape) and (max-height: 520px) {
  html #activity-chrome-ending.site-shriversify .ac-card::after { top: 8px; right: 12px; width: 40px; height: 36px; }
  html #activity-chrome-ending.site-shriversify .ac-number { padding-right: 48px; }
}
