/* The Last Ferry: a driftwood chart table seen straight down. The chart runs edge to edge,
   the scene plate is tacked to it, the tickets lie below, and the lantern, the tin tray and
   two pencilled cards sit on the table's near edge. */

:root {
  --pad: clamp(8px, 2.4vw, 14px);
  --gap: clamp(6px, 1.4dvh, 12px);
  --wash-light: color-mix(in srgb, var(--ak-bg) 58%, transparent);
  --pool: radial-gradient(circle at 0% 100%, color-mix(in srgb, var(--ak-accent) 26%, transparent) 0%, transparent 42%);
  --ink-line: color-mix(in srgb, var(--ak-ink-muted) 70%, transparent);
  --brass: radial-gradient(circle at 35% 30%, var(--ak-btn-hover) 0%, var(--ak-btn-active) 55%, var(--ak-bg) 100%);
  --fade-ms: 400ms;
  --slide-ms: 1300ms;
  --breath-ms: 2400ms;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background-color: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-body);
}

body {
  background-image: var(--ak-bg-art);
  background-size: var(--ak-bg-size);
}

button { font: inherit; color: inherit; }

/* The table. Not fixed and no z-index, so the lantern can rise above the ending's dark. */
.table {
  position: relative;
  height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "logo" "chart" "tickets" "edge";
  gap: var(--gap);
  padding:
    calc(var(--ac-status-h, 64px) + 4px)
    max(var(--pad), env(safe-area-inset-right), calc((100vw - 560px) / 2))
    max(10px, env(safe-area-inset-bottom))
    max(var(--pad), env(safe-area-inset-left), calc((100vw - 560px) / 2));
  background-color: var(--ak-bg);
  background-image: var(--pool), var(--ak-backdrop-layer, none);
  background-size: cover;
  background-position: center;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

:root.ac-lights-up .table {
  background-image: var(--pool), linear-gradient(var(--wash-light), var(--wash-light)), url("./art/chart-table.jpg");
}

.logo {
  grid-area: logo;
  justify-self: center;
  display: block;
  height: clamp(26px, 4.4dvh, 40px);
  width: auto;
  max-width: 60%;
  object-fit: contain;
}

/* The chart: the board. It runs to both screen edges, ruled top and bottom like the inked border. */
.chart {
  grid-area: chart;
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  /* The words get their full height first; the plate takes what is left (game.js fits it). */
  grid-template-rows: minmax(0, auto) auto;
  grid-template-areas: "channel plate" "channel strip";
  align-content: start;
  column-gap: 10px;
  row-gap: var(--gap);
  margin-inline: calc(-1 * max(var(--pad), env(safe-area-inset-left), calc((100vw - 560px) / 2)));
  padding: 10px max(var(--pad), env(safe-area-inset-right), calc((100vw - 560px) / 2)) 10px max(var(--pad), env(safe-area-inset-left), calc((100vw - 560px) / 2));
  border-block: 3px double var(--ink-line);
}

.channel {
  grid-area: channel;
  position: relative;
  min-height: 160px;
}

.channel-svg {
  position: absolute;
  inset: 4px 0;
  width: 100%;
  height: calc(100% - 8px);
  overflow: visible;
}

.channel-line {
  fill: none;
  stroke: var(--ak-ink);
  stroke-width: 4;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

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

/* Each stop is numbered in ink on the channel, so "Stop 5" on a ticket points at a dot. */
.station {
  position: absolute;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--ak-ink-muted);
  border-radius: 50%;
  background: var(--ak-bg);
  color: var(--ak-ink);
  font-family: var(--ak-font-display);
  font-size: 12px;
  line-height: 1;
  transition: box-shadow var(--fade-ms) ease, border-color var(--fade-ms) ease;
}

.station.is-passed { background: var(--ak-ink); border-color: var(--ak-ink); color: var(--ak-bg); }
.station.is-uncharted { border-style: dashed; background: color-mix(in srgb, var(--ak-bg) 70%, transparent); color: var(--ak-ink-muted); }
.station.is-target { border-color: var(--ak-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ak-accent) 45%, transparent); }

.token {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.75));
  will-change: transform;
}

.token svg { display: block; width: 100%; height: 100%; }
.token-hull { fill: var(--ak-ink); stroke: var(--ak-bg); stroke-width: 2.5; stroke-linejoin: round; }
.token-seat { fill: none; stroke: var(--ak-bg); stroke-width: 2.5; stroke-linecap: round; }

/* The scene plate, tacked flat to the chart. */
.plate {
  grid-area: plate;
  position: relative;
  margin: 0;
  padding: 5px;
  background: var(--ak-surface);
  border: 1px solid var(--ak-outline);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.65);
}

.plate-art {
  position: relative;
  width: 100%;
  height: min(calc((min(100vw, 560px) - 2 * var(--pad) - 72px) / 2), 30dvh);
  overflow: hidden;
  background: var(--ak-bg);
}


.scene { display: block; width: 100%; height: 100%; }
.plate.is-folded { display: none; }

.tack {
  position: absolute;
  top: -6px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 3px 4px rgba(0, 0, 0, 0.7);
  z-index: 1;
}
.tack-left { left: 14px; }
.tack-right { right: 14px; }

/* Scene plate ink. */
.s-sky { fill: var(--ak-bg); }
.s-fog { fill: var(--ak-ink-muted); opacity: 0.28; }
.s-fog-soft { opacity: 0.16; }
.s-band { fill: var(--ak-ink-muted); opacity: 0.2; }
.s-deep { fill: var(--ak-surface); }
.s-dawn { fill: var(--ak-ink-muted); opacity: 0.34; }
.s-horizon { stroke: var(--ak-accent); stroke-width: 1.5; opacity: 0.7; }
.s-ripple { fill: none; stroke: var(--ak-ink-muted); stroke-width: 1.4; opacity: 0.7; stroke-linecap: round; }
.s-hull { fill: var(--ak-bg); stroke: var(--ak-bg); stroke-width: 1; }
.s-rim { fill: none; stroke: var(--ak-ink); stroke-width: 2; stroke-linecap: round; opacity: 0.85; }
.s-rim-soft { fill: none; stroke: var(--ak-ink-muted); stroke-width: 1.5; }
.s-wood { fill: var(--ak-outline); }
.s-wood-line { fill: none; stroke: var(--ak-outline); stroke-width: 4; stroke-linecap: round; }
.s-pole { fill: none; stroke: var(--ak-outline); stroke-width: 3; stroke-linecap: round; }
.s-pole-bright { fill: none; stroke: var(--ak-ink-muted); stroke-width: 4; stroke-linecap: round; }
.s-bone { fill: var(--ak-ink); }
.s-drip { fill: none; stroke: var(--ak-ink-muted); stroke-width: 1.4; stroke-linecap: round; opacity: 0.6; }
.s-hand { fill: var(--ak-outline); }
.s-hand-pale { fill: var(--ak-ink-muted); }
.s-iron { fill: var(--ak-bg); stroke: var(--ak-outline); stroke-width: 1; }
.s-iron-ring { fill: none; stroke: var(--ak-outline); stroke-width: 1.5; }
.s-pane { fill: var(--ak-outline); }
.s-pane-lit { fill: var(--ak-accent); }
.s-pool { fill: var(--ak-accent); opacity: 0.14; }
.s-ring { fill: none; stroke: var(--ak-ink-muted); stroke-width: 1.6; stroke-linecap: round; }
.s-knock { fill: var(--ak-ink); }
.s-door { fill: var(--ak-accent); opacity: 0.55; }

:root.ac-lights-up .plate-art { filter: brightness(1.3); }

/* The typed strip under the plate. */
.strip {
  grid-area: strip;
  position: relative;
  padding: 8px 16px 10px;
  background: var(--ak-surface);
  color: var(--ak-ink);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.55);
  /* Last resort on the tiniest screens, once the plate has given up all it can. */
  overflow-y: auto;
  clip-path: polygon(0 4%, 2% 0, 30% 3%, 62% 0, 98% 2%, 100% 0, 99% 50%, 100% 100%, 70% 97%, 36% 100%, 3% 98%, 0 100%, 1% 52%);
}

.strip-place {
  margin: 0 0 2px;
  color: var(--ak-ink-muted);
  font-family: var(--ak-font-display);
  font-size: 16px;
  letter-spacing: 0.08em;
}

.strip-lines p {
  margin: 0;
  font-size: clamp(17px, 2.3dvh, 19px);
  line-height: 1.32;
}

.strip-lines p + p { margin-top: 2px; }
.strip-lines p.is-again { color: var(--ak-ink-muted); font-style: italic; }
/* What your ticket did: said in the strip the instant it is taken, then heading the next stop. */
.strip-lines p.is-echo { color: var(--ak-accent); font-style: italic; }
.strip-lines p.is-lead { color: var(--ak-accent); font-style: italic; }
@media (max-height: 680px) { .strip-lines p { font-size: 16px; line-height: 1.28; } }
.strip.is-ending .strip-lines p:first-child { font-family: var(--ak-font-display); font-size: clamp(20px, 3dvh, 24px); }
.strip.is-ending .strip-lines p + p { color: var(--ak-ink-muted); font-style: italic; }

/* The two tickets. */
.tickets {
  grid-area: tickets;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ticket {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: clamp(76px, 12.5dvh, 112px);
  margin: 0;
  padding: 5% 17% 7% 21%;
  border: 0;
  background: url("./art/choice-card.png") center / 100% 100% no-repeat;
  color: var(--ak-choice-selected-ink);
  font-size: clamp(16px, 2.2dvh, 19px);
  font-weight: 600;
  line-height: 1.18;
  text-align: center;
  cursor: pointer;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.7));
  touch-action: manipulation;
}

.ticket:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: 3px; }
.ticket:disabled { cursor: default; }

.ticket-key {
  position: absolute;
  left: 7%;
  bottom: 12%;
  width: 9%;
  text-align: center;
  font-family: var(--ak-font-display);
  font-size: 14px;
  font-weight: 400;
  opacity: 0.75;
}

.ticket.is-settling { opacity: 0.5; }
.ticket.is-dropped { opacity: 0.22; filter: grayscale(1) drop-shadow(0 6px 6px rgba(0, 0, 0, 0.7)); }

/* The taken ticket answers the tap at once, with or without motion: lit at the edge by the
   lantern's wax yellow and stamped Taken. */
.ticket.is-chosen {
  filter: drop-shadow(0 0 2px var(--ak-accent)) drop-shadow(0 0 10px var(--ak-accent)) drop-shadow(0 6px 6px rgba(0, 0, 0, 0.7));
}
.ticket.is-chosen .ticket-stamp {
  display: block;
  background: var(--ak-accent);
  border-color: var(--ak-btn-ink);
  color: var(--ak-btn-ink);
}

/* A ticket no crossing has taken yet: a small bone tag pinned over its top edge, clear of the words. */
.ticket-stamp {
  display: none;
  position: absolute;
  top: -9px;
  right: 14%;
  z-index: 1;
  padding: 1px 6px 0;
  border: 1.5px solid var(--ak-choice-selected-ink);
  border-radius: 2px;
  background: var(--ak-ink);
  color: var(--ak-choice-selected-ink);
  font-family: var(--ak-font-display);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.3;
  transform: rotate(3deg);
}
.ticket.is-untried .ticket-stamp { display: block; }

.ticket-body { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.hint-where, .hint-does { display: block; }

/* What the ticket does, pencilled under the choice: where the ferry goes and how the flame moves. */
.ticket-hint {
  font-size: 13px;
  font-weight: 400;
  font-style: italic;
  line-height: 1.15;
  opacity: 0.78;
}

/* A ticket that ends the crossing says so in full ink, underlined; red stays on the seal and the thread. */
.ticket.is-final .hint-where {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}
.ticket.is-final .ticket-hint { opacity: 1; }

/* The near edge of the table: lantern, tin tray, two cards. */
.edge {
  grid-area: edge;
  display: grid;
  grid-template-columns: auto minmax(84px, 0.8fr) minmax(0, 1.4fr);
  gap: 10px;
  align-items: end;
}

.lantern {
  grid-column: 1;
  position: relative;
  width: calc(clamp(76px, 13.5dvh, 120px) * 295 / 384);
  height: clamp(76px, 13.5dvh, 120px);
}

/* At the ending the lantern is the only light left, set down at the near corner above the dark. */
.table.is-ended .lantern {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 33;
  pointer-events: none;
}

.lantern::before {
  content: "";
  position: absolute;
  inset: -40% -60% -20% -60%;
  background: radial-gradient(ellipse at 50% 70%, color-mix(in srgb, var(--ak-accent) 30%, transparent), transparent 65%);
  opacity: calc(0.2 + var(--flame-y, 0.64) * 0.8);
  pointer-events: none;
}

.lantern-body, .lantern-glass {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* The glass dims with the flame: grey and cold at a bead, warm through every pane when it is full. */
.glass { fill: color-mix(in srgb, var(--ak-ink) 62%, #3a352c); }
.glass-glow { opacity: calc(0.12 + var(--flame-y, 0.64) * 0.85); }
.glow-core { stop-color: var(--ak-accent); stop-opacity: 0.9; }
.glow-edge { stop-color: var(--ak-ink); stop-opacity: 0.35; }
.flame-outer {
  fill: var(--ak-accent);
  stroke: #1a130c;
  stroke-width: 3;
  stroke-linejoin: round;
  paint-order: stroke;
  vector-effect: non-scaling-stroke;
}
.flame-inner { fill: var(--ak-btn-hover); opacity: 0.85; }

.flame {
  transform-box: view-box;
  transform-origin: 142px 344px;
  transform: scale(var(--flame-x, 0.85), var(--flame-y, 0.62));
}

.lantern-hand {
  position: absolute;
  left: 14%;
  bottom: 78%;
  width: 72%;
  display: none;
}
.hand-sleeve { fill: #15100c; stroke: #000; stroke-width: 2; }
.hand-rim { fill: none; stroke: var(--ak-ink); stroke-width: 3; stroke-linecap: round; opacity: 0.85; }
.hand-cuff { fill: var(--ak-ink-muted); }
.hand-grip { fill: color-mix(in srgb, var(--ak-ink) 82%, #8a7560); stroke: #1a130c; stroke-width: 2.5; }
.hand-finger { fill: none; stroke: #1a130c; stroke-width: 2; stroke-linecap: round; }
.lantern.in-hand .lantern-hand { display: block; }

.tray {
  grid-column: 2;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px 8px;
  border: 2px solid var(--ak-outline);
  border-radius: 6px;
  background: var(--ak-surface);
  box-shadow: inset 0 0 0 3px var(--ak-bg), inset 0 6px 12px rgba(0, 0, 0, 0.8), 0 6px 12px rgba(0, 0, 0, 0.5);
}

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

.tray-well {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 46px;
}

.tray-well img { width: 44px; height: 44px; display: block; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.8)); }
.tray-well img:nth-child(2) { rotate: 24deg; }
.tray-empty { color: var(--ak-ink-muted); font-style: italic; font-size: 15px; }

.notes {
  grid-column: 3;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.note {
  margin: 0;
  padding: 6px 10px;
  border: 1px dashed var(--ak-ink-muted);
  background: var(--ak-surface);
  color: var(--ak-ink);
  text-align: left;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.55);
}

.goal { rotate: 1.2deg; }
.note-text { margin: 0; font-size: 15px; line-height: 1.2; font-style: italic; }

.found {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 0;
  color: var(--ak-ink-muted);
  font-size: 14px;
}
.found svg { width: 14px; height: 14px; display: block; }
.found .mark-ring { fill: none; stroke: var(--ak-ink-muted); stroke-width: 2; }
.found .mark-fill { fill: var(--ak-ink); stroke: var(--ak-ink); stroke-width: 2; }

.where {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 52px;
  border-style: solid;
  border-color: var(--ak-outline);
  cursor: pointer;
  rotate: -1.5deg;
}
.where:focus-visible { outline: 3px solid var(--ak-focus); outline-offset: 2px; }
.where-title { font-family: var(--ak-font-display); font-size: 18px; line-height: 1.1; }
.where-sub { color: var(--ak-ink-muted); font-size: 14px; font-style: italic; }

/* The ending: the dark comes in and only the lantern stays lit. */
.dark {
  position: fixed;
  inset: 0;
  z-index: 28;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.table.is-ended .dark { opacity: 1; visibility: visible; }

.table.is-ended .tickets,
.table.is-ended .tray,
.table.is-ended .notes,
.table.is-ended .token { opacity: 0; visibility: hidden; }
.table.is-ended .tickets { transform: translateX(-110vw) rotate(-6deg); }
.table.is-ended .tray { transform: translateX(110vw) rotate(8deg); }
.table.is-ended .notes { transform: translateX(110vw) rotate(-10deg); }

/* Sideways: chart on the left, tickets and the table edge on the right. */
@media (orientation: landscape) {
  .table {
    grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
    /* The first row is as tall as the status card, so the tickets start below it and the help button. */
    grid-template-rows: minmax(calc(var(--ac-status-h, 64px) - 8px), auto) auto minmax(0, 1fr) auto;
    grid-template-areas:
      "chart logo"
      "chart tickets"
      "chart ."
      "chart edge";
    column-gap: clamp(12px, 2.4vw, 28px);
    row-gap: clamp(6px, 1.6dvh, 12px);
    /* The status card only covers the chart's column, so only the chart steps down for it; the
       right-hand column starts near the top, beside it, and the whole table fits one screen. */
    padding:
      max(8px, env(safe-area-inset-top))
      max(var(--pad), env(safe-area-inset-right), calc((100vw - 1040px) / 2))
      max(8px, env(safe-area-inset-bottom))
      max(var(--pad), env(safe-area-inset-left), calc((100vw - 1040px) / 2));
  }

  .chart {
    margin: calc(-1 * max(8px, env(safe-area-inset-top))) 0 0 calc(-1 * max(var(--pad), env(safe-area-inset-left), calc((100vw - 1040px) / 2)));
    padding: calc(var(--ac-status-h, 64px) + 4px) 12px 8px max(var(--pad), env(safe-area-inset-left), calc((100vw - 1040px) / 2));
    border-block: 0;
    border-right: 3px double var(--ink-line);
    align-content: center;
  }

  /* The logo sits top centre of the right column, clear of the help button in the corner. */
  .logo { align-self: center; margin-right: 56px; }
  /* Both grid templates above name a logo row; this one keeps the help button's corner clear. */

  .plate-art { height: min(calc((min(100vw, 1040px) * 0.53 - 90px) / 2), 36dvh); }
  .strip-lines p { font-size: clamp(16px, 4.4dvh, 19px); }
  .ticket { min-height: clamp(72px, 24dvh, 112px); }
  .lantern { height: clamp(64px, 22dvh, 104px); width: calc(clamp(64px, 22dvh, 104px) * 295 / 384); }
  .logo { height: clamp(24px, 8dvh, 40px); }
}

@media (orientation: landscape) and (max-height: 420px) {
  .note-text { font-size: 14px; }
  .where { min-height: 44px; padding-block: 4px; }
  .where-title { font-size: 16px; }
  .where-sub { font-size: 13px; }
  .tray-label { font-size: 14px; }
  .strip { padding: 6px 12px 8px; }
  .strip-place { font-size: 14px; }
}

/* A short phone upright: the words come first. The logo steps aside (the status card and the
   letter already carry the name) and the notes tighten, so the chart keeps its scene. */
@media (orientation: portrait) and (max-height: 700px) {
  .logo { display: none; }
  .table { grid-template-rows: 0 minmax(0, 1fr) auto auto; row-gap: 8px; }
  .note { padding: 4px 9px; }
  .note-text { font-size: 14px; line-height: 1.15; }
  .where { min-height: 0; }
  .where-title { font-size: 16px; }
  .where-sub { font-size: 13px; }
  .found { margin-top: 2px; }
}

/* The narrowest phones upright: a slimmer channel and tighter type buy the words their lines. */
@media (orientation: portrait) and (max-width: 340px) {
  .chart { grid-template-columns: 40px minmax(0, 1fr); column-gap: 6px; }
  .strip { padding: 6px 10px 8px; }
  .strip-place { font-size: 14px; }
  .strip-lines p { font-size: 15px; line-height: 1.24; }
  .ticket { font-size: 15px; }
  .edge { grid-template-columns: auto minmax(70px, 0.7fr) minmax(0, 1.4fr); gap: 8px; }
  .note-text { font-size: 13px; }
}

/* A small phone on its side: lantern and tray share a row, the two notes lie side by side under
   them, and the tickets start below the help button, so nothing falls off the bottom. */
@media (orientation: landscape) and (max-height: 365px) {
  .table { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .logo { height: 26px; }
  .tickets { gap: 8px; }
  .table { row-gap: 5px; }
  .ticket { min-height: 60px; font-size: 14px; padding: 4% 15% 6% 21%; }
  .ticket-hint { font-size: 11.5px; }
  .ticket-stamp { font-size: 10.5px; }
  .edge {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: stretch;
    gap: 6px 8px;
  }
  .lantern { grid-row: 1; height: 58px; width: calc(58px * 295 / 384); align-self: end; }
  .tray { grid-row: 1; flex-direction: row; align-items: center; gap: 8px; padding: 4px 8px; }
  .tray-well { min-height: 40px; }
  .tray-well img { width: 36px; height: 36px; }
  .notes { grid-column: 1 / -1; grid-row: 2; flex-direction: row; gap: 6px; }
  .notes .note { flex: 1 1 0; min-width: 0; padding: 4px 8px; }
  .note-text { font-size: 12.5px; line-height: 1.15; }
  .found { margin-top: 2px; font-size: 12px; }
  .where { min-height: 0; rotate: -1deg; }
  .strip-lines p { font-size: 15px; line-height: 1.25; }
  .strip-lines p + p { margin-top: 1px; }
  .chart { grid-template-columns: 38px minmax(0, 1fr); column-gap: 6px; }
  .strip { padding: 5px 10px 6px; }
  .strip-place { margin: 0; font-size: 13px; }
}

@media (orientation: landscape) and (max-height: 330px) {
  .strip-lines p { font-size: 14px; line-height: 1.22; }
}

/* Motion: slow, and only when asked for. */
@media (prefers-reduced-motion: no-preference) {
  :root:not(.ac-still) .plate-art,
  :root:not(.ac-still) .strip-lines,
  :root:not(.ac-still) .strip-place { transition: opacity var(--fade-ms) ease-in-out; }
  :root:not(.ac-still) .chart.is-fading .plate-art,
  :root:not(.ac-still) .chart.is-fading .strip-lines,
  :root:not(.ac-still) .chart.is-fading .strip-place { opacity: 0; }

  :root:not(.ac-still) .flame { transition: transform var(--breath-ms) cubic-bezier(0.45, 0, 0.3, 1); }
  :root:not(.ac-still) .glass-glow,
  :root:not(.ac-still) .lantern::before { transition: opacity var(--breath-ms) ease-in-out; }
  :root:not(.ac-still) .flame-inner { animation: sway 5.5s ease-in-out infinite alternate; transform-box: view-box; transform-origin: 146px 350px; }

  :root:not(.ac-still) .ticket { transition: opacity 250ms ease, transform 250ms ease, filter 250ms ease; }
  :root:not(.ac-still) .ticket:active:not(:disabled) { transform: translateY(2px); }
  :root:not(.ac-still) .ticket.is-chosen { transform: translateY(-3px); }
  :root:not(.ac-still) .tickets.invite .ticket { animation: wax 3.6s ease-in-out infinite; }
  :root:not(.ac-still) .tickets.invite .ticket + .ticket { animation-delay: 1.8s; }

  :root:not(.ac-still) .dark { transition: opacity 1200ms ease, visibility 0s linear 1200ms; }
  :root:not(.ac-still) .table.is-ended .dark { transition: opacity 1200ms ease, visibility 0s; }
  :root:not(.ac-still) .tickets,
  :root:not(.ac-still) .tray,
  :root:not(.ac-still) .notes { transition: transform 900ms cubic-bezier(0.5, 0, 0.75, 0), opacity 900ms ease-in, visibility 0s linear 900ms; }
  :root:not(.ac-still) .table.is-ended .token { transition: opacity 900ms ease-in, visibility 0s linear 900ms; }
  :root:not(.ac-still) .table:not(.is-ended) .tickets,
  :root:not(.ac-still) .table:not(.is-ended) .tray,
  :root:not(.ac-still) .table:not(.is-ended) .notes { transition: opacity 700ms ease-out, transform 0s, visibility 0s; }

  @keyframes sway { from { transform: scaleX(0.92); } to { transform: scaleX(1.06); } }
  @keyframes wax {
    0%, 100% { filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.7)); }
    50% { filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 9px color-mix(in srgb, var(--ak-accent) 55%, transparent)); }
  }
}

/* The ending card. The kit's card sets everything in the small-caps display face; the story
   reads in the body face at a comfortable size, and the card scrolls rather than run off a
   short screen. */
html body #activity-chrome-ending.site-shriversify { overflow-y: auto; align-items: flex-start; padding: 16px; }
html body #activity-chrome-ending.site-shriversify .ac-card { margin: auto; padding: 28px 26px 18px; }
html body #activity-chrome-ending.site-shriversify .ac-number { font-size: 15px; letter-spacing: 0.1em; line-height: 1.35; }
html body #activity-chrome-ending.site-shriversify .ac-lines {
  font-family: var(--ak-font-body);
  font-size: 18px;
  line-height: 1.42;
  text-align: left;
}
html body #activity-chrome-ending.site-shriversify .ac-line:first-child { color: var(--ak-ink); }
html body #activity-chrome-ending.site-shriversify .ac-line + .ac-line { margin-top: 10px; font-size: 17px; }
html body #activity-chrome-ending.site-shriversify .ac-actions button { min-height: 48px; font-size: 21px; }

/* Sideways the card lies across the table, clear of the lantern at the near corner: the verdict
   and Cross again on the left, the ending to read on the right. */
@media (orientation: landscape) and (max-height: 620px) {
  html body #activity-chrome-ending.site-shriversify {
    padding: 66px max(16px, env(safe-area-inset-right)) 12px max(116px, calc(env(safe-area-inset-left) + 104px));
  }
  html body #activity-chrome-ending.site-shriversify .ac-card {
    display: grid;
    grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.3fr);
    grid-template-rows: auto auto 1fr;
    column-gap: 26px;
    width: min(100%, 860px);
    max-height: calc(100dvh - 78px);
    padding: 20px 24px;
    text-align: left;
  }
  html body #activity-chrome-ending.site-shriversify .ac-number { grid-column: 1; grid-row: 1; }
  html body #activity-chrome-ending.site-shriversify .ac-verdict { grid-column: 1; grid-row: 2; }
  html body #activity-chrome-ending.site-shriversify .ac-actions { grid-column: 1; grid-row: 3; align-self: end; justify-content: flex-start; margin-top: 8px; }
  /* Only the words scroll, so the verdict and Cross again never leave the screen. */
  html body #activity-chrome-ending.site-shriversify .ac-lines { grid-column: 2; grid-row: 1 / span 3; min-height: 0; margin: 0; padding-right: 4px; overflow-y: auto; font-size: 17px; }
  html body #activity-chrome-ending.site-shriversify .ac-line + .ac-line { font-size: 16px; }
}
