/* The Governess's Diary: a dark schoolroom with one pool of lamplight on the page.
   Spotlight signature in the case-file frame: everything outside the pool sinks into fog,
   the page and the clue stay crisp, and light changes slowly. */

:root {
  --edge: 10px;
  --status: var(--ac-status-h, 68px);
  --ink-page: var(--ak-btn-ink);
  --ink-hand: color-mix(in srgb, var(--ak-btn-active) 38%, var(--ak-btn-ink));
  --pencil: color-mix(in srgb, var(--ak-outline) 80%, var(--ak-btn-fill));
  --pencil-dark: var(--ak-outline);
  --paper: var(--ak-btn-fill);
  --lamp: var(--ak-accent-2);
  --teal-breath: color-mix(in srgb, var(--ak-glow) 34%, transparent);
  --slow: 1200ms;
  --key-h: clamp(80px, 11dvh, 112px);
  /* The kit's slate and quiet ink, kept so Lights up can lighten them on the stage. */
  --gd-surface: var(--ak-surface);
  --gd-muted: var(--ak-ink-muted);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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 48%;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

/* ---------- the stage ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  grid-template-areas: "tabs" "clue" "desk";
  gap: 8px;
  padding:
    calc(var(--status) + 4px)
    max(var(--edge), env(safe-area-inset-right))
    max(var(--edge), env(safe-area-inset-bottom))
    max(var(--edge), env(safe-area-inset-left));
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  touch-action: manipulation;
}

.stage[hidden] { display: none; }

/* The dark around the lamp: a warm pool on the desk, fog-dark at the edges. */
.dark {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 62% 48% at 50% 64%, color-mix(in srgb, var(--lamp) 18%, transparent) 0%, transparent 70%),
    radial-gradient(ellipse 90% 75% at 50% 62%, transparent 30%, rgba(6, 8, 7, 0.62) 78%, rgba(4, 5, 5, 0.86) 100%);
}

.stage::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: color-mix(in srgb, var(--lamp) 16%, transparent);
  opacity: 0;
}

/* Lights up: the fog lifts off the room, the tabs and notes brighten. */
/* Lights up: the fog lifts off the whole room at once. The schoolroom shows round the page, the notes
   and tabs turn a lighter slate, and their quieter words brighten, so the change is plain at a glance. */
:root.gd-lights body {
  background-image:
    linear-gradient(color-mix(in srgb, var(--ak-bg) 10%, transparent), color-mix(in srgb, var(--ak-bg) 10%, transparent)),
    url("art/schoolroom-backdrop.jpg");
}
:root.gd-lights .dark { opacity: 0; }
:root.gd-lights .stage::after { opacity: 0.7; }
:root.gd-lights .stage {
  --ak-surface: color-mix(in srgb, var(--gd-surface) 78%, var(--ak-btn-fill));
  --ak-ink-muted: color-mix(in srgb, var(--gd-muted) 45%, var(--ak-ink));
}
:root.gd-lights .tab { color: var(--ak-ink); }
:root.gd-lights .page { filter: brightness(1.07); }

:root .tab-lights.is-on {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  border-color: var(--ak-btn-fill);
}
.stage.house-lights .dark { opacity: 0.12; }
.stage.house-lights::after { opacity: 1; }

/* ---------- tabs: paper labels pinned along the top ---------- */
.tabs {
  grid-area: tabs;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
}

.tabs-pages { display: flex; gap: 6px; }

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 48px;
  min-height: 48px;
  padding: 6px 9px 0;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink-muted);
  font-family: var(--ak-font-display);
  font-size: 17px;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  rotate: var(--tilt, -1deg);
}

.tab::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lamp);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  translate: -50% 0;
}

.tab:nth-child(2) { --tilt: 1.2deg; }
.tab:nth-child(3) { --tilt: -0.6deg; }
.tab-hint { --tilt: 1deg; }
.tab-lights { --tilt: -1.4deg; }

.tab[aria-selected="true"] {
  color: var(--ak-ink);
  box-shadow: inset 0 -3px 0 var(--lamp), 0 6px 14px rgba(0, 0, 0, 0.5);
}

.tab:disabled { opacity: 0.55; cursor: default; }
.tab:focus-visible, .key:focus-visible, .slip-next:focus-visible, .pick:focus-visible, .teach-go:focus-visible {
  outline: 3px solid var(--ak-focus);
  outline-offset: 2px;
}

.tab .tick {
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 22px;
  height: 8px;
  translate: -50% 0;
  color: var(--ak-ink);
}

.tab-hint { flex-direction: column; gap: 0; padding-top: 8px; }
.tab-lights { flex-direction: column; gap: 0; padding-top: 7px; line-height: 1.15; }
/* The lamp switch says where it stands: off or on. */
.tab-state {
  font-family: var(--ak-font-body);
  font-size: 11px;
  font-style: italic;
  line-height: 1;
  letter-spacing: 0.08em;
}
.pips { display: inline-flex; gap: 3px; height: 8px; }
.pips i {
  width: 6px;
  height: 6px;
  border: 1px solid var(--ak-ink-muted);
  border-radius: 50%;
}
.pips i.on { background: var(--ak-ink); border-color: var(--ak-ink); }

@media (max-width: 380px) {
  .tab { padding: 6px 7px 0; font-size: 16px; }
  .slip-text { font-size: 17px; }
  .slip .slip-how { font-size: 14px; }
}

/* ---------- the clue ---------- */
.clue {
  grid-area: clue;
  display: grid;
  grid-template-columns: minmax(96px, 30%) minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 0;
}

.key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: var(--key-h);
  width: calc(var(--key-h) * var(--key-shape, 0.8));
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.key { flex-direction: column; gap: 2px; padding-bottom: 0; }
.key-look {
  flex: none;
  padding: 1px 8px;
  border-bottom: 1px solid var(--ak-ink-muted);
  color: var(--ak-ink);
  font-size: 14px;
  font-style: italic;
  line-height: 1.3;
  white-space: nowrap;
}
.key > img, .key > svg, .key > .drawn-number, .key > .drawn-hymn { flex: 1 1 auto; min-height: 0; }
.key.painted-oval { --key-shape: 0.77; }
.key.key-keyword.framed { --key-shape: 1.3; }
.key.framed.wide { --key-shape: 1.06; }
.key.drawn.key-caesar { --key-shape: 0.8; }

.key img, .key svg { display: block; width: 100%; height: 100%; object-fit: contain; }

.key.painted-oval img { filter: drop-shadow(0 0 10px var(--teal-breath)); }

.key.framed {
  padding: calc(var(--key-h) * 0.12) calc(var(--key-h) * 0.16);
  border-radius: 50%;
  background: color-mix(in srgb, var(--ak-bg) 88%, black);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ak-glow) 45%, transparent), 0 0 18px var(--teal-breath);
}

.key.framed.wide { padding: calc(var(--key-h) * 0.1) calc(var(--key-h) * 0.16); }
.key.framed img { border-radius: 4px; }

.key.drawn { color: var(--ak-ink); }
.drawn-number {
  display: grid;
  place-items: center;
  width: 78%;
  height: 86%;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-page);
  font-family: var(--ak-font-body);
  font-style: italic;
  font-weight: 700;
  font-size: calc(var(--key-h) * 0.3);
  line-height: 1;
  text-decoration: underline double;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

.drawn-hymn {
  display: grid;
  place-items: center;
  gap: 2px;
  width: 100%;
  height: 80%;
  padding: 6px;
  background: var(--paper);
  color: var(--ink-page);
  border-radius: 2px;
}
.drawn-hymn-label { font-size: 13px; font-variant: small-caps; letter-spacing: 0.1em; }
.drawn-hymn-word {
  padding: 2px 8px;
  border: 1.5px solid var(--pencil-dark);
  border-radius: 50%;
  font-family: var(--ak-font-display);
  font-size: clamp(13px, calc(var(--key-h) * 0.15), 30px);
  letter-spacing: 0.08em;
}

.logo.logo-side { display: none; }

/* The sampler, stitched: dark wood frame, linen, thread letters. */
.sampler { width: 100%; height: 100%; }
.smp-frame { fill: color-mix(in srgb, var(--ak-bg) 70%, black); stroke: color-mix(in srgb, var(--ak-outline) 70%, black); stroke-width: 2; }
.smp-linen { fill: var(--paper); }
.smp-thread { stroke: var(--ink-page); stroke-width: 3; stroke-dasharray: 5 2; stroke-linecap: square; }
.smp-letter { fill: var(--ink-page); font-family: var(--ak-font-body); font-weight: 700; font-size: 17px; }
.smp-dot { fill: var(--ink-page); }
.smp-chair { stroke: var(--ink-page); stroke-width: 2; }
.smp-chair.pale { stroke: var(--pencil); }

.stage.finale-on .clue { display: none; }

.key-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.key-col .logo { align-self: center; height: clamp(28px, 4.4dvh, 40px); }

.slip-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.logo {
  display: block;
  align-self: flex-start;
  height: clamp(30px, 5.2dvh, 46px);
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.slip {
  position: relative;
  padding: 12px 14px 10px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5);
  rotate: 0.6deg;
}

.slip::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lamp);
  translate: -50% 0;
}

.slip-label {
  margin: 0 0 4px;
  color: var(--ak-ink-muted);
  font-size: 16px;
  line-height: 1.25;
}

.slip-text {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-style: italic;
}

.slip-label.is-do {
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--ak-outline);
  color: var(--ak-ink);
  font-size: 18px;
  font-variant: normal;
  font-weight: 700;
  letter-spacing: 0;
}

/* A hint is not the clue: a brass rule down its side and a brighter label. */
.slip.is-hint { border-left: 4px solid var(--lamp); }
.slip.is-hint .slip-label { color: var(--ak-ink); font-weight: 700; }

.slip-next {
  display: block;
  min-height: 48px;
  margin-top: 4px;
  padding: 0 4px;
  border: 0;
  border-bottom: 1px solid var(--ak-ink-muted);
  background: none;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 19px;
  cursor: pointer;
}


/* ---------- the desk and the page ---------- */
.desk {
  grid-area: desk;
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
}

/* The note carries the short how-to, hints and results; the long method is read on Look closer. */
.slip-text.is-method { display: none; }
.slip-how {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  font-style: italic;
}
/* A note for the player (a wrong page, the pencil line, the lamp): brass-ruled, until the next move. */
.slip-label.is-notice {
  padding-left: 8px;
  border-left: 4px solid var(--lamp);
  color: var(--ak-ink);
  font-size: 17px;
  font-weight: 700;
}
.record-next {
  display: block;
  color: var(--ak-ink-muted);
  font-size: 14px;
  font-style: italic;
  line-height: 1.25;
}
.record-line {
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 15px;
  rotate: 0.8deg;
}
.key-col .record { display: none; }

/* A letter a hint pencilled in: grey pencil, not her ink. */
.cell.given .plain { color: var(--pencil-dark); font-family: var(--ak-font-display); font-style: normal; font-weight: 400; }

.page {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background-image: url("art/diary-page.png");
  background-size: 126% 100%;
  background-position: 100% 0;
  background-repeat: no-repeat;
  box-shadow: inset 12px 0 16px -12px rgba(30, 22, 14, 0.55), 0 22px 44px rgba(0, 0, 0, 0.6);
}

.page[hidden] { display: none; }

/* Her numeral, written over the corner of the sheet. */
.numeral {
  position: absolute;
  top: 4.6%;
  right: 3.5%;
  z-index: 1;
  display: grid;
  place-items: center;
  width: max(14%, 44px);
  height: max(9.4%, 30px);
  background: color-mix(in srgb, var(--paper) 62%, var(--lamp));
  box-shadow: 0 0 6px 5px color-mix(in srgb, var(--paper) 62%, var(--lamp));
  color: var(--ink-page);
  font-family: var(--ak-font-display);
  font-size: 19px;
  text-align: center;
}

.lines {
  position: absolute;
  inset: 5.5% 2% 1.5% 2.5%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 0 2px;
}

/* A quiet wash, cut to the sheet's own torn shape, so the painted rules sit back behind her rows. */
.page::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--paper) 58%, transparent);
  -webkit-mask-image: url("art/diary-page.png");
  mask-image: url("art/diary-page.png");
  -webkit-mask-size: 126% 100%;
  mask-size: 126% 100%;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

.row {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: calc(var(--cw) * 0.34);
  height: var(--ch);
  border-bottom: 1px solid color-mix(in srgb, var(--ak-outline) 55%, transparent);
}

.row.new-line { margin-top: calc(var(--ch) * 0.22); }

.word { display: flex; position: relative; }

.cell {
  position: relative;
  display: grid;
  grid-template-rows: 46% 54%;
  width: var(--cw);
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-page);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

/* Each coded mark sits on its own faint slot, so it reads as something to tap. */
.cell::before {
  content: '';
  position: absolute;
  inset: 2px 1px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--ink-page) 7%, transparent);
  pointer-events: none;
}
.cell.filled::before { background: color-mix(in srgb, var(--ink-page) 3%, transparent); }

.plain {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 1px;
  color: var(--ink-hand);
  font-family: var(--ak-font-body);
  font-style: italic;
  font-weight: 700;
  font-size: min(calc(var(--cw) * 0.74), calc(var(--ch) * 0.46));
  line-height: 1;
}

.cell:not(.filled) .plain:empty::after {
  content: '';
  width: 46%;
  margin-bottom: 4px;
  border-bottom: 2px dotted color-mix(in srgb, var(--ak-outline) 75%, transparent);
}

.plain.ghost { color: color-mix(in srgb, var(--ink-hand) 42%, transparent); }

.mark {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-page);
  font-family: var(--ak-font-display);
  font-size: min(calc(var(--cw) * 0.78), calc(var(--ch) * 0.5));
  font-weight: 700;
  line-height: 1;
}

.mark .pen { width: 88%; height: 100%; }

/* A pigpen mark gets more of its cell than a letter does: the shape and its dot must read at a glance. */
.lines[data-kind="pigpen"] .cell { grid-template-rows: 38% 62%; }
/* Big, but never wall to wall: two marks side by side must not join into one shape. */
.lines[data-kind="pigpen"] .mark .pen { width: 80%; height: 100%; }
.lines[data-kind="pigpen"] .plain { font-size: min(calc(var(--cw) * 0.66), calc(var(--ch) * 0.38)); }

/* The lamp picks out the mark being worked on, everywhere it appears. */
.cell.lit {
  background: radial-gradient(ellipse at 50% 60%, color-mix(in srgb, var(--lamp) 85%, transparent) 0%, color-mix(in srgb, var(--lamp) 30%, transparent) 70%);
}
.cell.sel { box-shadow: inset 0 0 0 2px var(--ink-page); }

/* A wrong letter is ringed in pencil and struck through until it is changed. */
.cell.wrong .plain {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}
.cell.wrong::after {
  content: '';
  position: absolute;
  inset: 1px 3px 46% 3px;
  border: 2px dashed var(--ink-page);
  border-radius: 50%;
  pointer-events: none;
}

/* The first move, offered: a lit cell with a steady ring. */
.cell.invite {
  background: radial-gradient(ellipse at 50% 55%, color-mix(in srgb, var(--lamp) 90%, transparent) 0%, transparent 78%);
}
.cell.invite::before {
  content: '';
  position: absolute;
  inset: -4px;
  background: none;
  border: 3px solid var(--ink-page);
  border-radius: 50%;
  pointer-events: none;
}

/* A decoded run that spells a real word gets a faint pencil line. */
.word.real .plain { box-shadow: inset 0 -2px 0 var(--pencil); }

/* SHE, in a child's round hand. */
.word.child .plain {
  color: var(--pencil-dark);
  font-family: var(--ak-font-display);
  font-style: normal;
  font-weight: 400;
  font-size: min(calc(var(--cw) * 0.76), calc(var(--ch) * 0.5));
}
.word.child .cell:nth-child(1) .plain { rotate: -5deg; }
.word.child .cell:nth-child(2) .plain { rotate: 4deg; translate: 0 2px; }
.word.child .cell:nth-child(3) .plain { rotate: -2deg; }

.breath {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(100deg, transparent 25%, color-mix(in srgb, var(--ak-ink) 30%, transparent) 50%, transparent 75%);
}

/* ---------- the picker: docked in the layout, so the page is never covered ---------- */
.tray {
  grid-area: tray;
  min-height: 0;
  padding: 8px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.45);
  overflow-y: auto;
}

/* Upright: page above, picker below; the tabs and clue step aside while a letter is chosen. */
.stage.picking {
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "desk" "tray";
}
.stage.picking .tabs,
.stage.picking .clue { display: none; }

.tray-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
}

.tray-preview {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tray-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--paper);
  color: var(--ink-page);
  font-size: 28px;
  font-style: normal;
  box-shadow: inset 0 0 0 2px var(--ink-page);
}
.tray-mark .pen { width: 34px; height: 34px; }

.tray-arrow { font-family: var(--ak-font-display); font-size: 22px; color: var(--ak-ink-muted); }

.tray-reads {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 2px solid var(--ak-ink);
  font-family: var(--ak-font-body);
  font-size: 28px;
  font-style: italic;
  font-weight: 700;
}
.tray-reads.empty { border-style: dashed; color: var(--ak-ink-muted); }

.tray-words { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.tray-how { display: none; }
.tray-say { display: none; }
.tray-said { font-size: 16px; line-height: 1.25; font-style: italic; color: var(--ak-ink); }

.tray-say { margin: 0 0 4px; font-size: 16px; line-height: 1.25; font-style: italic; }
.tray-ruler { margin: 0 0 8px; }
.tray-short { display: block; font-size: 17px; line-height: 1.25; }
.tray-short.has-said { display: none; }
.ring {
  color: var(--ak-ink);
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--ak-ink);
  border-radius: 50%;
}

/* Her strip for a shift: the coded alphabet on top, the same alphabet slid back under it. The ringed
   column is lit top to bottom, so the real letter is read straight down from the coded one. */
.caesar-strip { border-top: 1px solid var(--ak-outline); border-bottom: 1px solid var(--ak-outline); padding: 2px 0; }
.kt-code-top { color: var(--ak-ink-muted); }
.kt-plain-low { color: var(--ak-ink); border-top: 1px solid var(--ak-outline); }
.caesar-strip .ring {
  box-shadow: none;
  border-radius: 0;
  background: color-mix(in srgb, var(--lamp) 34%, transparent);
  color: var(--ak-ink);
}
.caesar-strip .kt-plain-low.ring { font-size: 1.3em; font-weight: 700; }

/* Her key row written out under A to Z, in two halves. */
.key-table {
  display: grid;
  grid-template-columns: repeat(26, minmax(0, 1fr));
  margin-bottom: 4px;
  font-family: var(--ak-font-display);
  font-size: 16px;
  line-height: 1.25;
  text-align: center;
}
.kt-plain { color: var(--ak-ink); }
.kt-code { color: var(--ak-ink-muted); border-top: 1px solid var(--ak-outline); }
.kt-code.ring { color: var(--ak-ink); }

.helper-pigpen { display: flex; align-items: center; gap: 10px; }
.helper-pigpen .tray-say { margin: 0; flex: 1 1 auto; }
.sampler-grid { flex: none; width: 96px; height: 96px; }
/* In the picker the grid is the reference: its letters drawn bigger than on the wall. */
.sampler-grid .smp-letter { font-size: 21px; }
.sampler-grid .smp-dot { r: 3.4px; }

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

.pick {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  min-width: 0;
  min-height: 54px;
  height: 54px;
  padding: 0;
  border: 1px solid var(--ak-choice-border);
  border-radius: var(--ak-radius);
  background: var(--ak-choice-bg);
  color: var(--ak-choice-ink);
  font-family: var(--ak-font-body);
  cursor: pointer;
}
.pick b { font-size: 28px; line-height: 1; }
.pick small { font-size: 12px; line-height: 1; font-style: italic; }

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

.pick.used { border-style: dashed; color: var(--ak-ink-muted); }
.pick.used b { font-weight: 400; }

.pick-word { font-size: 15px; font-weight: 400; font-style: italic; letter-spacing: -0.04em; }
.pick:disabled { opacity: 0.45; cursor: default; }

/* The mark being edited is lit and ringed everywhere it appears on the page. */
.cell.lit::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--ink-page);
  border-radius: 4px;
  pointer-events: none;
}

.record {
  position: relative;
  display: grid;
  margin: 0;
  padding: 6px 10px 4px;
  border: 1px solid var(--ak-outline);
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
  rotate: -1.5deg;
}
.record::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lamp);
  translate: -50% 0;
}

/* The sampler's own lines round one pen, traced in the key's teal, and the pen lit inside. */
.smp-trace { stroke: var(--ak-btn-active); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.smp-lit { fill: color-mix(in srgb, var(--ak-glow) 22%, transparent); }

/* Worked pairs for the sampler: a mark, then the letter it reads. */
.pen-legend, .teach-pairs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}
.pl-item { display: inline-flex; align-items: center; gap: 6px; }
.pl-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  background: var(--paper);
  color: var(--ink-page);
}
.pl-mark .pen { width: 32px; height: 32px; }
.pl-eq { color: var(--ak-ink-muted); font-family: var(--ak-font-display); font-size: 20px; }
.pl-letter { font-family: var(--ak-font-body); font-size: 24px; font-style: italic; }
.inspect-legend { margin: 0 0 8px; }
.teach-pen { display: flex; align-items: center; gap: 14px; }
.teach-pen .sampler-grid { width: 92px; height: 92px; }
.teach-pairs { flex-direction: column; }

/* The sampler grid sits beside the mark being read, not on a row of its own. */
.tray[data-kind="pigpen"]:not([hidden]) {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 10px;
  align-items: start;
  align-content: start;
}
.tray[data-kind="pigpen"] .tray-ruler { grid-column: 1; grid-row: 1; margin: 0 0 6px; }
.tray[data-kind="pigpen"] .tray-head { grid-column: 2; grid-row: 1; flex-wrap: wrap; align-content: flex-start; row-gap: 4px; }
.tray[data-kind="pigpen"] .tray-words { order: 3; flex-basis: 100%; }
.tray[data-kind="pigpen"] .tray-close { margin-left: auto; }
.tray[data-kind="pigpen"] .tray-grid { grid-column: 1 / -1; grid-row: 2; }

/* ---------- upright: the page takes the height ---------- */
@media (orientation: portrait) {
  /* The clue: key and logo on the left, the note beside it, the record in one strip underneath. */
  :root { --key-h: clamp(72px, 10dvh, 100px); }
  .clue { grid-template-columns: max-content minmax(0, 1fr); row-gap: 6px; column-gap: 10px; align-items: start; }
  .key-col { min-width: 100px; }
  .key-col .logo { height: clamp(24px, 3.6dvh, 32px); }
  .slip-wrap { display: contents; }
  .slip { grid-column: 2; grid-row: 1; align-self: stretch; padding: 9px 11px 7px; }
  .slip-label, .slip-label.is-do { font-size: 16px; line-height: 1.28; }
  .slip-label.is-do { margin-bottom: 4px; padding-bottom: 4px; }
  .slip-label.is-notice { font-size: 16px; }
  .slip-how { font-size: 15px; }
  .slip-text { font-size: 16px; }
  .slip-next { min-height: 44px; font-size: 17px; }
  .record-line {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 10px;
    margin: 0;
    padding: 3px 10px;
    rotate: 0.4deg;
  }
  .record-line .record-next { display: inline; font-size: 14px; }

  /* A compact picker, so the page above it keeps letters big enough to read and tap. */
  .tray { padding: 6px; }
  .tray-head { margin-bottom: 4px; flex-wrap: wrap; row-gap: 2px; }
  /* The how-to line runs the full width under the mark, not squeezed beside it. */
  .tray-words { order: 3; flex-basis: 100%; }
  .tray-close { margin-left: auto; }
  .tray-short { font-size: 16px; }
  .tray-ruler { margin-bottom: 6px; }
  .tray-grid { gap: 4px; }
  .pick { min-height: 48px; height: 48px; }
  .pick b { font-size: 26px; }
  /* The grid is as big as the height allows; the mark beside it is drawn big too, for a straight compare. */
  .tray[data-kind="pigpen"] .sampler-grid { width: clamp(104px, 15dvh, 132px); height: clamp(104px, 15dvh, 132px); }
  .tray[data-kind="pigpen"] .tray-mark { width: 48px; height: 48px; }
  .tray[data-kind="pigpen"] .tray-mark .pen { width: 40px; height: 40px; }
  .tray[data-kind="pigpen"] .tray-reads { width: 48px; height: 48px; }
  .tray[data-kind="pigpen"] .tray-short { font-size: 15px; }
  .tray[data-kind="pigpen"] .tray-close { min-width: 52px; min-height: 48px; padding: 0 6px; }
}

/* ---------- the worked step ---------- */
.teach {
  position: fixed;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 560px);
  margin: 0 auto;
  padding: 12px 14px 14px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.7);
}

.teach[hidden] { display: none; }

.teach-label {
  margin: 0 0 6px;
  color: var(--ak-ink-muted);
  font-size: 18px;
  font-variant: small-caps;
  letter-spacing: 0.12em;
}

.teach-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
}

.strip-cell {
  display: grid;
  justify-items: center;
  width: 25px;
}

.strip-cell b {
  display: grid;
  place-items: center;
  width: 25px;
  height: 30px;
  font-family: var(--ak-font-display);
  font-size: 20px;
  font-weight: 400;
}

.strip-cell i { font-size: 18px; font-style: normal; letter-spacing: -1px; color: var(--ak-ink-muted); min-height: 20px; line-height: 1.1; }
.strip-cell.from b, .strip-cell.to b { background: var(--ak-btn-fill); color: var(--ak-btn-ink); }

.strip-note { display: none; }

.teach-text { margin: 8px 0 10px; font-size: 18px; line-height: 1.36; }

.teach-go {
  display: block;
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--ak-outline);
  border-radius: var(--ak-radius);
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font-family: var(--ak-font-display);
  font-size: 22px;
  cursor: pointer;
}

/* ---------- the finale: the house lights come up ---------- */
.finale {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px;
  overflow: hidden;
}

.finale[hidden] { display: none; }

.finale-label {
  margin: 0;
  padding: 6px 16px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 22px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
}

.finale-pages {
  display: grid;
  gap: 8px;
  width: 100%;
}

.finale-page {
  position: relative;
  padding: 12px 40px 10px 14px;
  background-image: url("art/diary-page.png");
  background-size: 126% 100%;
  background-position: 100% 0;
  color: var(--ink-page);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
}

.finale-page:nth-child(2) { rotate: 0.6deg; }
.finale-page:nth-child(3) { rotate: -0.5deg; }

.finale-numeral {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 0 6px;
  background: var(--paper);
  font-family: var(--ak-font-display);
  font-size: 16px;
}

.finale-line {
  margin: 0;
  padding: 1px 6px;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
  color: var(--ink-hand);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(14px, 2.1dvh, 18px);
  line-height: 1.4;
}

.child-hand {
  color: var(--pencil-dark);
  font-family: var(--ak-font-display);
  font-style: normal;
  font-weight: 400;
}

.finale-child .finale-line { color: var(--pencil-dark); font-size: clamp(16px, 2.4dvh, 20px); }
.finale-child .is-new { color: var(--ink-page); }

.tea { width: min(64%, 240px); height: auto; flex: none; }
.tea-top { fill: color-mix(in srgb, var(--ak-bg) 55%, var(--lamp)); }
.tea-cloth { fill: var(--paper); opacity: 0.85; }
.saucer { fill: var(--paper); stroke: var(--ak-outline); stroke-width: 1.5; }
.cup-rim { fill: color-mix(in srgb, var(--lamp) 70%, var(--ak-btn-ink)); stroke: var(--ink-page); stroke-width: 1.5; }
.cup-handle { stroke: var(--ink-page); stroke-width: 2; }
.teapot { fill: var(--ak-surface); stroke: var(--ink-page); stroke-width: 1.5; }

/* ---------- sideways: the page on one side, the clue and controls on the other ---------- */
@media (orientation: landscape) {
  :root {
    --key-h: clamp(64px, 20dvh, 150px);
    --col: clamp(240px, 34vw, 320px);
  }

  /* Sideways: the clue and its note down the left, under the lamp's label; the tabs pinned along
     the top of the page, where they step round the help button; the page takes the rest. */
  .stage {
    max-width: 1100px;
    grid-template-columns: var(--col) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "clue tabs" "clue desk";
    column-gap: 16px;
    row-gap: 6px;
    padding-top: max(var(--edge), env(safe-area-inset-top));
    padding-right: max(var(--edge), env(safe-area-inset-right));
  }

  .tabs { flex-wrap: nowrap; gap: 3px; padding-top: 2px; margin-right: 66px; }
  .tabs-pages { gap: 3px; }
  .tab { padding: 6px 6px 0; font-size: 15px; }
  .key-col { flex-direction: row; justify-content: center; gap: 12px; }
  .key-col .logo { height: clamp(28px, 9dvh, 44px); }

  .clue {
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    align-items: start;
    padding-top: calc(var(--status) - 6px);
    min-height: 0;
    overflow: hidden;
  }

  .slip { padding: 10px 12px 8px; }

  /* The record runs in one strip under the note, with what waits after this round. */
  .record-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0 8px;
    margin-top: 0;
    padding: 3px 10px;
    font-size: 14px;
    rotate: 0.4deg;
  }
  .record-line .record-next { display: inline; font-size: 13px; }
  .slip-wrap { gap: 6px; }

  /* Sideways: the picker takes the controls column; the page and its tabs stay whole on their side. */
  .stage.picking {
    grid-template-columns: max(var(--col), 290px) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "tray tabs" "tray desk";
  }
  .stage.picking .tabs { display: flex; }
  .tray { grid-row: 1 / -1; }
  .tray {
    align-self: start;
    margin-top: calc(var(--status) - 10px);
    max-height: calc(100dvh - var(--status) + 10px - max(var(--edge), env(safe-area-inset-bottom)));
    padding: 4px 5px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
  .tray-head { margin-bottom: 4px; gap: 6px; flex-wrap: wrap; row-gap: 2px; }
  .tray-words { order: 3; flex-basis: 100%; }
  .tray-close { margin-left: auto; }
  .tray-mark, .tray-reads { width: 36px; height: 36px; font-size: 22px; }
  .tray-mark .pen { width: 28px; height: 28px; }
  /* Sideways the head carries the short how-to, then the last pick's news; the long line steps aside. */
  .tray-how, .tray-say { display: none; }
  .tray-short { display: block; }
  .tray-short.has-said { display: none; }
  .tray-said { font-size: 14px; }
  .tray-short { font-size: 14px; }
  .tray-close { min-width: 56px; min-height: 44px; font-size: 16px; }
  .tray-ruler { margin-bottom: 4px; }
  .key-table { font-size: 14px; line-height: 1.15; margin-bottom: 2px; }
  .tray[data-kind="pigpen"] .sampler-grid { width: 92px; height: 92px; }
  .tray[data-kind="pigpen"] .tray-close { padding: 0 6px; min-width: 52px; }
  .tray[data-kind="pigpen"] .tray-mark { width: 44px; height: 44px; }
  .tray[data-kind="pigpen"] .tray-mark .pen { width: 38px; height: 38px; }
  .tray[data-kind="pigpen"] .tray-ruler { margin-bottom: 4px; }
  .helper-pigpen { justify-content: center; }
  .tray-grid { gap: 2px; }
  .pick { min-height: 44px; height: 44px; }
  .pick b { font-size: 19px; }
  .pick-word { font-size: 13px; }

  .teach {
    left: auto;
    right: max(12px, env(safe-area-inset-right));
    width: min(calc(100vw - var(--col) - 50px), 620px);
    padding: 10px 14px 12px;
  }
  .teach-label, .strip-note { display: none; }
  .teach-text { margin: 8px 0 10px; }
  .teach-go { min-height: 48px; }

  .page { width: min(100%, 760px); justify-self: center; }

  .finale {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-content: center;
    align-items: center;
    column-gap: 16px;
  }
  .finale-label { grid-column: 1 / -1; justify-self: center; }
  .finale-pages { width: 100%; }
  .tea { width: min(30vw, 200px); }
}

/* A low landscape phone: tighter rows above the clue. */
@media (orientation: landscape) and (max-height: 420px) {
  .slip { padding: 8px 12px 6px; }
  .slip-text { font-size: 17px; line-height: 1.28; }
  /* Low phones: the note and record in smaller type, so the column holds them whole. */
  .slip-label, .slip-label.is-do, .slip-label.is-notice { font-size: 15px; line-height: 1.28; }
  .slip .slip-how { font-size: 14px; }
  .record-line { font-size: 13px; }
  .record-line .record-next { font-size: 12px; }
  .slip-next { min-height: 44px; font-size: 17px; }
  .finale-label { font-size: 18px; padding: 4px 12px; }
  .finale-line { font-size: 13px; line-height: 1.3; }
}

@media (orientation: landscape) and (max-height: 380px) {
  /* The lowest phones: on a strip or key-row page the ring already shows the coded letter, so the
     picker drops its own copy and keeps every row of letters in view. */
  .tray:not([data-kind="pigpen"]) .tray-preview { display: none; }
  .tray:not([data-kind="pigpen"]) .tray-words { order: 0; flex: 1 1 0; min-width: 0; }
  .tray[data-kind="pigpen"] .sampler-grid { width: 84px; height: 84px; }
  .key-table { line-height: 1.02; }
  .caesar-strip { padding: 0; }
}

@media (orientation: landscape) and (max-height: 370px) {
  :root { --key-h: 64px; }

  /* Too short to sit under the first row: the worked step covers the controls column instead. */
  .teach {
    left: max(var(--edge), env(safe-area-inset-left));
    right: auto;
    width: 310px;
    bottom: max(var(--edge), env(safe-area-inset-bottom));
    max-height: calc(100dvh - 2 * var(--edge));
    overflow-y: auto;
  }
  .strip-cell i { display: none; }
  .slip { padding: 6px 10px 4px; }
}

/* ---------- motion: slow light, never a bounce ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* Light changes slowly, but a tap on Lights up answers within a breath, so it is seen to work. */
  :root:not(.ac-still) .dark { transition: opacity 700ms ease; }
  :root:not(.ac-still) .stage::after { transition: opacity 900ms ease; }
  :root:not(.ac-still) .tab { transition: color var(--slow) ease, box-shadow var(--slow) ease; }
  :root:not(.ac-still) .key { transition: height var(--slow) ease, width var(--slow) ease; }
  :root:not(.ac-still) .cell { transition: background-color 700ms ease, box-shadow 700ms ease; }
  :root:not(.ac-still) .tray:not([hidden]) { animation: gd-rise 420ms ease-out both; }
  :root:not(.ac-still) .cell.write .plain { animation: gd-pen 620ms cubic-bezier(0.3, 0.6, 0.3, 1) both; }
  :root:not(.ac-still) .cell.invite::before { animation: gd-breathe 3200ms ease-in-out infinite; }
  :root:not(.ac-still) .page.settling { animation: gd-settle 1800ms ease-out both; }
  :root:not(.ac-still) .page.settling .plain { animation: gd-glow 1600ms ease-out both; animation-delay: var(--glow-delay, 0ms); }
  :root:not(.ac-still) .page.settling .breath { animation: gd-breath 2600ms ease-in-out both; }
  :root:not(.ac-still) .stage.lamp-swell .dark { animation: gd-swell 3600ms ease-in-out both; }
  :root:not(.ac-still) .stage.key-lit .key { animation: gd-key 2600ms ease-in-out 2; }
  /* Words never fade in: a changed note shows at once, and only its edge takes the lamp's light. */
  :root:not(.ac-still) .slip.fresh { animation: gd-note 1600ms ease-out both; }
  :root:not(.ac-still) .finale-page { animation: gd-lay 1400ms ease-out both; }
  :root:not(.ac-still) .finale-page:nth-child(2) { animation-delay: 300ms; }
  :root:not(.ac-still) .finale-page:nth-child(3) { animation-delay: 600ms; }
  :root:not(.ac-still) .cup-fourth { animation: gd-warm 4200ms ease-in-out infinite; }
}

@keyframes gd-rise { from { translate: 0 8px; } to { translate: 0 0; } }
@keyframes gd-note {
  from { box-shadow: 0 0 0 3px var(--lamp), 0 10px 22px rgba(0, 0, 0, 0.5); }
  to { box-shadow: 0 0 0 0 transparent, 0 10px 22px rgba(0, 0, 0, 0.5); }
}
@keyframes gd-lay { from { translate: 0 -6px; } to { translate: 0 0; } }
@keyframes gd-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes gd-pen {
  from { clip-path: inset(0 60% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes gd-breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes gd-settle {
  from { scale: 1.014; translate: 0 -4px; }
  to { scale: 1; translate: 0 0; }
}
@keyframes gd-glow {
  0% { text-shadow: none; }
  35% { text-shadow: 0 0 10px var(--lamp), 0 0 2px var(--lamp); }
  100% { text-shadow: none; }
}
@keyframes gd-breath {
  0% { opacity: 0; translate: -70% 0; }
  45% { opacity: 0.7; }
  100% { opacity: 0; translate: 70% 0; }
}
@keyframes gd-swell { 0% { opacity: 1; } 40% { opacity: 0.55; } 100% { opacity: 1; } }
@keyframes gd-key {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 16px var(--ak-glow)); }
}
@keyframes gd-warm { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

.tray-close {
  flex: none;
  min-width: 64px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid var(--ak-ink-muted);
  background: none;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 17px;
  font-style: normal;
  cursor: pointer;
}
.tray-close:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: 2px; }

/* The chrome's note clears on any tap; letting the tap through means a cell under it is never lost. */
#activity-chrome-toast { pointer-events: none; }


/* ---------- looking closer: the clue as an object in the lamp's pool ---------- */
.inspect {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 14px;
  padding:
    calc(var(--status) + 8px)
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background:
    radial-gradient(ellipse 60% 45% at 50% 38%, color-mix(in srgb, var(--lamp) 26%, transparent) 0%, transparent 72%),
    rgba(6, 8, 7, 0.9);
}
.inspect-pool { display: grid; place-items: center; width: 100%; min-height: 0; }
.inspect-object { display: grid; place-items: center; width: min(100%, 520px); height: 100%; min-height: 0; }
.inspect-object img,
.inspect-object svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 18px var(--teal-breath));
}
.inspect-object svg { width: min(100%, 60dvh); height: auto; }
.big-number {
  display: grid;
  place-items: center;
  width: min(60vw, 40dvh);
  aspect-ratio: 0.78;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink-page);
  font-family: var(--ak-font-body);
  font-size: min(22vw, 15dvh);
  font-style: italic;
  font-weight: 700;
  text-decoration: underline double;
  text-decoration-thickness: 4px;
  text-underline-offset: 12px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ak-glow) 50%, transparent), 0 0 26px var(--teal-breath);
}
.big-hymn {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 28px 36px;
  background: var(--paper);
  color: var(--ink-page);
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.7), 0 0 18px var(--teal-breath);
}
.big-hymn span { font-variant: small-caps; letter-spacing: 0.12em; font-size: 18px; }
.big-hymn b { padding: 4px 18px; border: 2px solid var(--pencil-dark); border-radius: 50%; font-family: var(--ak-font-display); font-size: 34px; font-weight: 400; letter-spacing: 0.1em; }
.inspect-note {
  position: relative;
  width: min(100%, 520px);
  padding: 14px 18px 12px;
  border: 1px solid var(--ak-outline);
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.55);
  rotate: -0.5deg;
}
.inspect-note::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lamp);
  translate: -50% 0;
}
.inspect-title { margin: 0 0 4px; font-family: var(--ak-font-display); font-size: 22px; }
.inspect-text, .inspect-how { margin: 0 0 8px; font-size: 18px; line-height: 1.35; }
.inspect-how { font-style: italic; }
.inspect-back {
  display: block;
  min-height: 48px;
  margin: 4px 0 0 auto;
  padding: 0 6px;
  border: 0;
  border-bottom: 1px solid var(--ak-ink-muted);
  background: none;
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 19px;
  cursor: pointer;
}
.inspect-back:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: 2px; }

@media (orientation: landscape) {
  .inspect {
    grid-template-rows: minmax(0, 1fr);
    grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
    align-items: center;
    padding-top: calc(var(--status) + 4px);
    padding-right: calc(72px + env(safe-area-inset-right));
  }
  .inspect-object { height: calc(100dvh - var(--status) - 24px); }
  .inspect-object img { max-height: calc(100dvh - var(--status) - 24px); width: auto; }
  .inspect-object svg { width: min(100%, calc(100dvh - var(--status) - 24px)); }
  .big-number { width: auto; height: calc(100dvh - var(--status) - 40px); font-size: 24dvh; }
  .inspect-text, .inspect-how { font-size: 17px; }
}

@media (orientation: landscape) and (max-height: 420px) {
  .inspect-note { padding: 10px 14px 8px; }
  .inspect-title { font-size: 19px; }
  .inspect-text, .inspect-how { font-size: 16px; line-height: 1.3; margin-bottom: 6px; }
}

/* ---------- the opening letter, on foxed paper with a wax seal ---------- */
#activity-start#activity-start.site-shriversify { overflow-x: hidden; }
html #activity-start#activity-start.site-shriversify .ak-sheet {
  --paper-ink: var(--ak-btn-ink);
  --paper-faint: color-mix(in srgb, var(--ak-btn-ink) 72%, var(--ak-btn-fill));
  background-color: var(--ak-btn-fill);
  background-image:
    radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--ak-accent-2) 55%, transparent) 0 14px, transparent 26px),
    radial-gradient(circle at 86% 9%, color-mix(in srgb, var(--ak-accent-2) 45%, transparent) 0 9px, transparent 20px),
    radial-gradient(circle at 78% 62%, color-mix(in srgb, var(--ak-accent-2) 40%, transparent) 0 18px, transparent 34px),
    radial-gradient(circle at 20% 84%, color-mix(in srgb, var(--ak-accent-2) 50%, transparent) 0 11px, transparent 24px),
    radial-gradient(ellipse at 50% 50%, transparent 60%, color-mix(in srgb, var(--ak-accent-2) 55%, transparent) 100%);
  color: var(--paper-ink);
  border-color: color-mix(in srgb, var(--ak-accent-2) 70%, var(--ak-btn-ink));
}
html #activity-start#activity-start.site-shriversify .ak-sheet :is(.ak-tagline, .ak-badge, .ak-label, .ak-first-label, .ak-legend) { color: var(--paper-faint); }
html #activity-start#activity-start.site-shriversify .ak-sheet :is(.ak-body, .ak-controls, .ak-first, li, p) { color: var(--paper-ink); }
html #activity-start#activity-start.site-shriversify .ak-head,
html #activity-start#activity-start.site-shriversify .ak-first { border-color: color-mix(in srgb, var(--ak-btn-ink) 35%, transparent); }
html #activity-start#activity-start.site-shriversify .ak-sheet .ak-jump,
html #activity-start#activity-start.site-shriversify .ak-sheet .ak-how {
  color: color-mix(in srgb, var(--ak-btn-active) 45%, var(--ak-btn-ink));
  position: relative;
  z-index: 3;
}
/* The seal is pressed under the title, in view on arrival, and never over the letter's words. */
html #activity-start#activity-start.site-shriversify .ak-sheet { display: flex; flex-direction: column; }
html #activity-start#activity-start.site-shriversify .ak-head { order: 0; }
html #activity-start#activity-start.site-shriversify .ak-go { order: 1; }
html #activity-start#activity-start.site-shriversify .ak-jump { order: 2; align-self: center; }
html #activity-start#activity-start.site-shriversify .ak-first { order: 3; }
html #activity-start#activity-start.site-shriversify .ak-howto { order: 4; }
html #activity-start#activity-start.site-shriversify .ak-groups,
html #activity-start#activity-start.site-shriversify .ak-how { order: 5; }
html #activity-start#activity-start.site-shriversify .ak-go {
  position: relative;
  bottom: auto;
  z-index: 2;
  flex: none;
  width: 112px;
  height: 112px;
  margin: 20px auto 6px;
  border: 0;
  background: none;
  color: var(--ak-btn-ink);
  box-shadow: none;
  font-weight: 700;
}
/* The wax: a teal disc with a pressed rim, under the words. */
html #activity-start#activity-start.site-shriversify .ak-go::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  background:
    radial-gradient(circle at 36% 30%, color-mix(in srgb, var(--ak-accent) 70%, var(--ak-btn-fill)) 0 10%, transparent 34%),
    radial-gradient(circle at 50% 50%, var(--ak-btn-active) 0 58%, color-mix(in srgb, var(--ak-btn-active) 62%, black) 70%, var(--ak-btn-active) 76%, color-mix(in srgb, var(--ak-btn-active) 55%, black) 100%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), inset 0 0 0 7px color-mix(in srgb, var(--ak-btn-active) 70%, black), inset 0 0 0 9px color-mix(in srgb, var(--ak-accent) 55%, transparent);
}
html #activity-start#activity-start.site-shriversify .ak-go:focus-visible { outline: 3px solid var(--ak-btn-ink); outline-offset: 4px; }
@media (orientation: landscape) and (max-height: 500px) {
  html #activity-start#activity-start.site-shriversify .ak-go { width: 92px; height: 92px; font-size: 12px; margin: 10px auto 4px; }
}

/* The ending: the house lights are up behind the turned page, so the pages stay in sight above it. */
html body #activity-chrome-ending.site-shriversify {
  justify-content: flex-end;
  background: linear-gradient(to bottom, transparent 0%, transparent 28%, rgba(0, 0, 0, 0.62) 62%);
}
@media (orientation: landscape) {
  html body #activity-chrome-ending.site-shriversify {
    align-items: flex-end;
    justify-content: center;
    padding: 12px calc(76px + env(safe-area-inset-right)) 12px 12px;
    background: linear-gradient(to right, transparent 0%, transparent 40%, rgba(0, 0, 0, 0.62) 64%);
  }
  html body #activity-chrome-ending.site-shriversify .ac-card { width: min(100%, 380px); padding: 24px 22px 16px; }
  /* The finished pages and the tea table take the lit left side; the page of the file turns on the right. */
  .stage.finale-on { grid-template-rows: minmax(0, 1fr); grid-template-areas: "desk desk"; }
  .stage.finale-on .tabs { display: none; }
  .stage.finale-on .desk { margin-top: calc(var(--status) - 4px); }
  .stage.finale-on .finale {
    right: calc(380px + 76px);
    grid-template-columns: minmax(0, 1fr) 120px;
    column-gap: 10px;
  }
  .stage.finale-on .finale-label { display: none; }
  .stage.finale-on .tea { width: 120px; }
}
