/* The Bell for Nine: a ransom-note collage pasted onto foxed pulp paper. Kit colours and fonts only. */

:root {
  --rope-w: 58px;
  --rope-h: min(25dvh, 240px);
  --card-h: clamp(84px, 14dvh, 128px);
  --gap: 8px;
  --tape: color-mix(in srgb, var(--ak-bg) 70%, var(--ak-ink-muted));
  --paper-shadow: drop-shadow(0 5px 7px color-mix(in srgb, var(--ak-ink) 55%, transparent));
  --slide-ms: 900ms;
}

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

body {
  overflow: hidden;
  background-color: var(--ak-bg);
  background-image: var(--ak-bg-art), var(--ak-backdrop-layer, linear-gradient(transparent, transparent));
  background-size: var(--ak-bg-size), cover;
  background-position: 0 0, center;
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
  -webkit-text-size-adjust: 100%;
}

/* Foxing and two old creases on the page. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 72%, color-mix(in srgb, var(--ak-ink-muted) 16%, transparent) 0 2.5%, transparent 5%),
    radial-gradient(circle at 81% 22%, color-mix(in srgb, var(--ak-ink-muted) 12%, transparent) 0 1.8%, transparent 4%),
    radial-gradient(circle at 64% 88%, color-mix(in srgb, var(--ak-ink-muted) 14%, transparent) 0 1.4%, transparent 3%),
    linear-gradient(97deg, transparent 49.8%, color-mix(in srgb, var(--ak-ink-muted) 22%, transparent) 50%, transparent 50.3%),
    linear-gradient(4deg, transparent 63.8%, color-mix(in srgb, var(--ak-ink-muted) 16%, transparent) 64%, transparent 64.25%);
}

svg.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

/* ---------- the play screen ---------- */

.play {
  position: fixed;
  inset: 0;
  z-index: 1;
  box-sizing: border-box;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--rope-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    'rope logo'
    'rope scene'
    'story story';
  gap: var(--gap) 6px;
  padding:
    calc(var(--ac-status-h, 64px) + 2px)
    max(12px, env(safe-area-inset-right))
    max(3dvh, 14px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* A coarse ink halftone closing in from every edge: candlelight on a page. */
.ink-edge {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--ak-ink) 1.7px, transparent 2.2px);
  background-size: 7px 7px;
  -webkit-mask-image: radial-gradient(ellipse 70% 62% at 50% 46%, transparent 55%, #000 100%);
  mask-image: radial-gradient(ellipse 70% 62% at 50% 46%, transparent 55%, #000 100%);
  opacity: 0.85;
  transition: opacity 600ms ease;
}

:root.ac-lights-up .ink-edge {
  opacity: 0.2;
}

.logo-row {
  grid-area: logo;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
}

.logo {
  display: block;
  height: clamp(30px, 6dvh, 50px);
  width: auto;
  rotate: -1.5deg;
}

/* ---------- the rope: the nerve meter ---------- */

.rope-col {
  grid-area: rope;
  position: relative;
  min-height: 0;
  z-index: 2;
  pointer-events: none;
}

.nail {
  position: absolute;
  top: 0;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ak-ink);
  box-shadow: 0 0 0 2px var(--ak-bg);
  translate: -50% 0;
  z-index: 1;
}

.rope {
  position: absolute;
  top: 2px;
  left: 50%;
  height: var(--rope-h);
  aspect-ratio: 224 / 384;
  translate: -50% 0;
  transform-origin: 50% 5%;
  rotate: 0deg;
  filter: drop-shadow(2px 4px 3px color-mix(in srgb, var(--ak-ink) 45%, transparent));
}

.rope.is-still {
  transition: rotate 700ms ease;
}

.rope img {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-user-drag: none;
}

.nerve-word {
  position: absolute;
  top: calc(var(--rope-h) + 8px);
  left: 50%;
  translate: -50% 0;
  rotate: -4deg;
  padding: 2px 7px 3px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font: 600 13px/1.2 var(--ak-font-body);
  letter-spacing: 0.04em;
  white-space: nowrap;
  clip-path: polygon(0 8%, 12% 0, 30% 6%, 55% 0, 78% 7%, 100% 0, 97% 52%, 100% 100%, 70% 93%, 44% 100%, 20% 92%, 0 100%, 3% 50%);
}

/* ---------- the scene ---------- */

.scene-col {
  grid-area: scene;
  position: relative;
  min-height: 0;
}

.scene-stage {
  position: absolute;
  inset: 8px 6px 10px 4px;
}

.scene-slip {
  position: absolute;
  inset: 0;
  rotate: var(--tilt, -1deg);
  filter: var(--paper-shadow);
}

.scene-paper {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: 7px;
  background: var(--ak-bg);
}

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

.scene-svg .i { fill: var(--ak-ink); }
.scene-svg .c { fill: var(--ak-bg); }
.scene-svg .m { fill: var(--ak-ink-muted); }
.scene-svg .o { fill: var(--ak-accent); }

.scene-photo {
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: cover;
}

.scene-board {
  background-image: url('art/bell-board-hall.jpg');
  background-position: 62% 30%;
}

.scene-piece {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.scene-piece .scene-svg {
  position: absolute;
  inset: 0;
}

.piece {
  position: absolute;
  bottom: 3%;
  width: auto;
  -webkit-user-drag: none;
}

.piece-door {
  left: 50%;
  height: 94%;
  translate: -50% 0;
}

.piece-keeper {
  right: 16%;
  height: 95%;
}

/* Tape: a strip of yellowed paper, torn at both ends. */
.tape {
  position: absolute;
  z-index: 3;
  width: 78px;
  height: 22px;
  background: var(--tape);
  clip-path: polygon(4% 0, 96% 0, 92% 22%, 98% 45%, 93% 70%, 97% 100%, 3% 100%, 7% 76%, 1% 52%, 6% 26%);
  pointer-events: none;
}

.tape-tl {
  top: -8px;
  left: -18px;
  rotate: -34deg;
}

.tape-tr {
  top: -6px;
  right: -20px;
  rotate: 31deg;
}

.where-tab {
  position: absolute;
  right: 2px;
  bottom: 0;
  z-index: 4;
  min-width: 48px;
  min-height: 48px;
  padding: 4px 14px 6px;
  border: 0;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font: 400 15px/1 var(--ak-font-display);
  rotate: -3deg;
  cursor: pointer;
  filter: var(--paper-shadow);
  clip-path: polygon(2% 6%, 20% 0, 46% 5%, 74% 0, 98% 4%, 100% 48%, 97% 100%, 66% 95%, 38% 100%, 10% 94%, 0 60%);
}

.where-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.file-marks {
  display: flex;
  align-items: center;
  gap: 3px;
}

.fm-page {
  width: 8px;
  height: 11px;
  box-sizing: border-box;
  border: 1.5px solid var(--ak-ink);
}

.fm-page.is-on {
  background: var(--ak-ink);
}

.fm-page.is-here {
  background: var(--ak-accent);
}

.fm-gap {
  width: 5px;
}

.fm-seal {
  width: 11px;
  height: 11px;
  box-sizing: border-box;
  border: 1.5px dashed var(--ak-ink-muted);
  border-radius: 50%;
}

.fm-seal.is-on {
  border: 1.5px solid var(--ak-ink);
  background: var(--ak-accent);
}

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

/* ---------- the story slip and the choice ---------- */

.story-col {
  grid-area: story;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-height: 0;
  filter: var(--paper-shadow);
}

.story-slip {
  margin: 0 4px 0 10px;
  padding: 13px 16px 15px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font-size: clamp(16px, 1.15dvh + 7px, 18px);
  line-height: 1.42;
  rotate: 0.6deg;
}

.story-slip p {
  margin: 0;
}

.story-slip .return-line {
  font-style: italic;
  color: var(--ak-ink-muted);
}

.story-slip p + p {
  margin-top: 0.35em;
}

.decide {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prompt {
  margin: 0 0 0 4px;
  font-size: clamp(16px, 1.2dvh + 8px, 21px);
  font-weight: 400;
  line-height: 1.55;
}

.cut {
  display: inline-block;
  padding: 1px 6px 2px;
  font-style: normal;
}

.cut-0 { background: var(--ak-surface); color: var(--ak-ink); font-family: var(--ak-font-display); rotate: -2deg; }
.cut-1 { background: var(--ak-btn-fill); color: var(--ak-btn-ink); font-family: var(--ak-font-body); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; rotate: 1.5deg; }
.cut-2 { background: var(--ak-choice-selected-bg); color: var(--ak-choice-selected-ink); font-family: var(--ak-font-display); rotate: -1deg; translate: 0 2px; }
.cut-3 { background: var(--ak-bg); color: var(--ak-ink); font-family: var(--ak-font-body); font-weight: 500; font-style: italic; box-shadow: inset 0 -2px 0 var(--ak-ink); rotate: 2.2deg; }

/* The first move, pinned above the cards until the first tap. */
.first-move {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 6px 2px;
  padding: 10px 12px 10px 14px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: 0 0 0 2px var(--ak-ink);
  font: 600 18px/1.3 var(--ak-font-body);
  rotate: -0.8deg;
}

.first-move-arrow {
  flex: 0 0 auto;
}

.tape-first {
  top: -12px;
  left: -14px;
  width: 56px;
  height: 18px;
  rotate: -28deg;
}

.cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* A luggage tag torn from pulp paper. The painted tag is the card; its face holds the words. */
.card {
  position: relative;
  display: block;
  width: min(100%, calc(var(--card-h) * 2.55));
  height: var(--card-h);
  padding: 0;
  border: 0;
  background: url('art/choice-card.png') no-repeat;
  background-size: 100% 172%;
  background-position: 0 57.4%;
  color: var(--ak-ink);
  cursor: pointer;
  text-align: left;
}

.card-a {
  margin-left: 0;
  rotate: -1.4deg;
}

.card-b {
  margin-left: 26px;
  rotate: 1.8deg;
}

.card-text {
  position: absolute;
  top: 22%;
  bottom: 26%;
  left: 21%;
  right: 5%;
  display: flex;
  align-items: center;
  font-size: clamp(16px, 1.1dvh + 9px, 21px);
  line-height: 1.12;
}

.card-a .card-text {
  font-family: var(--ak-font-display);
}

.card-b .card-text {
  font-family: var(--ak-font-body);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Where the card leads, pinned at its top corner: a page number, or the end of the night. */
.card-note {
  position: absolute;
  top: 1%;
  right: 5%;
  display: flex;
  align-items: center;
  gap: 4px;
  rotate: 2.5deg;
  pointer-events: none;
}

.note-where,
.note-new {
  padding: 2px 7px 3px;
  font: 600 14px/1.1 var(--ak-font-body);
  white-space: nowrap;
}

.note-where {
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: 0 0 0 1.5px var(--ak-ink);
}

.card.ends .note-where {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  box-shadow: none;
  font-style: italic;
}

.note-new {
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  font-family: var(--ak-font-display);
  font-weight: 400;
  rotate: -5deg;
}

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

.card:disabled {
  cursor: default;
}

.card.is-passed {
  opacity: 0.6;
}

.card.is-chosen {
  rotate: 0deg;
}

/* ---------- the reason, taped where the cards were ---------- */

.reason {
  position: relative;
  padding: 14px 6px 4px;
}

.reason-text {
  margin: 0;
  padding: 20px 18px 22px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  font: 400 clamp(24px, 2.4dvh + 10px, 34px)/1.15 var(--ak-font-display);
  text-align: center;
  rotate: -1.5deg;
}

.tape-reason {
  top: 2px;
  left: 50%;
  translate: -50% 0;
  rotate: 3deg;
}

/* ---------- Where am I? ---------- */

.where {
  position: fixed;
  inset: 0;
  z-index: 33;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--ak-ink) 70%, transparent);
}

.where-sheet {
  position: relative;
  width: min(100%, 380px);
  max-height: 100%;
  filter: var(--paper-shadow);
  rotate: -1deg;
}

.tape-where {
  top: -9px;
  left: 50%;
  translate: -50% 0;
  rotate: -4deg;
}

.where-paper {
  box-sizing: border-box;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 22px 22px 14px;
  background: var(--ak-surface);
  color: var(--ak-ink);
}

.where-title {
  margin: 0 0 10px;
  font: 400 24px/1.2 var(--ak-font-display);
}

.where-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.where-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 17px;
}

.where-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font: 400 16px/1 var(--ak-font-display);
}

.is-read .where-mark {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
}

.is-here .where-mark {
  background: var(--ak-choice-selected-bg);
  color: var(--ak-choice-selected-ink);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--ak-ink);
}

.is-unread .where-mark {
  border: 2px dashed var(--ak-ink-muted);
  color: var(--ak-ink-muted);
  box-sizing: border-box;
}

.is-unread .where-name {
  color: var(--ak-ink-muted);
}

.where-note {
  color: var(--ak-ink-muted);
  font-size: 14px;
  font-style: italic;
}

.where-night {
  margin-left: 6px;
  padding: 1px 7px 2px;
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  font: 600 14px/1.3 var(--ak-font-body);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
  display: inline-block;
  rotate: 2deg;
}

.where-intro {
  margin: 0 0 10px;
  color: var(--ak-ink-muted);
  font-size: 15px;
  font-style: italic;
}

.where-scared-row {
  margin: 12px 0 0;
  font-size: 15px;
  line-height: 1.35;
}

.where-endings-title {
  margin: 14px 0 6px;
  font: 400 18px/1.2 var(--ak-font-display);
}

.where-endings {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 16px;
}

.where-endings li {
  padding: 3px 9px;
}

.where-endings .is-found {
  background: var(--ak-btn-fill);
  color: var(--ak-btn-ink);
  rotate: -1.5deg;
}

.where-endings .is-missing {
  border: 2px dashed var(--ak-ink-muted);
  color: var(--ak-ink-muted);
  font-style: italic;
}

.where-close {
  display: block;
  min-height: 48px;
  margin: 14px auto 0;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid var(--ak-ink);
  background: none;
  color: var(--ak-ink);
  font: 400 18px/1 var(--ak-font-display);
  cursor: pointer;
}

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

/* ---------- sideways: the scene on one side, the story and the choice on the other ---------- */

@media (orientation: landscape) {
  :root {
    --rope-w: 60px;
    --rope-h: min(56dvh, 330px);
    --card-h: clamp(70px, 23dvh, 118px);
  }

  .play {
    max-width: 1120px;
    grid-template-columns: var(--rope-w) minmax(0, 1.05fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      'rope scene logo'
      'rope scene story';
    column-gap: 14px;
    padding-top: max(10px, env(safe-area-inset-top));
  }

  .rope-col,
  .scene-col {
    margin-top: calc(var(--ac-status-h, 64px) - 6px);
  }

  .logo-row {
    justify-content: flex-end;
    padding-right: 64px;
    min-height: 48px;
  }

  .logo {
    height: clamp(30px, 7dvh, 72px);
  }

  .story-col {
    justify-content: flex-start;
  }

  .cards {
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
  }

  .card {
    width: calc(50% - 3px);
    flex: 0 0 auto;
  }

  .card-b {
    margin-top: 10px;
    margin-left: 0;
  }

  .card-text {
    left: 20%;
    right: 4%;
    font-size: clamp(14px, 1.6dvh + 8px, 20px);
  }

  .story-slip {
    font-size: clamp(15px, 1.5dvh + 9px, 18px);
    line-height: 1.36;
  }
}

/* ---------- motion: slow paper only, never with reduced motion or Less motion ---------- */

.scene-slip.is-fading-in { animation: bn-fade-in 500ms ease both; }
.scene-slip.is-leaving { animation: bn-fade-out 500ms ease both; }

@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .scene-slip.is-sliding-in {
    animation: bn-slide-in var(--slide-ms) cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  :root:not(.ac-still) .scene-slip.is-sliding-in .tape {
    animation: bn-tape var(--slide-ms) cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  :root:not(.ac-still) .scene-slip.is-leaving {
    animation: bn-slide-out 700ms ease-in both;
  }

  :root:not(.ac-still) .story-slip.is-new {
    animation: bn-settle 760ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  :root:not(.ac-still) .card {
    transition: opacity 420ms ease, rotate 420ms ease, translate 420ms ease;
  }

  :root:not(.ac-still) .card.is-chosen {
    translate: 0 2px;
  }

  :root:not(.ac-still) .reason:not([hidden]) .reason-text {
    animation: bn-settle 760ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  :root:not(.ac-still) .reason:not([hidden]) .tape-reason {
    animation: bn-tape 760ms 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

@keyframes bn-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes bn-fade-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes bn-slide-in {
  from { opacity: 0; transform: translate(38px, -22px) rotate(5deg); }
  45% { opacity: 1; }
  to { opacity: 1; transform: none; }
}

@keyframes bn-slide-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translate(-26px, 14px) rotate(-3deg); }
}

@keyframes bn-settle {
  from { opacity: 0; transform: translateY(12px) rotate(-1.4deg); }
  to { opacity: 1; transform: none; }
}

@keyframes bn-tape {
  0%, 55% { opacity: 0; transform: scaleX(0.2); }
  to { opacity: 1; transform: scaleX(1); }
}

/* Sideways and short: the Where am I? slip goes wide so it all fits at once. */
@media (max-height: 520px) {
  .where-sheet {
    width: min(100%, 680px);
  }

  .where-paper {
    padding: 16px 22px 8px;
  }

  .where-title {
    margin-bottom: 4px;
    font-size: 21px;
  }

  .where-intro {
    margin-bottom: 6px;
  }

  .where-list {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(4, auto);
    grid-auto-flow: column;
    gap: 3px 22px;
  }

  .where-endings-title {
    margin-top: 8px;
  }

  .where-scared-row {
    margin-top: 8px;
  }

  .where-close {
    margin-top: 6px;
  }
}

/* The rope never hangs past its own column: it shortens when the scene row is short. */
.rope-col {
  container-type: size;
}

.rope {
  height: min(var(--rope-h), calc(100cqh - 30px));
}

.nerve-word {
  top: calc(min(var(--rope-h), 100cqh - 30px) + 6px);
}

/* Short upright phones: slimmer cards and first-move note leave the scene room to breathe. */
@media (orientation: portrait) and (max-height: 760px) {
  :root {
    --card-h: clamp(78px, 12.5dvh, 120px);
  }

  .first-move {
    padding: 6px 10px 6px 12px;
  }

  .decide {
    gap: 4px;
  }
}

/* ---------- the ending: the chrome's own page, with the story screen put away behind it ---------- */

body.bn-ending #play,
body.bn-ending #activity-chrome-status,
body.bn-ending #activity-chrome-toast {
  visibility: hidden;
}

/* Keep the page clear of the ? corner, and let it scroll from its top if a short screen needs it. */
body #activity-chrome-ending.site-shriversify {
  padding: max(68px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

body #activity-chrome-ending.site-shriversify .ac-card {
  margin: auto;
}

/* The one accent: a short orange rule over the line that names the sealing choice. */
body #activity-chrome-ending .ac-line.bn-seal {
  margin-top: 14px;
  color: var(--ak-ink);
  font-style: normal;
}

body #activity-chrome-ending .ac-line.bn-seal::before {
  content: '';
  display: block;
  width: 36px;
  height: 3px;
  margin: 0 auto 10px;
  background: var(--ak-accent);
}

body #activity-chrome-ending .ac-line.bn-next {
  margin-top: 12px;
  font-size: 15px;
}

/* Another night reads as a button: the chrome's own, with a plain frame around it. */
body #activity-chrome-ending.site-shriversify .ac-actions .ac-replay {
  padding: 0 20px;
  border: 1px solid var(--ak-ink);
}

body #activity-chrome-ending .ac-work img {
  width: auto;
  max-height: min(14dvh, 150px);
  margin: 0 auto;
}

@media (orientation: portrait) and (max-height: 780px) {
  body #activity-chrome-ending .ac-work {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  body #activity-chrome-ending.site-shriversify {
    padding: max(8px, env(safe-area-inset-top)) max(80px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(80px, env(safe-area-inset-left));
  }

  body #activity-chrome-ending.site-shriversify .ac-card {
    width: min(100%, 680px);
    padding: 18px 28px 10px;
  }

  body #activity-chrome-ending .ac-work {
    display: none;
  }

  body #activity-chrome-ending.site-shriversify .ac-verdict {
    margin-bottom: 8px;
    padding-bottom: 8px;
  }
}

/* Stuck on a page: a short thought takes the question's place, with a small bell. It stays until you choose. */
.hint-slip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 6px 0;
  padding: 8px 12px 9px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: inset 3px 0 0 var(--ak-accent);
  font: italic 500 17px/1.35 var(--ak-font-body);
  rotate: 0.6deg;
}

.hint-bell {
  flex: 0 0 auto;
  margin-top: 1px;
}

/* ---------- before the story starts: the case file lies in the dark ---------- */

body:not(.bn-live) {
  background-color: var(--ak-ink);
  background-image: radial-gradient(color-mix(in srgb, var(--ak-ink-muted) 50%, transparent) 1.3px, transparent 1.8px);
  background-size: 7px 7px;
}

body:not(.bn-live)::before {
  display: none;
}

/* ---------- the opening: start.js's own scene, dressed as a note from the housekeeper ---------- */

html body #activity-start#activity-start.site-shriversify {
  background-color: var(--ak-ink);
  background-image: radial-gradient(color-mix(in srgb, var(--ak-ink-muted) 50%, transparent) 1.3px, transparent 1.8px);
  background-size: 7px 7px;
}

/* start.js paints its washed backdrop on two fixed layers; here they become the dark the letter lies in. */
html body #activity-start#activity-start.site-shriversify.has-backdrop::before {
  background-color: var(--ak-ink);
  background-image: radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--ak-ink-muted) 45%, transparent), transparent 70%);
  background-size: cover;
}

html body #activity-start#activity-start.site-shriversify.has-backdrop::after {
  background-image: radial-gradient(color-mix(in srgb, var(--ak-ink-muted) 45%, transparent) 1.3px, transparent 1.8px);
  background-size: 7px 7px;
}

html body #activity-start#activity-start.is-scene .ak-scene {
  position: relative;
  box-sizing: border-box;
  width: min(100%, 440px);
  min-height: 0;
  margin: 3dvh auto;
  padding: 30px 26px 22px;
  gap: 18px;
  background-color: var(--ak-surface);
  background-image:
    radial-gradient(circle at 14% 86%, color-mix(in srgb, var(--ak-ink-muted) 15%, transparent) 0 16px, transparent 38px),
    radial-gradient(circle at 90% 10%, color-mix(in srgb, var(--ak-ink-muted) 12%, transparent) 0 10px, transparent 28px),
    linear-gradient(176deg, transparent 58%, color-mix(in srgb, var(--ak-ink-muted) 16%, transparent) 58.2%, transparent 58.6%);
  color: var(--ak-ink);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6);
  rotate: -0.8deg;
}

html body #activity-start#activity-start.is-scene .ak-scene::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  width: 88px;
  height: 22px;
  background: var(--tape);
  translate: -50% 0;
  rotate: 2deg;
  clip-path: polygon(4% 0, 96% 0, 92% 22%, 98% 45%, 93% 70%, 97% 100%, 3% 100%, 7% 76%, 1% 52%, 6% 26%);
}

html body #activity-start#activity-start.is-scene .ak-scene-line {
  color: var(--ak-ink);
  font-size: clamp(18px, 4.4vw, 22px);
  text-shadow: none;
}

html body #activity-start#activity-start.is-scene .ak-scene-lines::after {
  content: '\2014  the housekeeper';
  display: block;
  text-align: right;
  color: var(--ak-ink-muted);
  font: italic 400 16px/1.3 var(--ak-font-body);
}

/* Her seal: a small disc of orange wax, pressed with a ring. Tap it to open the letter. */
html body #activity-start#activity-start.is-scene .ak-go {
  width: 88px;
  height: 88px;
  min-width: 0;
  min-height: 0;
  padding: 8px;
  border: 0;
  background: var(--ak-accent);
  color: var(--ak-choice-selected-ink);
  box-shadow:
    inset 0 0 0 5px color-mix(in srgb, var(--ak-accent) 72%, var(--ak-ink)),
    inset 0 0 0 8px var(--ak-accent),
    inset 0 0 0 9.5px color-mix(in srgb, var(--ak-accent) 55%, var(--ak-ink)),
    0 3px 6px rgba(0, 0, 0, 0.45);
  font-family: var(--ak-font-display);
  font-size: 13px;
  letter-spacing: 0.04em;
}

html body #activity-start#activity-start.is-scene .ak-go:hover,
html body #activity-start#activity-start.is-scene .ak-go:active {
  background: var(--ak-btn-active);
  color: var(--ak-choice-selected-ink);
}

/* Sideways: the letter on the left, her seal on the right, so it all sits on one screen. */
@media (orientation: landscape) and (max-height: 520px) {
  html body #activity-start#activity-start.is-scene .ak-scene {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 160px;
    align-items: center;
    width: min(100%, 720px);
    margin: 1dvh auto;
    padding: 16px 22px 14px;
    gap: 8px 18px;
  }

  html body #activity-start#activity-start.is-scene .ak-head {
    grid-column: 1;
  }

  html body #activity-start#activity-start.is-scene .ak-scene-lines {
    grid-column: 1;
    gap: 6px;
    max-width: none;
  }

  html body #activity-start#activity-start.is-scene .ak-scene-line {
    font-size: 17px;
  }

  html body #activity-start#activity-start.is-scene .ak-scene-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  html body #activity-start#activity-start.is-scene .ak-go {
    order: 0;
    width: 76px;
    height: 76px;
    margin: 0;
    font-size: 12px;
  }

  html body #activity-start#activity-start.is-scene .ak-jump {
    order: 1;
    text-align: center;
  }
}

/* ---------- tall landscape (tablet, desktop): the scene above the story, the choices side by side under it ---------- */

@media (orientation: landscape) and (min-height: 600px) {
  .play {
    max-width: 920px;
    grid-template-columns: var(--rope-w) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      'rope logo'
      'rope scene'
      'story story';
    padding-top: calc(var(--ac-status-h, 64px) + 2px);
    column-gap: 10px;
  }

  .rope-col,
  .scene-col {
    margin-top: 0;
  }

  .logo-row {
    justify-content: center;
    padding-right: 0;
  }

  .story-col {
    padding-left: calc(var(--rope-w) + 10px);
  }

  .cards {
    justify-content: center;
    gap: 18px;
  }

  .card {
    width: min(calc(50% - 9px), calc(var(--card-h) * 2.55));
  }
}
